import { BaseSchema } from '@adonisjs/lucid/schema'

export default class extends BaseSchema {
  protected tableName = 'users'

  async up() {
    this.schema.createTable(this.tableName, (table) => {
      table.uuid('id').primary()
      table.string('email', 254).notNullable().unique()
      table.string('password').nullable()
      table.string('legacy_password').nullable()
      table.string('username', 16).notNullable().unique()
      table.enum('status', ['active', 'banned', 'pending']).notNullable().defaultTo('active')
      table.date('date_of_birth').notNullable()
      table.enum('sex', ['male', 'female', 'other']).notNullable()
      table.dateTime('agreed_to_tos').notNullable()
      table.dateTime('password_changed_at').nullable()
      table.dateTime('created_at').notNullable()
      table.dateTime('updated_at').nullable()
      table.dateTime('deleted_at').nullable()
    })
  }

  async down() {
    this.schema.dropTable(this.tableName)
  }
}
