From 4c163d7e5139212ff03faae181ff6fbe5968342d Mon Sep 17 00:00:00 2001 From: "val.istar.guo" Date: Sun, 5 May 2024 16:02:45 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E8=84=9A=E6=9C=AC=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E6=B7=BB=E5=8A=A0=E9=9C=80=E8=A6=81=E7=A6=81=E7=94=A8?= =?UTF-8?q?=E7=9A=84=E5=BA=94=E7=94=A8=E7=BC=96=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changeset/serious-lobsters-run.md | 5 +++ .../src/migrations/Migration20240428154537.ts | 37 ++++++++++++++++--- 2 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 .changeset/serious-lobsters-run.md diff --git a/.changeset/serious-lobsters-run.md b/.changeset/serious-lobsters-run.md new file mode 100644 index 0000000..1ec5481 --- /dev/null +++ b/.changeset/serious-lobsters-run.md @@ -0,0 +1,5 @@ +--- +"@opendoc/backend": patch +--- + +迁移脚本将自动添加常见的需要禁用的应用编号 diff --git a/app/backend/src/migrations/Migration20240428154537.ts b/app/backend/src/migrations/Migration20240428154537.ts index 5f66ffb..5cd00fd 100644 --- a/app/backend/src/migrations/Migration20240428154537.ts +++ b/app/backend/src/migrations/Migration20240428154537.ts @@ -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 { - 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 { - this.addSql('drop table if exists `forbidden_application_code`;'); + this.addSql('drop table if exists `forbidden_application_code`;') } - }