From 3e363db42e4ba46223bb4c57ffd1174efb6070d6 Mon Sep 17 00:00:00 2001 From: elweyn Date: Wed, 24 Nov 2021 09:40:45 +0100 Subject: [PATCH] Adding a description of the migration. --- database/migrations/0005-admin_tables.ts | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/database/migrations/0005-admin_tables.ts b/database/migrations/0005-admin_tables.ts index 3730755f0..8e1219715 100644 --- a/database/migrations/0005-admin_tables.ts +++ b/database/migrations/0005-admin_tables.ts @@ -1,19 +1,24 @@ /* MIGRATION FOR ADMIN INTERFACE + * + * This migration is special since it takes into account that + * the database can be setup already but also may not be. + * Therefore you will find all `CREATE TABLE` statements with + * a `IF NOT EXISTS`, all `INSERT` with an `IGNORE` and in the + * downgrade function all `DROP TABLE` with a `IF EXISTS`. + * This ensures compatibility for existing or non-existing + * databases. */ export async function upgrade(queryFn: (query: string, values?: any[]) => Promise>) { await queryFn(` CREATE TABLE \`login_pending_tasks_admin\` ( \`id\` int UNSIGNED NOT NULL AUTO_INCREMENT, - \`user_id\` int UNSIGNED DEFAULT 0, - \`request\` varbinary(2048) NOT NULL, + \`userId\` int UNSIGNED DEFAULT 0, \`created\` datetime NOT NULL, - \`finished\` datetime DEFAULT '2000-01-01 000000', - \`result_json\` text DEFAULT NULL, - \`param_json\` text DEFAULT NULL, - \`task_type_id\` int UNSIGNED NOT NULL, - \`child_pending_task_id\` int UNSIGNED DEFAULT 0, - \`parent_pending_task_id\` int UNSIGNED DEFAULT 0, + \`date\` datetime NOT NULL, + \`note\` text DEFAULT NULL, + \`amount\` bigint(20) NOT NULL, + \`moderator\` int UNSIGNED DEFAULT 0, PRIMARY KEY (\`id\`) ) ENGINE = InnoDB DEFAULT CHARSET=utf8mb4; `)