Remove multi-run feature completely - simplify to single test execution only

This commit is contained in:
2025-12-29 10:45:05 +11:00
parent 947312906f
commit 110eb7a3f8
6 changed files with 4 additions and 448 deletions

View File

@@ -1,47 +0,0 @@
-- Multi-Run Statistics Database Migration
-- Creates test_suites table and modifies test_results for multi-run support
-- Create test_suites table to group multiple test runs
CREATE TABLE IF NOT EXISTS test_suites (
id SERIAL PRIMARY KEY,
suite_id TEXT UNIQUE NOT NULL,
user_uuid TEXT NOT NULL,
url TEXT NOT NULL,
device_type TEXT,
run_count INTEGER DEFAULT 1,
completed_runs INTEGER DEFAULT 0,
status TEXT DEFAULT 'running', -- running, completed, failed
created_at TIMESTAMP DEFAULT NOW(),
completed_at TIMESTAMP,
-- Statistical results (calculated after all runs complete)
median_performance_score NUMERIC,
avg_performance_score NUMERIC,
stddev_performance_score NUMERIC,
median_lcp NUMERIC,
avg_lcp NUMERIC,
stddev_lcp NUMERIC,
median_cls NUMERIC,
avg_cls NUMERIC,
stddev_cls NUMERIC,
median_tbt NUMERIC,
avg_tbt NUMERIC,
stddev_tbt NUMERIC
);
-- Add columns to test_results for multi-run support
ALTER TABLE test_results
ADD COLUMN IF NOT EXISTS suite_id TEXT,
ADD COLUMN IF NOT EXISTS run_number INTEGER DEFAULT 1,
ADD COLUMN IF NOT EXISTS is_median BOOLEAN DEFAULT FALSE;
-- Create index for faster lookups
CREATE INDEX IF NOT EXISTS idx_suite_id ON test_results(suite_id);
CREATE INDEX IF NOT EXISTS idx_test_suites_user ON test_suites(user_uuid);
CREATE INDEX IF NOT EXISTS idx_test_suites_status ON test_suites(status);
-- Comment
COMMENT ON TABLE test_suites IS 'Groups multiple test runs for statistical analysis';
COMMENT ON COLUMN test_results.suite_id IS 'Links individual run to parent test suite';
COMMENT ON COLUMN test_results.run_number IS 'Run number within the suite (1-10)';
COMMENT ON COLUMN test_results.is_median IS 'TRUE if this run represents the median performance';

View File

@@ -1,6 +0,0 @@
-- 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';

View File

@@ -1,27 +0,0 @@
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();

View File

@@ -1,56 +0,0 @@
#!/bin/bash
# Database Migration Script for Multi-Run Support
# Run this on the production server to apply schema changes
set -e # Exit on error
echo "=== Multi-Run Statistics Migration ==="
echo "Starting database migration..."
# Database connection details
DB_HOST="202.171.184.108"
DB_USER="postgres"
DB_NAME="WebPerformance"
DB_PORT="5432"
# Get script directory
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
MIGRATION_FILE="$SCRIPT_DIR/001_multi_run_support.sql"
# Check if migration file exists
if [ ! -f "$MIGRATION_FILE" ]; then
echo "Error: Migration file not found: $MIGRATION_FILE"
exit 1
fi
echo "Migration file: $MIGRATION_FILE"
echo "Target database: $DB_NAME on $DB_HOST"
echo ""
read -p "Continue with migration? (yes/no): " confirm
if [ "$confirm" != "yes" ]; then
echo "Migration cancelled"
exit 0
fi
# Run migration
echo "Applying migration..."
PGPASSWORD='X@gon2005!#$' psql -h "$DB_HOST" -U "$DB_USER" -d "$DB_NAME" -p "$DB_PORT" -f "$MIGRATION_FILE"
if [ $? -eq 0 ]; then
echo ""
echo "✅ Migration completed successfully!"
echo ""
echo "New tables/columns created:"
echo " - test_suites (new table)"
echo " - test_results.suite_id (new column)"
echo " - test_results.run_number (new column)"
echo " - test_results.is_median (new column)"
echo ""
echo "You can now deploy the application code."
else
echo ""
echo "❌ Migration failed!"
echo "Please check the error messages above."
exit 1
fi