| 12345678910111213141516171819202122232425262728293031 |
- import type { MigrationLiveDefinition } from '@d8d-appcontainer/types'
- import { DeleteStatus , EnableStatus} from "../../client/share/types.ts";
- // 定义设备类型表迁移
- const createDeviceTypesTable: MigrationLiveDefinition = {
- name: "create_device_types_table",
- up: async (api) => {
- await api.schema.createTable('device_types', (table) => {
- table.increments('id').primary();
- table.string('name').notNullable();
- table.string('code').notNullable().unique();
- table.string('image_url');
- table.text('description');
- table.integer('is_enabled').defaultTo(EnableStatus.ENABLED);
- table.integer('is_deleted').defaultTo(DeleteStatus.NOT_DELETED);
- 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('device_types');
- }
- };
- export default createDeviceTypesTable
|