fix: add calendar_events.active, expand seed coverage, and refresh local init script
This commit is contained in:
+37
-10
@@ -186,16 +186,16 @@ export async function initSchema() {
|
||||
);
|
||||
`);
|
||||
|
||||
await db.query(`
|
||||
CREATE TABLE IF NOT EXISTS calendar_events (
|
||||
id SERIAL PRIMARY KEY,
|
||||
date DATE NOT NULL UNIQUE,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
type VARCHAR(100) NOT NULL,
|
||||
description TEXT,
|
||||
color VARCHAR(20) NOT NULL
|
||||
);
|
||||
`);
|
||||
await db.query(`CREATE TABLE IF NOT EXISTS calendar_events (
|
||||
id SERIAL PRIMARY KEY,
|
||||
date DATE NOT NULL UNIQUE,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
type VARCHAR(100) NOT NULL,
|
||||
description TEXT,
|
||||
color VARCHAR(20) NOT NULL,
|
||||
active BOOLEAN DEFAULT TRUE,
|
||||
created_at TIMESTAMP DEFAULT NOW()
|
||||
);`);
|
||||
|
||||
await db.query(`
|
||||
CREATE TABLE IF NOT EXISTS user_sessions (
|
||||
@@ -314,6 +314,33 @@ export async function seed() {
|
||||
if (configTaglineRows.length === 0) {
|
||||
await db.query(`INSERT INTO config (key, value) VALUES ($1, $2)`, ['tagline', tagline]);
|
||||
}
|
||||
|
||||
const { rows: calendarRows } = await db.query(`SELECT id FROM calendar_events`);
|
||||
if (calendarRows.length === 0) {
|
||||
await db.query(
|
||||
`INSERT INTO calendar_events (date, title, type, description, color, active) VALUES ($1, $2, $3, $4, $5, $6)`,
|
||||
['2026-06-30', 'Welcome Dinner', 'event', 'Andean tasting menu', '#b45309', true]
|
||||
);
|
||||
}
|
||||
|
||||
const { rows: socialRows } = await db.query(`SELECT id FROM social_events`);
|
||||
if (socialRows.length === 0) {
|
||||
await db.query(
|
||||
`INSERT INTO social_events (name, description, price, date, photos, featured_photo, active, sort_order) VALUES ($1, $2, $3, $4, '{}', null, $5, $6)`,
|
||||
['Sunset Tasting', 'Local wines on the terrace.', 'USD 35', '2026-07-04', true, 1]
|
||||
);
|
||||
}
|
||||
|
||||
const { rows: socialReservationRows } = await db.query(`SELECT id FROM social_event_reservations`);
|
||||
if (socialReservationRows.length === 0) {
|
||||
const { rows: adminIdRows } = await db.query(`SELECT id FROM users WHERE username = 'admin'`);
|
||||
if (adminIdRows.length > 0) {
|
||||
await db.query(
|
||||
`INSERT INTO social_event_reservations (user_id, social_event_id, guests, notes, status) SELECT $1, id, $2, $3, $4 FROM social_events LIMIT 1`,
|
||||
[adminIdRows[0].id, 2, 'Anniversary', 'confirmed']
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function resetDatabase() {
|
||||
|
||||
Reference in New Issue
Block a user