You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
799 B
22 lines
799 B
/**
|
|
* @param { import("knex").Knex } knex
|
|
* @returns { Promise<void> }
|
|
*/
|
|
export const up = async knex => {
|
|
return knex.schema.createTable("users", function (table) {
|
|
table.increments("id").primary() // 自增主键
|
|
table.string("name", 100).notNullable() // 字符串字段(最大长度100)
|
|
table.string("email", 100).unique().notNullable() // 唯一邮箱
|
|
table.integer("age").unsigned() // 无符号整数
|
|
table.timestamp("created_at").defaultTo(knex.fn.now()) // 创建时间
|
|
table.timestamp("updated_at").defaultTo(knex.fn.now()) // 更新时间
|
|
})
|
|
}
|
|
|
|
/**
|
|
* @param { import("knex").Knex } knex
|
|
* @returns { Promise<void> }
|
|
*/
|
|
export const down = async knex => {
|
|
return knex.schema.dropTable("users") // 回滚时删除表
|
|
}
|
|
|