also change memo column

This commit is contained in:
Ulf Gebhardt 2022-04-25 14:03:38 +02:00
parent efcd75717a
commit 73fe46c39d
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9
2 changed files with 11 additions and 2 deletions

View File

@ -16,7 +16,7 @@ export class AdminPendingCreation extends BaseEntity {
@Column({ type: 'datetime', nullable: false })
date: Date
@Column({ length: 256, nullable: true, default: null })
@Column({ length: 255, nullable: false, collation: 'utf8mb4_unicode_ci' })
memo: string
@Column({

View File

@ -1,4 +1,7 @@
/* MIGRATION TO CHANGE `amount` FIELD TYPE TO `Decimal` ON `admin_pending_creations` */
/* MIGRATION TO CHANGE SEVERAL FIELDS ON `admin_pending_creations`
* - `amount` FIELD TYPE TO `Decimal`
* - `memo` FIELD TYPE TO `varchar(255)`, collate `utf8mb4_unicode_ci`
*/
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
@ -18,9 +21,15 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis
)
// drop `amount_bitint` column
await queryFn('ALTER TABLE `admin_pending_creations` DROP COLUMN `amount_bigint`;')
// change `memo` to varchar(255), collate utf8mb4_unicode_ci
await queryFn(
'ALTER TABLE `admin_pending_creations` MODIFY COLUMN `memo` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL;',
)
}
export async function downgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
await queryFn('ALTER TABLE `admin_pending_creations` MODIFY COLUMN `memo` text DEFAULT NULL;')
await queryFn(
'ALTER TABLE `admin_pending_creations` ADD COLUMN `amount_bigint` bigint(20) DEFAULT NULL AFTER `amount`;',
)