feat: replace php migration with django migration

- keep latest legacy version in initial migration file
- move propel schema to api legacy app
- remove legacy upgrade tool
This commit is contained in:
jo 2022-05-28 16:27:57 +02:00 committed by Kyle Robbertze
parent ee98387264
commit 0e4bc4cacd
85 changed files with 1005 additions and 1000 deletions

View file

@ -214,30 +214,22 @@ class AirtimeInstall
public static function CreateDatabaseTables($dbuser, $dbpasswd, $dbname, $dbhost, $dbport)
{
echo ' * Creating database tables' . PHP_EOL;
// Put Propel sql files in Database
// $command = AirtimeInstall::CONF_DIR_WWW."/library/propel/generator/bin/propel-gen ".AirtimeInstall::CONF_DIR_WWW."/build/ insert-sql 2>/dev/null";
$dir = self::GetAirtimeSrcDir() . '/build/sql/';
$files = ['schema.sql', 'sequences.sql', 'views.sql', 'triggers.sql', 'defaultdata.sql'];
foreach ($files as $f) {
$command = <<<"END"
PGPASSWORD={$dbpasswd} \\
/usr/bin/psql \\
--host={$dbhost} \\
--port={$dbport} \\
--dbname={$dbname} \\
--username={$dbuser} \\
--file {$dir}{$f} 2>&1
END;
@exec($command, $output, $results);
$con = Propel::getConnection();
$sqlDir = dirname(ROOT_PATH) . '/api/libretime_api/legacy/migrations/sql/';
$files = ['schema.sql', 'data.sql'];
foreach ($files as $file) {
try {
$sql = file_get_contents($sqlDir . $file);
$con->exec($sql);
} catch (PDOException $e) {
echo $e->getMessage();
throw $e;
}
}
AirtimeInstall::$databaseTablesCreated = true;
}
final public static function UpdateDatabaseTables()
{
UpgradeManager::doUpgrade();
}
public static function SetAirtimeVersion($p_version)
{
$con = Propel::getConnection();

View file

@ -126,7 +126,6 @@ class TestHelper
} else {
// Create all the database tables
AirtimeInstall::CreateDatabaseTables($dbuser, $dbpasswd, $dbname, $dbhost, $dbport);
AirtimeInstall::UpdateDatabaseTables();
}
}