deckhearth/scripts/add-card-columns.js
Randall Stillwell bb60b4f6b0 Enhanced card detail page with real data and functionality
- Updated card detail page to fetch real data from API
- Added ownership tracking with quantity management
- Added favorite system for cards
- Added collection and deck management functionality
- Created API endpoints for ownership, favorites, collections, and decks
- Added database columns for quantity and favorited status
- Shows current collections and decks the card belongs to
- Added proper error handling and loading states
- Integrated with real card data from database
- Added purchase links to TCGPlayer and eBay
2025-07-24 15:03:09 -05:00

43 lines
No EOL
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();