import { BaseSchema } from '@adonisjs/lucid/schema' export default class extends BaseSchema { protected tableName = 'scraped_parts' async up() { this.schema.alterTable(this.tableName, (table) => { // Not every pc-builder.io listing has a fixed price (recent GPUs in // particular often only have a generic "search on Amazon" link with // no resolved offer) — these are now kept instead of being skipped, // so price must be nullable. table.float('price', 8, 2).nullable().alter() // Tracks where the currently stored `price`/`source_url` came from: // "pc-builder.io" for the original catalog price, or one of the // merchant names from merchant_price_service.ts (Amazon, LDLC, ...) // once a live price comparison finds (and persists) a cheaper offer. // Null means no price has ever been resolved for this part. table.string('price_source').nullable() table.timestamp('price_checked_at').nullable() }) } async down() { this.schema.alterTable(this.tableName, (table) => { table.dropColumn('price_source') table.dropColumn('price_checked_at') }) this.schema.alterTable(this.tableName, (table) => { table.float('price', 8, 2).notNullable().alter() }) } }