import { BaseSchema } from '@adonisjs/lucid/schema' export default class extends BaseSchema { protected tableName = 'scraped_parts' async up() { this.schema.createTable(this.tableName, (table) => { table.increments('id') table.integer('type_id').unsigned().references('id').inTable('component_types').notNullable() table.string('name').notNullable() table.float('price', 8, 2).notNullable() table.string('image_url').nullable() table.string('source').notNullable().defaultTo('pc-builder.io') table.string('source_url').notNullable() table.string('source_ref').notNullable() table.timestamp('scraped_at').notNullable() table.timestamp('created_at') table.timestamp('updated_at') table.unique(['source', 'source_ref']) table.index(['type_id']) }) } async down() { this.schema.dropTable(this.tableName) } }