Browse Source

已成功完成数据库迁移文件014_createStockXunlianCodesTable.ts的创建

yourname 6 months ago
parent
commit
807dbe397c
1 changed files with 25 additions and 0 deletions
  1. 25 0
      server/migrations/014_createStockXunlianCodesTable.ts

+ 25 - 0
server/migrations/014_createStockXunlianCodesTable.ts

@@ -0,0 +1,25 @@
+import type { MigrationLiveDefinition } from '@d8d-appcontainer/types'
+
+const createStockXunlianCodesTable: MigrationLiveDefinition = {
+  name: "create_stock_xunlian_codes",
+  up: async (api) => {
+    await api.schema.createTable("stock_xunlian_codes", (table) => {
+      table.increments("id").primary();
+      table.string("code").notNullable().comment("股票代码");
+      table.string("stock_name").notNullable().comment("股票名称");
+      table.string("name").notNullable().comment("案例名称");
+      table.string("type").nullable().comment("案例类型");
+      table.string("description").nullable().comment("案例描述");
+      table.timestamp("trade_date").notNullable().comment("交易日期");
+      table.timestamps(true, true);
+
+      // 添加索引
+      table.unique("code");
+    });
+  },
+  down: async (api) => {
+    await api.schema.dropTable("stock_xunlian_codes");
+  }
+}
+
+export default createStockXunlianCodesTable;