1700557040664_users.ts 809 B

1234567891011121314151617181920212223
  1. import BaseSchema from '@ioc:Adonis/Lucid/Schema'
  2. export default class extends BaseSchema {
  3. protected tableName = 'users'
  4. public async up() {
  5. this.schema.createTable(this.tableName, (table) => {
  6. table.increments('id')
  7. table.datetime('created_at', { useTz: true })
  8. table.datetime('updated_at', { useTz: true })
  9. table.enum('role', ['admin', 'user']).defaultTo('user')
  10. table.string('username', 80).notNullable().unique()
  11. table.string('phone', 120).nullable().unique()
  12. table.string('email', 190).notNullable().unique()
  13. table.string('password').nullable()
  14. table.string('avatar').nullable()
  15. })
  16. }
  17. public async down() {
  18. this.schema.dropTable(this.tableName)
  19. }
  20. }