011_createStockDataTable.ts 633 B

123456789101112131415161718192021
  1. import type { MigrationLiveDefinition } from '@d8d-appcontainer/types'
  2. const createStockDataTable: MigrationLiveDefinition = {
  3. name: "create_stock_data_table",
  4. up: async (api) => {
  5. await api.schema.createTable('stock_data', (table) => {
  6. table.increments("id").primary();
  7. table.string("code").notNullable().comment("股票代码");
  8. table.jsonb("data").notNullable().comment("股票数据");
  9. table.timestamps(true, true);
  10. // 添加索引
  11. table.unique("code");
  12. });
  13. },
  14. down: async (api) => {
  15. await api.schema.dropTable('stock_data');
  16. }
  17. }
  18. export default createStockDataTable;