added deployment file
This commit is contained in:
1 parent
061d5fd8a4
commit
125eab3cd4
14 files changed
+704
-1
No files matched your search
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
if (PHP_SAPI !== 'cli') {
|
||||
http_response_code(404);
|
||||
exit;
|
||||
}
|
||||
|
||||
try {
|
||||
require '/var/www/html/includes/conn.php';
|
||||
foreach (['in_daper', 'in_soal', 'in_jawab'] as $table) {
|
||||
$conn->query("SELECT 1 FROM `$table` LIMIT 0");
|
||||
}
|
||||
|
||||
foreach (['001_admin.sql', '002_admin_identity.sql', '003_exam_attempts.sql'] as $file) {
|
||||
// Only migrate the historical rec_admin schema, preserving identities.
|
||||
if ($file === '002_admin_identity.sql'
|
||||
&& $conn->query("SHOW COLUMNS FROM rec_admin LIKE 'name'")->num_rows === 0) {
|
||||
continue;
|
||||
}
|
||||
$sql = file_get_contents('/var/www/html/dashboard/migrations/' . $file);
|
||||
$conn->multi_query($sql);
|
||||
do {
|
||||
$result = $conn->store_result();
|
||||
if ($result instanceof mysqli_result) {
|
||||
$result->free();
|
||||
}
|
||||
} while ($conn->more_results() && $conn->next_result());
|
||||
fwrite(STDOUT, "Applied: $file\n");
|
||||
}
|
||||
fwrite(STDOUT, "Database ready. Existing accounts and test data were preserved.\n");
|
||||
} catch (Throwable $error) {
|
||||
fwrite(STDERR, 'Migration failed: ' . $error->getMessage() . "\nImport the base database first; see docs/deployment.md.\n");
|
||||
exit(1);
|
||||
}
|
||||
Reference in new issue
Block a user