import { BaseSchema } from '@adonisjs/lucid/schema' export default class extends BaseSchema { protected tableName = 'web_components' async up() { this.schema.createTable(this.tableName, (table) => { table.increments('id') table .integer('page_id') .unsigned() .notNullable() .references('id') .inTable('web_pages') .onDelete('CASCADE') table.string('type').notNullable() table.jsonb('data').notNullable() table.integer('sort_order').unsigned().notNullable().defaultTo(0) table.timestamp('created_at', { useTz: true }).notNullable() table.timestamp('updated_at', { useTz: true }).notNullable() table.index(['page_id', 'sort_order']) }) } async down() { this.schema.dropTable(this.tableName) } }