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

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

  async up() {
    this.schema.createTable(this.tableName, (table) => {
      table.uuid('id').primary()
      table.uuid('user_id').notNullable().unique().references('id').inTable('users').onDelete('CASCADE')
      table.enum('profile_visibility', ['public', 'private']).notNullable().defaultTo('public')
      table.string('display_name', 16).nullable()
      table.string('country', 2).nullable()
      table.string('locale', 2).notNullable().defaultTo('en')
    })
  }

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