From 95c786f48477469676f387e4493014f11f6c8245 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 10 Mar 2022 17:33:01 +0100 Subject: [PATCH] migration to remove showEmail --- .../TransactionLink.ts | 61 +++++++++++++++++++ database/entity/TransactionLink.ts | 2 +- ...-remove_sendEmail_from_transaction_link.ts | 14 +++++ 3 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 database/entity/0031-remove_sendEmail_from_transaction_link/TransactionLink.ts create mode 100644 database/migrations/0031-remove_sendEmail_from_transaction_link.ts diff --git a/database/entity/0031-remove_sendEmail_from_transaction_link/TransactionLink.ts b/database/entity/0031-remove_sendEmail_from_transaction_link/TransactionLink.ts new file mode 100644 index 000000000..789644782 --- /dev/null +++ b/database/entity/0031-remove_sendEmail_from_transaction_link/TransactionLink.ts @@ -0,0 +1,61 @@ +import Decimal from 'decimal.js-light' +import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, DeleteDateColumn } from 'typeorm' +import { DecimalTransformer } from '../../src/typeorm/DecimalTransformer' + +@Entity('transaction_links') +export class TransactionLink extends BaseEntity { + @PrimaryGeneratedColumn('increment', { unsigned: true }) + id: number + + @Column({ unsigned: true, nullable: false }) + userId: number + + @Column({ + type: 'decimal', + precision: 40, + scale: 20, + nullable: false, + transformer: DecimalTransformer, + }) + amount: Decimal + + @Column({ + type: 'decimal', + name: 'hold_available_amount', + precision: 40, + scale: 20, + nullable: false, + transformer: DecimalTransformer, + }) + holdAvailableAmount: Decimal + + @Column({ length: 255, nullable: false, collation: 'utf8mb4_unicode_ci' }) + memo: string + + @Column({ length: 24, nullable: false, collation: 'utf8mb4_unicode_ci' }) + code: string + + @Column({ + type: 'datetime', + nullable: false, + }) + createdAt: Date + + @DeleteDateColumn() + deletedAt?: Date | null + + @Column({ + type: 'datetime', + nullable: false, + }) + validUntil: Date + + @Column({ + type: 'datetime', + nullable: true, + }) + redeemedAt?: Date | null + + @Column({ type: 'int', unsigned: true, nullable: true }) + redeemedBy?: number | null +} diff --git a/database/entity/TransactionLink.ts b/database/entity/TransactionLink.ts index fde2ba9e0..a483f0171 100644 --- a/database/entity/TransactionLink.ts +++ b/database/entity/TransactionLink.ts @@ -1 +1 @@ -export { TransactionLink } from './0030-transaction_link/TransactionLink' +export { TransactionLink } from './0031-remove_sendEmail_from_transaction_link/TransactionLink' diff --git a/database/migrations/0031-remove_sendEmail_from_transaction_link.ts b/database/migrations/0031-remove_sendEmail_from_transaction_link.ts new file mode 100644 index 000000000..76b2ee742 --- /dev/null +++ b/database/migrations/0031-remove_sendEmail_from_transaction_link.ts @@ -0,0 +1,14 @@ +/* MIGRATION TO REMOVE sendEmail FIELD FROM 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('ALTER TABLE `transaction_links` DROP COLUMN `showEmail`;') +} + +export async function downgrade(queryFn: (query: string, values?: any[]) => Promise>) { + await queryFn( + 'ALTER TABLE `transaction_links` ADD COLUMN `showEmail` boolean NOT NULL DEFAULT false AFTER `validUntil`;', + ) +}