| 123456789101112131415161718192021222324252627282930 |
- import type { MigrationLiveDefinition } from '@d8d-appcontainer/types'
- import { DeleteStatus, EnableStatus } from "../../client/share/types.ts";
- // 定义资产归属区域表迁移
- const createZichanAreaTable: MigrationLiveDefinition = {
- name: "create_zichan_area_table",
- up: async (api) => {
- await api.schema.createTable('zichan_area', (table) => {
- table.increments('id').primary();
- table.string('name').notNullable().comment('区域名称');
- table.string('code').notNullable().unique().comment('区域编码');
- table.string('image_url').comment('区域图片');
- table.text('description').comment('区域描述');
- table.integer('is_enabled').defaultTo(EnableStatus.ENABLED).comment('是否启用 (0否 1是)');
- table.integer('is_deleted').defaultTo(DeleteStatus.NOT_DELETED).comment('是否被删除 (0否 1是)');
- table.timestamps(true, true);
-
- // 添加索引
- table.index('name');
- table.index('code');
- table.index('is_enabled');
- table.index('is_deleted');
- });
- },
- down: async (api) => {
- await api.schema.dropTable('zichan_area');
- }
- };
- export default createZichanAreaTable;
|