"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const migrate_1 = require("./migrate"); async function addJobsTable() { const client = await migrate_1.pool.connect(); try { await client.query('BEGIN'); await client.query(` CREATE TABLE IF NOT EXISTS jobs ( id SERIAL PRIMARY KEY, type VARCHAR(50) NOT NULL, status VARCHAR(50) DEFAULT 'pending', store_id INTEGER REFERENCES stores(id) ON DELETE CASCADE, progress INTEGER DEFAULT 0, total_items INTEGER, processed_items INTEGER DEFAULT 0, error TEXT, started_at TIMESTAMP, completed_at TIMESTAMP, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); CREATE INDEX IF NOT EXISTS idx_jobs_status ON jobs(status); CREATE INDEX IF NOT EXISTS idx_jobs_type ON jobs(type); CREATE INDEX IF NOT EXISTS idx_jobs_store_id ON jobs(store_id); `); await client.query('COMMIT'); console.log('✅ Jobs table created successfully'); } catch (error) { await client.query('ROLLBACK'); console.error('❌ Failed to create jobs table:', error); throw error; } finally { client.release(); } } addJobsTable() .then(() => process.exit(0)) .catch(() => process.exit(1));