Add deployment tracking schema (Migration 018)
Creates deployments and deployment_logs tables for tracking all deployment types (Docker, MCP, iOS/macOS, services). Includes deployment status, timing, git integration, and structured logging. Also adds run-migration.mjs helper for running migrations against PostgreSQL database. Part of CF-290, completes CF-291. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
62
run-migration.mjs
Normal file
62
run-migration.mjs
Normal file
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Run a migration file against the task-mcp database
|
||||
* Usage: node run-migration.mjs <migration-file>
|
||||
*/
|
||||
|
||||
import pg from 'pg';
|
||||
import { readFileSync } from 'fs';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { dirname, join } from 'path';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
||||
const { Pool } = pg;
|
||||
|
||||
// Database configuration
|
||||
const pool = new Pool({
|
||||
host: process.env.POSTGRES_HOST || 'infra.agiliton.internal',
|
||||
port: 5432,
|
||||
database: 'agiliton',
|
||||
user: 'agiliton',
|
||||
password: 'QtqiwCOAUpQNF6pjzOMAREzUny2bY8V1',
|
||||
max: 1,
|
||||
connectionTimeoutMillis: 5000,
|
||||
});
|
||||
|
||||
async function runMigration(migrationFile) {
|
||||
const client = await pool.connect();
|
||||
|
||||
try {
|
||||
console.log(`Running migration: ${migrationFile}`);
|
||||
|
||||
// Read migration file
|
||||
const migrationPath = join(__dirname, 'migrations', migrationFile);
|
||||
const sql = readFileSync(migrationPath, 'utf-8');
|
||||
|
||||
// Execute migration
|
||||
await client.query(sql);
|
||||
|
||||
console.log(`Migration completed successfully: ${migrationFile}`);
|
||||
} catch (error) {
|
||||
console.error(`Migration failed: ${error.message}`);
|
||||
throw error;
|
||||
} finally {
|
||||
client.release();
|
||||
await pool.end();
|
||||
}
|
||||
}
|
||||
|
||||
// Get migration file from command line
|
||||
const migrationFile = process.argv[2];
|
||||
|
||||
if (!migrationFile) {
|
||||
console.error('Usage: node run-migration.mjs <migration-file>');
|
||||
console.error('Example: node run-migration.mjs 018_deployments.sql');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
runMigration(migrationFile)
|
||||
.then(() => process.exit(0))
|
||||
.catch(() => process.exit(1));
|
||||
Reference in New Issue
Block a user