made client data browsable with dropdown and version diffs
This commit is contained in:
11
db_init.php
11
db_init.php
@ -6,7 +6,7 @@ require_once __DIR__ . '/common.php';
|
||||
define('QDB_PATH', __DIR__ . '/uploads/questionnaire_database');
|
||||
define('QDB_LOCK', __DIR__ . '/uploads/.qdb_lock');
|
||||
define('QDB_SCHEMA', __DIR__ . '/schema.sql');
|
||||
define('QDB_VERSION', 5);
|
||||
define('QDB_VERSION', 6);
|
||||
|
||||
function qdb_table_exists(PDO $pdo, string $table): bool {
|
||||
$stmt = $pdo->prepare(
|
||||
@ -101,6 +101,15 @@ function qdb_apply_migrations(PDO $pdo, string $schemaSql): bool {
|
||||
}
|
||||
}
|
||||
|
||||
$currentVersion = (int)$pdo->query('PRAGMA user_version')->fetchColumn();
|
||||
if ($currentVersion < 6 && qdb_table_exists($pdo, 'questionnaire_submission')) {
|
||||
$pdo->exec(
|
||||
'UPDATE questionnaire_submission SET submittedAt = completedAt
|
||||
WHERE completedAt IS NOT NULL AND submittedAt != completedAt'
|
||||
);
|
||||
$changed = true;
|
||||
}
|
||||
|
||||
$currentVersion = (int)$pdo->query('PRAGMA user_version')->fetchColumn();
|
||||
if ($currentVersion < QDB_VERSION) {
|
||||
$pdo->exec('PRAGMA foreign_keys = OFF;');
|
||||
|
||||
Reference in New Issue
Block a user