EverydayTech Platform - Developer Reference
Complete Source Code Documentation - All Applications
Loading...
Searching...
No Matches
apply_platform_migration.js
Go to the documentation of this file.
1#!/usr/bin/env node
2/**
3 * Apply platform column migration to production database
4 * Run this on a machine that has access to the production database
5 */
6
7const { Pool } = require('pg');
8require('dotenv').config();
9
10const pool = new Pool({
11 connectionString: process.env.DATABASE_URL,
12 ssl: process.env.DB_SSL === 'true' ? { rejectUnauthorized: false } : false
13});
14
15async function applyMigration() {
16 const client = await pool.connect();
17
18 try {
19 console.log('🔄 Applying platform column migration...');
20
21 await client.query(`
22 ALTER TABLE agents
23 ADD COLUMN IF NOT EXISTS platform VARCHAR(20);
24 `);
25
26 await client.query(`
27 COMMENT ON COLUMN agents.platform IS 'Operating system platform (win32, linux, darwin)';
28 `);
29
30 console.log('✅ Migration applied successfully!');
31 console.log(' - Added platform column to agents table');
32
33 } catch (err) {
34 console.error('❌ Migration failed:', err.message);
35 process.exit(1);
36 } finally {
37 client.release();
38 await pool.end();
39 }
40}
41
42applyMigration();