import BaseSchema from '@ioc:Adonis/Lucid/Schema'
import { PropertyType } from 'App/Models/Property'

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

    public async up() {
        this.schema.alterTable(this.tableName, (table) => {
            table.dropPrimary()
        })

        this.schema.alterTable(this.tableName, (table) => {
            table.dropColumn('id')
        })

        this.schema.alterTable(this.tableName, (table) => {
            table.increments('id').primary()
            table.enum('type', Object.values(PropertyType)).alter()
            table.string('remark').notNullable()
        })
    }

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