From d69d7e82b8bbb567668c935ace848c7dcf750b08 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Thu, 24 Jun 2021 21:09:24 +0200 Subject: Implement database schema Migrator This commit implements the new database schema Migrator which keeps track of the on-disk schema and the schema used by the codebase. It tries to makes future database schema upgrades user-friendlier. --- theme/admin/html/main.php | 2 +- theme/admin/html/migration.php | 59 ++++++++++++++++++++++++++++++++++++++++++ theme/admin/lang/de.php | 10 +++++++ theme/admin/lang/en.php | 10 +++++++ theme/admin/rsrc/css/main.css | 31 +++++++++++++++------- theme/admin/rsrc/css/main.scss | 32 ++++++++++++++++------- 6 files changed, 125 insertions(+), 19 deletions(-) create mode 100644 theme/admin/html/migration.php (limited to 'theme') diff --git a/theme/admin/html/main.php b/theme/admin/html/main.php index a7772ed..db637da 100644 --- a/theme/admin/html/main.php +++ b/theme/admin/html/main.php @@ -10,7 +10,7 @@
-
+
diff --git a/theme/admin/html/migration.php b/theme/admin/html/migration.php new file mode 100644 index 0000000..14405c4 --- /dev/null +++ b/theme/admin/html/migration.php @@ -0,0 +1,59 @@ + + + + + + + + <?=$Language->text('maintenance_mode')?> + + +
+
+
+ +
+
text('maintenance_mode')?>
+
+
+
+ +
+

text('maintenance_mode')?>

+ +

text('migration_successful')?>

+
    + +
  • Migration
  • + +
+ +

text("migration_upgrade", [$database_schema, $codebase_schema])?>

+
+
    + $commands): ?> +
  • +

    Migration

    +

    text('migration_notice', [$migration-1, $migration])?>

    +
    +
  • + +
+ + +
+ +
+
+ + diff --git a/theme/admin/lang/de.php b/theme/admin/lang/de.php index 0a848a6..3c7e834 100644 --- a/theme/admin/lang/de.php +++ b/theme/admin/lang/de.php @@ -143,3 +143,13 @@ $LANGUAGE['markdown_code'] = 'Codeblock'; $LANGUAGE['markdown_quote'] = 'Zitat'; $LANGUAGE['markdown_list_ul'] = 'Liste [ungeordnet]'; $LANGUAGE['markdown_list_ol'] = 'Liste [geordnet]'; + +#=============================================================================== +# Migrations +#=============================================================================== +$LANGUAGE['maintenance_mode'] = 'Wartungsmodus'; +$LANGUAGE['migration_upgrade'] = 'Eine Migration des Datenbankschemas ist erforderlich!
Die Datenbank verwendet die + Schema-Version %d, aber die Applikation benutzt die höhere Schema-Version %d.'; +$LANGUAGE['migration_notice'] = 'Die folgenden Kommandos migrieren das Datenbankschema von %d nach %d.'; +$LANGUAGE['migration_successful'] = 'Die folgenden Migrationen waren erfolgreich:'; +$LANGUAGE['migration_submit'] = 'Migrationen ausführen'; diff --git a/theme/admin/lang/en.php b/theme/admin/lang/en.php index 174a1d7..20482d4 100644 --- a/theme/admin/lang/en.php +++ b/theme/admin/lang/en.php @@ -143,3 +143,13 @@ $LANGUAGE['markdown_code'] = 'Code block'; $LANGUAGE['markdown_quote'] = 'Quote'; $LANGUAGE['markdown_list_ul'] = 'List [unordered]'; $LANGUAGE['markdown_list_ol'] = 'List [ordered]'; + +#=============================================================================== +# Migrations +#=============================================================================== +$LANGUAGE['maintenance_mode'] = 'Maintenance mode'; +$LANGUAGE['migration_upgrade'] = 'A database schema migration is required!
The on-disk schema version is + %d but the application uses the higher schema version %d.'; +$LANGUAGE['migration_notice'] = 'The following commands will migrate the database schema from %d to %d.'; +$LANGUAGE['migration_successful'] = 'The following migrations were successful:'; +$LANGUAGE['migration_submit'] = 'Run migrations'; diff --git a/theme/admin/rsrc/css/main.css b/theme/admin/rsrc/css/main.css index cfc6db9..7d93d94 100644 --- a/theme/admin/rsrc/css/main.css +++ b/theme/admin/rsrc/css/main.css @@ -140,18 +140,18 @@ body { .header-line { padding: 0.5rem 0.75rem; overflow: hidden; -} -.header-line:first-child { - background: #5E819F; - position: sticky; - top: 0; -} -.header-line:last-child { background: #EEE; + padding: 0.25rem 0.75rem; +} +.header-line + .header-line { border: 0.05rem solid #AAA; border-left: none; border-right: none; - padding: 0.25rem 0.75rem; +} +.header-line.background { + background: #5E819F; + position: sticky; + top: 0; } /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -308,11 +308,18 @@ pre { overflow: auto; -moz-tab-size: 4; tab-size: 4; + background: #EEE; + padding: 0.5rem; + border: 0.05rem solid #AAA; + font-style: italic; } code, pre { font-family: "monospace"; - color: #B03060; +} + +code { + color: #008B45; } p { @@ -344,6 +351,12 @@ img { display: none; } +.no-visual-list { + margin: 0; + padding: 0; + list-style: none; +} + #database-result { color: inherit; } diff --git a/theme/admin/rsrc/css/main.scss b/theme/admin/rsrc/css/main.scss index d1f43c9..cc9bbb1 100644 --- a/theme/admin/rsrc/css/main.scss +++ b/theme/admin/rsrc/css/main.scss @@ -145,19 +145,20 @@ body { .header-line { padding: 0.5rem 0.75rem; overflow: hidden; + background: #EEE; - &:first-child { - background: #5E819F; - position: sticky; - top: 0; - } + padding: 0.25rem 0.75rem; - &:last-child { - background: #EEE; + +.header-line { border: 0.05rem solid #AAA; border-left: none; border-right: none; - padding: 0.25rem 0.75rem; + } + + &.background { + background: #5E819F; + position: sticky; + top: 0; } } @@ -341,11 +342,18 @@ pre { overflow: auto; -moz-tab-size: 4; tab-size: 4; + background: #EEE; + padding: 0.5rem; + border: 0.05rem solid #AAA; + font-style: italic; } code, pre { font-family: "monospace"; - color: #B03060; +} + +code { + color: #008B45; } p { @@ -377,6 +385,12 @@ img { display: none; } +.no-visual-list { + margin: 0; + padding: 0; + list-style: none; +} + #database-result { color: inherit; } -- cgit v1.2.3