#!/usr/bin/env node // Run from forecasting/ dir: DATABASE_URL= node seed-app.js import pg from 'pg' const { Pool } = pg const pool = new Pool({ connectionString: process.env.DATABASE_URL }) await pool.query(` INSERT INTO apps (slug, name, description, base_path, icon, theme_color, category, internal_host, internal_port) VALUES ('forecasting', 'Forecasting', 'Revenue forecasting and reporting', '/forecasting', 'TrendingUp', '#0077b6', 'Finance', '10.10.10.113', 3080) ON CONFLICT (slug) DO UPDATE SET name = EXCLUDED.name, description = EXCLUDED.description, base_path = EXCLUDED.base_path, icon = EXCLUDED.icon, theme_color = EXCLUDED.theme_color, category = EXCLUDED.category, internal_host = EXCLUDED.internal_host, internal_port = EXCLUDED.internal_port `) await pool.query(` INSERT INTO app_capabilities (app_id, slug, name, description, sort_order) SELECT a.id, c.slug, c.name, c.description, c.sort_order FROM apps a, (VALUES ('view', 'View Forecasts', 'View dashboard, forecasts, and history', 1), ('view_bookability', 'View Bookability', 'View the rate / bookability matrix', 2), ('view_competitor_rates', 'View Competitors', 'View competitor rate scraping and matrix', 3), ('view_accuracy', 'View Accuracy', 'View model accuracy metrics and backtesting', 4), ('manage_sync', 'Manage Data Sync', 'Trigger Newbook / Resos data syncs manually', 5), ('settings', 'Manage Settings', 'Configure Newbook credentials and sync schedules', 6) ) AS c(slug, name, description, sort_order) WHERE a.slug = 'forecasting' ON CONFLICT (app_id, slug) DO NOTHING `) console.log('forecasting app seeded.') await pool.end()