43 lines
1 KiB
JavaScript
43 lines
1 KiB
JavaScript
|
|
#!/usr/bin/env node
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Add missing columns to cards table
|
||
|
|
*
|
||
|
|
* This script adds quantity and favorited columns to the cards table.
|
||
|
|
*/
|
||
|
|
|
||
|
|
import dotenv from 'dotenv';
|
||
|
|
import { neon } from '@neondatabase/serverless';
|
||
|
|
|
||
|
|
// Load environment variables from .env.local
|
||
|
|
dotenv.config({ path: '.env.local' });
|
||
|
|
|
||
|
|
async function addCardColumns() {
|
||
|
|
const sql = neon(process.env.POSTGRES_URL);
|
||
|
|
|
||
|
|
try {
|
||
|
|
console.log('✅ Connecting to Neon database...');
|
||
|
|
|
||
|
|
// Add quantity column
|
||
|
|
await sql`
|
||
|
|
ALTER TABLE cards
|
||
|
|
ADD COLUMN IF NOT EXISTS quantity INTEGER DEFAULT 0
|
||
|
|
`;
|
||
|
|
console.log('✅ Added quantity column to cards table');
|
||
|
|
|
||
|
|
// Add favorited column
|
||
|
|
await sql`
|
||
|
|
ALTER TABLE cards
|
||
|
|
ADD COLUMN IF NOT EXISTS favorited BOOLEAN DEFAULT false
|
||
|
|
`;
|
||
|
|
console.log('✅ Added favorited column to cards table');
|
||
|
|
|
||
|
|
console.log('🎉 Card columns added successfully!');
|
||
|
|
|
||
|
|
} catch (error) {
|
||
|
|
console.error('❌ Failed to add columns:', error.message);
|
||
|
|
process.exit(1);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
addCardColumns();
|