From 5f5bde2f0f336cc43fef7da40b31861583e4bfd1 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Wed, 9 Mar 2022 11:38:24 +0100 Subject: [PATCH] migration to create transaction_links table --- database/migrations/0030-transaction_link.ts | 25 ++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 database/migrations/0030-transaction_link.ts diff --git a/database/migrations/0030-transaction_link.ts b/database/migrations/0030-transaction_link.ts new file mode 100644 index 000000000..ca0f0cfa5 --- /dev/null +++ b/database/migrations/0030-transaction_link.ts @@ -0,0 +1,25 @@ +/* MIGRATION TO CREATE TRANSACTION_LINK TABLE */ + +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +/* eslint-disable @typescript-eslint/no-explicit-any */ + +export async function upgrade(queryFn: (query: string, values?: any[]) => Promise>) { + await queryFn(` + CREATE TABLE \`transaction_links\` ( + \`id\` int UNSIGNED NOT NULL AUTO_INCREMENT, + \`userId\` int UNSIGNED NOT NULL, + \`amount\` DECIMAL(40,20) NOT NULL, + \`memo\` varchar(255) NOT NULL, + \`createdAt\` datetime NOT NULL, + \`validUntil\` datetime NOT NULL, + \`showEmail\` boolean NOT NULL DEFAULT false, + \`redeemedAt\` datetime, + \`redeemedBy\` int UNSIGNED, + PRIMARY KEY (\`id\`) + ) ENGINE = InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + `) +} + +export async function downgrade(queryFn: (query: string, values?: any[]) => Promise>) { + await queryFn(`DROP TABLE \`transaction_links\`;`) +}