deckhearth/scripts/add-updated-at-column.js

36 lines
885 B
JavaScript
Raw Normal View History

#!/usr/bin/env node
/**
* Add updated_at column to cards table
*
* This script adds the updated_at column to the cards table if it doesn't exist.
*/
import dotenv from 'dotenv';
import { neon } from '@neondatabase/serverless';
// Load environment variables from .env.local
dotenv.config({ path: '.env.local' });
async function addUpdatedAtColumn() {
const sql = neon(process.env.POSTGRES_URL);
try {
console.log('✅ Connecting to Neon database...');
// Add updated_at column
await sql`
ALTER TABLE cards
ADD COLUMN IF NOT EXISTS updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
`;
console.log('✅ Added updated_at column to cards table');
console.log('🎉 Updated_at column added successfully!');
} catch (error) {
console.error('❌ Failed to add column:', error.message);
process.exit(1);
}
}
addUpdatedAtColumn();