1743410408089_properties.ts 739 B

1234567891011121314151617181920212223242526
  1. import BaseSchema from '@ioc:Adonis/Lucid/Schema'
  2. import { PropertyType } from 'App/Models/Property'
  3. export default class extends BaseSchema {
  4. protected tableName = 'properties'
  5. public async up() {
  6. this.schema.alterTable(this.tableName, (table) => {
  7. table.dropPrimary()
  8. })
  9. this.schema.alterTable(this.tableName, (table) => {
  10. table.dropColumn('id')
  11. })
  12. this.schema.alterTable(this.tableName, (table) => {
  13. table.increments('id').primary()
  14. table.enum('type', Object.values(PropertyType)).alter()
  15. table.string('remark').notNullable()
  16. })
  17. }
  18. public async down() {
  19. this.schema.dropTable(this.tableName)
  20. }
  21. }