AeThex-Connect/scripts/fix-channels.js
2026-02-28 23:50:09 -07:00

38 lines
1.4 KiB
JavaScript

const { Pool } = require('pg');
require('dotenv').config();
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
async function fixChannels() {
const pool = new Pool({ connectionString: process.env.DATABASE_URL?.replace('?sslmode=require', ''), ssl: true });
console.log('Adding missing columns to channels table...');
await pool.query(`ALTER TABLE channels ADD COLUMN IF NOT EXISTS channel_type VARCHAR(20) DEFAULT 'text'`);
console.log(' ✓ channel_type');
await pool.query(`ALTER TABLE channels ADD COLUMN IF NOT EXISTS position INTEGER DEFAULT 0`);
console.log(' ✓ position');
await pool.query(`ALTER TABLE channels ADD COLUMN IF NOT EXISTS description TEXT`);
console.log(' ✓ description');
await pool.query(`ALTER TABLE channels ADD COLUMN IF NOT EXISTS is_private BOOLEAN DEFAULT false`);
console.log(' ✓ is_private');
await pool.query(`ALTER TABLE channels ADD COLUMN IF NOT EXISTS slowmode_seconds INTEGER DEFAULT 0`);
console.log(' ✓ slowmode_seconds');
await pool.query(`ALTER TABLE channels ADD COLUMN IF NOT EXISTS created_at TIMESTAMP DEFAULT NOW()`);
console.log(' ✓ created_at');
await pool.query(`ALTER TABLE channels ADD COLUMN IF NOT EXISTS updated_at TIMESTAMP DEFAULT NOW()`);
console.log(' ✓ updated_at');
console.log('\n✅ Channels table updated!');
await pool.end();
}
fixChannels().catch(err => {
console.error('Error:', err.message);
process.exit(1);
});