Migrate the Laysense production snapshot to LaySite 1.3
This commit is contained in:
+15
-10
@@ -62,6 +62,21 @@ final class Database
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($version < 4) {
|
||||
$columns = array_column($pdo->query('PRAGMA table_info(pages)')->fetchAll(), 'name');
|
||||
foreach (['header_id', 'footer_id', 'palette_id', 'layout_id'] as $column) {
|
||||
if (!in_array($column, $columns, true)) {
|
||||
$pdo->exec("ALTER TABLE pages ADD COLUMN $column INTEGER REFERENCES design_presets(id)");
|
||||
}
|
||||
}
|
||||
$pdo->exec('CREATE UNIQUE INDEX IF NOT EXISTS pages_layout_id ON pages(layout_id)');
|
||||
}
|
||||
if ($version < 6 && !in_array('page_type', array_column($pdo->query('PRAGMA table_info(pages)')->fetchAll(), 'name'), true)) {
|
||||
$pdo->exec("ALTER TABLE pages ADD COLUMN page_type TEXT NOT NULL DEFAULT 'page' CHECK (page_type IN ('page', 'maintenance', 'not-found'))");
|
||||
}
|
||||
if ($version === 0 && $pdo->query('SELECT id FROM site_settings WHERE id = 1')->fetchColumn() === false) {
|
||||
SiteSnapshot::install($pdo);
|
||||
}
|
||||
$pdo->prepare('INSERT OR IGNORE INTO site_settings (id, payload) VALUES (1, ?)')->execute([self::json(['name' => '我的网站'])]);
|
||||
$pdo->prepare("INSERT OR IGNORE INTO pages
|
||||
(slug, name, title, description, heading, accent, lead, image, alt, actions, quicklinks)
|
||||
@@ -82,16 +97,6 @@ final class Database
|
||||
if ($version < 2) {
|
||||
OAuthCredentials::migrateLegacy($pdo);
|
||||
}
|
||||
if ($version < 4) {
|
||||
$columns = $pdo->query('PRAGMA table_info(pages)')->fetchAll();
|
||||
if (!in_array('layout_id', array_column($columns, 'name'), true)) {
|
||||
$pdo->exec('ALTER TABLE pages ADD COLUMN layout_id INTEGER REFERENCES design_presets(id)');
|
||||
}
|
||||
$pdo->exec('CREATE UNIQUE INDEX IF NOT EXISTS pages_layout_id ON pages(layout_id)');
|
||||
}
|
||||
if ($version < 6 && !in_array('page_type', array_column($pdo->query('PRAGMA table_info(pages)')->fetchAll(), 'name'), true)) {
|
||||
$pdo->exec("ALTER TABLE pages ADD COLUMN page_type TEXT NOT NULL DEFAULT 'page' CHECK (page_type IN ('page', 'maintenance', 'not-found'))");
|
||||
}
|
||||
if ($version < 5) {
|
||||
LayoutPage::migrate($pdo);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user