mirror of
https://github.com/DeNNiiInc/Web-Page-Performance-Test.git
synced 2026-04-17 20:05:58 +00:00
Phase 3: Add filmstrip column to DB and update runner
This commit is contained in:
6
migrations/002_add_filmstrip.sql
Normal file
6
migrations/002_add_filmstrip.sql
Normal file
@@ -0,0 +1,6 @@
|
||||
-- Add filmstrip column to test_results table
|
||||
ALTER TABLE test_results
|
||||
ADD COLUMN filmstrip JSONB DEFAULT '[]'::jsonb;
|
||||
|
||||
-- Comment on column
|
||||
COMMENT ON COLUMN test_results.filmstrip IS 'Array of filmstrip screenshots/thumbnails from Lighthouse';
|
||||
27
migrations/migrate_002.js
Normal file
27
migrations/migrate_002.js
Normal file
@@ -0,0 +1,27 @@
|
||||
const db = require('../lib/db');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const migrationFile = path.join(__dirname, '002_add_filmstrip.sql');
|
||||
|
||||
async function runMigration() {
|
||||
try {
|
||||
console.log('Reading migration file:', migrationFile);
|
||||
const sql = fs.readFileSync(migrationFile, 'utf8');
|
||||
|
||||
console.log('Applying migration...');
|
||||
await db.pool.query(sql);
|
||||
|
||||
console.log('✅ Migration 002 applied successfully!');
|
||||
process.exit(0);
|
||||
} catch (err) {
|
||||
if (err.code === '42701') { // duplicate_column
|
||||
console.log('⚠️ Column already exists. Skipping.');
|
||||
process.exit(0);
|
||||
}
|
||||
console.error('❌ Migration failed:', err);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
runMigration();
|
||||
Reference in New Issue
Block a user