EverydayTech Platform - Developer Reference
Complete Source Code Documentation - All Applications
Loading...
Searching...
No Matches
migrate_add_platform.js
Go to the documentation of this file.
1/**
2 * Migration script: Add platform column to agents table
3 * Run with: node scripts/migrate_add_platform.js
4 */
5
6const pool = require('../services/db');
7
8/**
9 *
10 */
11async function migrate() {
12 try {
13 console.log('Adding platform column to agents table...');
14
15 await pool.query(`
16 ALTER TABLE agents ADD COLUMN IF NOT EXISTS platform VARCHAR(50);
17 `);
18
19 console.log('✅ Migration successful');
20
21 // Update existing agents
22 const result = await pool.query(`
23 UPDATE agents SET platform = 'unknown' WHERE platform IS NULL;
24 `);
25
26 console.log(`✅ Updated ${result.rowCount} existing agents`);
27
28 process.exit(0);
29 } catch (err) {
30 console.error('❌ Migration failed:', err);
31 process.exit(1);
32 }
33}
34
35migrate();