- Add backend stale process monitoring API (/api/stale-processes) - Add users management route - Add frontend landing page and stale process monitor UI on /scraper-tools - Move old development scripts to backend/archive/ - Update frontend build with new features 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
53 lines
1.7 KiB
TypeScript
53 lines
1.7 KiB
TypeScript
import { pool } from './src/db/migrate';
|
|
|
|
async function fixBrandsTable() {
|
|
console.log('🔧 Fixing brands table structure...\n');
|
|
|
|
try {
|
|
// Drop old tables
|
|
await pool.query('DROP TABLE IF EXISTS store_brands CASCADE');
|
|
await pool.query('DROP TABLE IF EXISTS product_brands CASCADE');
|
|
await pool.query('DROP TABLE IF EXISTS brands CASCADE');
|
|
|
|
console.log('✅ Dropped old tables');
|
|
|
|
// Create brands table with correct structure
|
|
await pool.query(`
|
|
CREATE TABLE brands (
|
|
id SERIAL PRIMARY KEY,
|
|
name VARCHAR(255) UNIQUE NOT NULL,
|
|
logo_url TEXT,
|
|
first_seen_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
last_seen_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
)
|
|
`);
|
|
console.log('✅ Created brands table');
|
|
|
|
// Create store_brands junction table
|
|
await pool.query(`
|
|
CREATE TABLE store_brands (
|
|
id SERIAL PRIMARY KEY,
|
|
store_id INTEGER REFERENCES stores(id) ON DELETE CASCADE,
|
|
brand_id INTEGER REFERENCES brands(id) ON DELETE CASCADE,
|
|
first_seen_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
last_seen_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
active BOOLEAN DEFAULT true,
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
UNIQUE(store_id, brand_id)
|
|
)
|
|
`);
|
|
console.log('✅ Created store_brands table');
|
|
|
|
console.log('\n✅ Brands tables fixed!');
|
|
} catch (error) {
|
|
console.error('❌ Error:', error);
|
|
} finally {
|
|
await pool.end();
|
|
}
|
|
}
|
|
|
|
fixBrandsTable();
|