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

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

  async up() {
    this.schema.createTable(this.tableName, (table) => {
      table.increments('id')
      table
        .integer('country_id')
        .unsigned()
        .references('id')
        .inTable('master_data_countries')
        .onDelete('SET NULL')
        .nullable()
      table.string('country_code').nullable()
      table.string('state_name').nullable()
      table.string('name').notNullable()
      table.string('latitude').nullable()
      table.string('longitude').nullable()
      table.boolean('is_active').defaultTo(true)

      table.timestamp('created_at')
      table.timestamp('updated_at')
    })
  }

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