mirror of
https://github.com/stackblitz/bolt.new
synced 2025-06-26 18:17:50 +00:00
feat: 修改数据库迁移脚本和模型,创建用户表并定义User模型
This commit is contained in:
parent
052bc6e0aa
commit
fd34ac25ce
@ -1,4 +1,4 @@
|
||||
exports.up = function(knex) {
|
||||
export function up(knex) {
|
||||
return knex.schema.createTable('users', function(table) {
|
||||
table.increments('_id').primary().comment('主键ID');
|
||||
table.string('username', 255).notNullable().unique().comment('用户名');
|
||||
@ -13,8 +13,8 @@ exports.up = function(knex) {
|
||||
table.timestamp('_create').defaultTo(knex.fn.now()).comment('创建时间');
|
||||
table.timestamp('_update').defaultTo(knex.fn.now()).comment('更新时间');
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
exports.down = function(knex) {
|
||||
export function down(knex) {
|
||||
return knex.schema.dropTable('users');
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
const { Model } = require('objection');
|
||||
import { Model } from 'objection';
|
||||
|
||||
class User extends Model {
|
||||
export class User extends Model {
|
||||
static get tableName() {
|
||||
return 'users';
|
||||
}
|
||||
@ -26,4 +26,3 @@ class User extends Model {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = User;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// knexfile.js
|
||||
module.exports = {
|
||||
export default {
|
||||
development: {
|
||||
client: 'mysql2',
|
||||
connection: {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user