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

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

  async up() {
    this.schema.createTable(this.tableName, (table) => {
      table.increments('id')
      table.string('codigo_psu').notNullable()
      table.string('artigo').notNullable()
      table.string('nome').notNullable()
      table.text('descricao').nullable()
      table.decimal('valor', 12, 2).notNullable()
      table.string('moeda').defaultTo('MZN')
      table.string('marca').nullable()
      table.string('categoria').nullable()
      table.integer('estoque').defaultTo(0)
      table.timestamp('created_at')
      table.timestamp('updated_at').nullable()
    })
  }

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