|
|
@ -1,19 +1,19 @@ |
|
|
|
<?php |
|
|
|
<?php |
|
|
|
|
|
|
|
|
|
|
|
if (count($argv) !== 2) { |
|
|
|
if (count($argv) !== 2) { |
|
|
|
echo "Need the www base path as argument"; |
|
|
|
echo "Need the www base path as argument"; |
|
|
|
exit(0); |
|
|
|
exit(0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$www = $argv[1]; |
|
|
|
$www = $argv[1]; |
|
|
|
|
|
|
|
|
|
|
|
require("$www/include/config.php"); |
|
|
|
require("$www/app/config.php"); |
|
|
|
require("$www/include/connect.php"); |
|
|
|
require("$www/app/connect.php"); |
|
|
|
require("$www/include/functions.php"); |
|
|
|
require("$www/app/functions.php"); |
|
|
|
|
|
|
|
|
|
|
|
$migrations = getMigrationSchemas(); |
|
|
|
$migrations = getMigrationSchemas(); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
$req = $bdd->prepare('SELECT `sql_schema` FROM `application` LIMIT 1'); |
|
|
|
$req = $bdd->prepare('SELECT `sql_schema` FROM `application` LIMIT 1'); |
|
|
|
$req->execute(); |
|
|
|
$req->execute(); |
|
|
|
$data = $req->fetch(); |
|
|
|
$data = $req->fetch(); |
|
|
@ -22,14 +22,13 @@ |
|
|
|
if ($data['sql_schema']) { |
|
|
|
if ($data['sql_schema']) { |
|
|
|
$sql_schema = $data['sql_schema']; |
|
|
|
$sql_schema = $data['sql_schema']; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} // Table does not exist |
|
|
|
// Table does not exist |
|
|
|
catch (Exception $e) { |
|
|
|
catch (Exception $e) { |
|
|
|
|
|
|
|
$sql_schema = -1; |
|
|
|
$sql_schema = -1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// For each migrations |
|
|
|
// For each migrations |
|
|
|
foreach ($migrations as $migration_value) { |
|
|
|
foreach ($migrations as $migration_value) { |
|
|
|
|
|
|
|
|
|
|
|
// Do the migration, we are behind the last schema |
|
|
|
// Do the migration, we are behind the last schema |
|
|
|
if ($sql_schema < $migration_value) { |
|
|
|
if ($sql_schema < $migration_value) { |
|
|
@ -39,8 +38,7 @@ |
|
|
|
try { |
|
|
|
try { |
|
|
|
$sql = file_get_contents($sql_file); |
|
|
|
$sql = file_get_contents($sql_file); |
|
|
|
$bdd->exec($sql); |
|
|
|
$bdd->exec($sql); |
|
|
|
} |
|
|
|
} catch (PDOException $e) { |
|
|
|
catch (PDOException $e) { |
|
|
|
|
|
|
|
printError($e->getMessage()); |
|
|
|
printError($e->getMessage()); |
|
|
|
exit(1); |
|
|
|
exit(1); |
|
|
|
} |
|
|
|
} |
|
|
@ -50,6 +48,4 @@ |
|
|
|
|
|
|
|
|
|
|
|
echo "Moved to schema $migration_value\n"; |
|
|
|
echo "Moved to schema $migration_value\n"; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
?> |
|
|
|
|
|
|
|