gradido/database/migrations/0071-add-pending_transactions-table.ts
2023-08-22 01:29:17 +02:00

35 lines
1.6 KiB
TypeScript

/* MIGRATION TO add new pending_transactions 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<Array<any>>) {
await queryFn(`
CREATE TABLE pending_transactions (
id int unsigned NOT NULL AUTO_INCREMENT,
previous int(10) unsigned DEFAULT NULL NULL,
type_id int(10) DEFAULT NULL NULL,
transaction_link_id int(10) unsigned DEFAULT NULL NULL,
amount decimal(40,20) DEFAULT NULL NULL,
balance decimal(40,20) DEFAULT NULL NULL,
balance_date datetime(3) DEFAULT current_timestamp(3) NOT NULL,
decay decimal(40,20) DEFAULT NULL NULL,
decay_start datetime(3) DEFAULT NULL NULL,
memo varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
creation_date datetime(3) DEFAULT NULL NULL,
user_id int(10) unsigned NOT NULL,
user_gradido_id char(36) NOT NULL,
user_name varchar(512) COLLATE utf8mb4_unicode_ci DEFAULT NULL NULL,
linked_user_id int(10) unsigned DEFAULT NULL NULL,
linked_user_gradido_id char(36) NOT NULL,
linked_user_name varchar(512) COLLATE utf8mb4_unicode_ci DEFAULT NULL NULL,
linked_transaction_id int(10) DEFAULT NULL NULL,
state int(10) DEFAULT NULL NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;`)
}
export async function downgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
await queryFn(`DROP TABLE pending_transactions;`)
}