Skip to content

Commit

Permalink
迁移脚本自动添加需要禁用的应用编号
Browse files Browse the repository at this point in the history
  • Loading branch information
Val-istar-Guo committed May 5, 2024
1 parent a5a8aa1 commit 4c163d7
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/serious-lobsters-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@opendoc/backend": patch
---

迁移脚本将自动添加常见的需要禁用的应用编号
37 changes: 31 additions & 6 deletions app/backend/src/migrations/Migration20240428154537.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,39 @@
import { Migration } from '@mikro-orm/migrations';
/* eslint-disable @typescript-eslint/require-await */
import { Migration } from '@mikro-orm/migrations'

export class Migration20240428154537 extends Migration {
const forbiddenCodes = [
'buka',
'webpack',
'rollup',
'react',
'vue',
'angular',
'nestjs',
'next',
'types',
'nuxt',
'nuxtjs',
'tailwindcss',
'asyncapi',
'shikijs',
'vueuse',
'tabler',
'pinia',
'typescript-eslint',
'eslint',
]

export class Migration20240428154537 extends Migration {
async up(): Promise<void> {
this.addSql('create table `forbidden_application_code` (`id` bigint unsigned not null auto_increment primary key comment \'主键\', `created_at` datetime not null default CURRENT_TIMESTAMP comment \'创建时间\', `updated_at` datetime not null default CURRENT_TIMESTAMP comment \'更新时间\', `code` varchar(255) not null comment \'唯一应用编码\') default character set utf8mb4 engine = InnoDB;');
this.addSql('alter table `forbidden_application_code` add unique `forbidden_application_code_code_unique`(`code`);');
this.addSql('create table `forbidden_application_code` (`id` bigint unsigned not null auto_increment primary key comment \'主键\', `created_at` datetime not null default CURRENT_TIMESTAMP comment \'创建时间\', `updated_at` datetime not null default CURRENT_TIMESTAMP comment \'更新时间\', `code` varchar(255) not null comment \'唯一应用编码\');')
this.addSql('alter table `forbidden_application_code` add unique `forbidden_application_code_code_unique`(`code`);')

for (const code of forbiddenCodes) {
this.addSql(`insert into \`forbidden_application_code\` (\`code\`) values ('${code}');`)
}
}

async down(): Promise<void> {
this.addSql('drop table if exists `forbidden_application_code`;');
this.addSql('drop table if exists `forbidden_application_code`;')
}

}

0 comments on commit 4c163d7

Please sign in to comment.