tour-operators) sharing add/edit lodging across admin and user facing side

This commit is contained in:
2026-02-19 18:09:20 -05:00
parent 18f9bbfbd7
commit cf2fd658f1
13 changed files with 1169 additions and 98 deletions

View File

@@ -303,11 +303,19 @@ export function runMigrations(db: Database): void {
id INTEGER PRIMARY KEY AUTOINCREMENT,
operator_id INTEGER NOT NULL REFERENCES tour_operators(id) ON DELETE CASCADE,
name TEXT NOT NULL,
description TEXT,
created_at TEXT NOT NULL DEFAULT (datetime('now')),
updated_at TEXT NOT NULL DEFAULT (datetime('now'))
)
`);
// Migration: add description to existing operator_tours tables
try {
db.run(`ALTER TABLE operator_tours ADD COLUMN description TEXT`);
} catch {
/* already exists */
}
// Template itinerary days for predefined operator tours
db.run(`
CREATE TABLE IF NOT EXISTS operator_tour_days (
@@ -322,6 +330,37 @@ export function runMigrations(db: Database): void {
)
`);
// Template plans (transport/lodging) attached to operator tour days
db.run(`
CREATE TABLE IF NOT EXISTS operator_tour_day_plans (
id INTEGER PRIMARY KEY AUTOINCREMENT,
operator_tour_day_id INTEGER NOT NULL REFERENCES operator_tour_days(id) ON DELETE CASCADE,
type TEXT NOT NULL CHECK (type IN ('transport', 'lodging')),
title TEXT NOT NULL,
notes TEXT,
position INTEGER NOT NULL DEFAULT 0,
created_at TEXT NOT NULL DEFAULT (datetime('now')),
updated_at TEXT NOT NULL DEFAULT (datetime('now'))
)
`);
// Lodging-specific fields for operator_tour_day_plans (type=lodging) — same shape as trip lodgings
for (const col of [
'chain TEXT',
'address_line1 TEXT',
'address_line2 TEXT',
'city_name TEXT',
'country TEXT',
'country_code TEXT',
'postal_code TEXT'
]) {
try {
db.run(`ALTER TABLE operator_tour_day_plans ADD COLUMN ${col}`);
} catch {
/* already exists */
}
}
// Countries table — editable list for admin (used by country selector)
db.run(`
CREATE TABLE IF NOT EXISTS countries (