Removed database related leftovers.

This commit is contained in:
flash 2024-08-27 03:23:04 +00:00
parent 281575bc51
commit 7d83bfbbe5
3 changed files with 0 additions and 84 deletions

View file

@ -1,24 +0,0 @@
<?php
use Index\Data\IDbConnection;
use Index\Data\Migration\IDbMigration;
final class InitialStructure_20231106_004121 implements IDbMigration {
public function migrate(IDbConnection $conn): void {
$existingTables = [];
$result = $conn->query('SHOW TABLES');
while($result->next())
$existingTables[] = $result->getString(0);
if(!in_array('exchange-rates', $existingTables))
$conn->execute('
CREATE TABLE `exchange-rates` (
rate_from BINARY(3) NOT NULL,
rate_to BINARY(3) NOT NULL,
rate_value DECIMAL(20,6) NOT NULL,
rate_stored TIMESTAMP NOT NULL DEFAULT current_timestamp(),
PRIMARY KEY (rate_from, rate_to),
KEY rate_stored (rate_stored)
) ENGINE=InnoDB COLLATE="utf8mb4_bin"
');
}
}

View file

@ -1,34 +0,0 @@
#!/usr/bin/env php
<?php
require_once __DIR__ . '/../satori.php';
try {
touch(SAT_ROOT . '/.migrating');
chmod(SAT_ROOT . '/.migrating', 0777);
$db = $sat->getDatabase();
echo 'Creating migration manager...' . PHP_EOL;
$manager = $db->createMigrationManager();
echo 'Preparing to run migrations...' . PHP_EOL;
$manager->init();
echo 'Creating migration repository...' . PHP_EOL;
$repo = $db->createMigrationRepo();
echo 'Running migrations...' . PHP_EOL;
$completed = $manager->processMigrations($repo);
if(empty($completed)) {
echo 'There were no migrations to run!' . PHP_EOL;
} else {
echo 'The following migrations have been completed:' . PHP_EOL;
foreach($completed as $migration)
echo ' - ' . $migration . PHP_EOL;
}
echo PHP_EOL;
} finally {
unlink(SAT_ROOT . '/.migrating');
}

View file

@ -1,26 +0,0 @@
#!/usr/bin/env php
<?php
use Index\Data\Migration\FsDbMigrationRepo;
require_once __DIR__ . '/../satori.php';
$db = $sat->getDatabase();
$repo = $db->createMigrationRepo();
if(!($repo instanceof FsDbMigrationRepo)) {
echo 'Migration repository type does not support creation of templates.' . PHP_EOL;
return;
}
$baseName = implode(' ', array_slice($argv, 1));
$manager = $db->createMigrationManager();
try {
$names = $manager->createNames($baseName);
} catch(InvalidArgumentException $ex) {
echo $ex->getMessage() . PHP_EOL;
return;
}
$repo->saveMigrationTemplate($names->name, $manager->template($names->className));
echo "Template for '{$names->className}' has been saved to {$names->name}.php." . PHP_EOL;