Fix cashup app seed: correct host to 10.10.10.117 and port to 3083
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
7fd1ed8381
commit
2d89fd9227
1 changed files with 79 additions and 20 deletions
79
src/db.js
79
src/db.js
|
|
@ -26,6 +26,8 @@ export async function initDb() {
|
||||||
icon TEXT NOT NULL DEFAULT 'ClipboardList',
|
icon TEXT NOT NULL DEFAULT 'ClipboardList',
|
||||||
theme_color TEXT NOT NULL DEFAULT '#1e3a5f',
|
theme_color TEXT NOT NULL DEFAULT '#1e3a5f',
|
||||||
category VARCHAR(100),
|
category VARCHAR(100),
|
||||||
|
internal_host TEXT,
|
||||||
|
internal_port INTEGER DEFAULT 3080,
|
||||||
active BOOLEAN NOT NULL DEFAULT TRUE,
|
active BOOLEAN NOT NULL DEFAULT TRUE,
|
||||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||||
);
|
);
|
||||||
|
|
@ -36,22 +38,79 @@ export async function initDb() {
|
||||||
granted_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
granted_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||||
PRIMARY KEY (user_id, app_id)
|
PRIMARY KEY (user_id, app_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS roles (
|
||||||
|
id SERIAL PRIMARY KEY,
|
||||||
|
name TEXT UNIQUE NOT NULL,
|
||||||
|
slug TEXT UNIQUE NOT NULL,
|
||||||
|
description TEXT,
|
||||||
|
is_default BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS role_app_perms (
|
||||||
|
role_id INTEGER NOT NULL REFERENCES roles(id) ON DELETE CASCADE,
|
||||||
|
app_id INTEGER NOT NULL REFERENCES apps(id) ON DELETE CASCADE,
|
||||||
|
PRIMARY KEY (role_id, app_id)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS user_roles (
|
||||||
|
user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||||
|
role_id INTEGER NOT NULL REFERENCES roles(id) ON DELETE CASCADE,
|
||||||
|
granted_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||||
|
source TEXT NOT NULL DEFAULT 'manual'
|
||||||
|
CHECK (source IN ('manual', 'workforce_department', 'default')),
|
||||||
|
PRIMARY KEY (user_id, role_id)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS workforce_department_roles (
|
||||||
|
department_id TEXT NOT NULL PRIMARY KEY,
|
||||||
|
department_name TEXT NOT NULL,
|
||||||
|
role_id INTEGER NOT NULL REFERENCES roles(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS pending_registrations (
|
||||||
|
id SERIAL PRIMARY KEY,
|
||||||
|
email TEXT NOT NULL,
|
||||||
|
wf_user_id TEXT NOT NULL,
|
||||||
|
wf_name TEXT NOT NULL,
|
||||||
|
pin_hash TEXT NOT NULL,
|
||||||
|
attempts INTEGER NOT NULL DEFAULT 0,
|
||||||
|
expires_at TIMESTAMPTZ NOT NULL,
|
||||||
|
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||||
|
);
|
||||||
`)
|
`)
|
||||||
|
|
||||||
// Add category column to existing installs
|
// Migrations for existing installs
|
||||||
await pool.query(`ALTER TABLE apps ADD COLUMN IF NOT EXISTS category VARCHAR(100)`)
|
await pool.query(`ALTER TABLE apps ADD COLUMN IF NOT EXISTS category VARCHAR(100)`)
|
||||||
|
await pool.query(`ALTER TABLE apps ADD COLUMN IF NOT EXISTS internal_host TEXT`)
|
||||||
|
await pool.query(`ALTER TABLE apps ADD COLUMN IF NOT EXISTS internal_port INTEGER DEFAULT 3080`)
|
||||||
|
await pool.query(`ALTER TABLE users ADD COLUMN IF NOT EXISTS workforce_user_id TEXT`)
|
||||||
|
await pool.query(`CREATE UNIQUE INDEX IF NOT EXISTS users_workforce_user_id_idx ON users (workforce_user_id) WHERE workforce_user_id IS NOT NULL`)
|
||||||
|
await pool.query(`CREATE UNIQUE INDEX IF NOT EXISTS pending_reg_email_idx ON pending_registrations (email)`)
|
||||||
|
|
||||||
// Seed built-in apps
|
// Seed built-in apps — internal_host/port used by management for health checks and auto-deploy
|
||||||
await pool.query(`
|
await pool.query(`
|
||||||
INSERT INTO apps (slug, name, description, base_path, icon, theme_color, category)
|
INSERT INTO apps (slug, name, description, base_path, icon, theme_color, category, internal_host, internal_port)
|
||||||
VALUES
|
VALUES
|
||||||
('noticeboard', 'Noticeboard', 'Staff notices and announcements', '/notices', 'ClipboardList', '#1e3a5f', NULL),
|
('noticeboard', 'Noticeboard', 'Staff notices and announcements', '/notices', 'ClipboardList', '#1e3a5f', NULL, '10.10.10.112', 3080),
|
||||||
('kitchen', 'Kitchen Flash','Invoice processing and GP tracking', '/kitchen', 'ChefHat', '#e85d04', 'Kitchen'),
|
('kitchen', 'Kitchen Flash','Invoice processing and GP tracking', '/kitchen', 'ChefHat', '#e85d04', 'Kitchen', '10.10.10.110', 3080),
|
||||||
('cashup', 'Cash Up', 'Hotel daily cashing up', '/cashup', 'Banknote', '#6b2d8b', 'Finance'),
|
('cashup', 'Cash Up', 'Hotel daily cashing up', '/cashup', 'Banknote', '#6b2d8b', 'Finance', '10.10.10.117', 3083),
|
||||||
('housekeeping','Housekeeping', 'Room status and task management', '/hk', 'BedDouble', '#2d6a4f', 'Housekeeping'),
|
('housekeeping','Housekeeping', 'Room status and task management', '/hk', 'BedDouble', '#2d6a4f', 'Housekeeping', '10.10.10.114', 3080),
|
||||||
('forecasting', 'Forecasting', 'Revenue forecasting and reporting', '/forecast','TrendingUp', '#0077b6', 'Finance'),
|
('forecasting', 'Forecasting', 'Revenue forecasting and reporting', '/forecast','TrendingUp', '#0077b6', 'Finance', '10.10.10.113', 3080),
|
||||||
('rates', 'Rate Scraper', 'Competitor rate monitoring', '/rates', 'Tag', '#7b4f00', 'Finance')
|
('rates', 'Rate Scraper', 'Competitor rate monitoring', '/rates', 'Tag', '#7b4f00', 'Finance', '10.10.10.115', 3080)
|
||||||
ON CONFLICT (slug) DO UPDATE SET icon = EXCLUDED.icon, category = EXCLUDED.category
|
ON CONFLICT (slug) DO UPDATE SET
|
||||||
|
icon = EXCLUDED.icon,
|
||||||
|
category = EXCLUDED.category,
|
||||||
|
internal_host = EXCLUDED.internal_host,
|
||||||
|
internal_port = EXCLUDED.internal_port
|
||||||
|
`)
|
||||||
|
|
||||||
|
// Seed default Staff role
|
||||||
|
await pool.query(`
|
||||||
|
INSERT INTO roles (name, slug, description, is_default)
|
||||||
|
VALUES ('Staff', 'staff', 'Default role assigned to all self-registered employees', TRUE)
|
||||||
|
ON CONFLICT (slug) DO NOTHING
|
||||||
`)
|
`)
|
||||||
|
|
||||||
// Seed first admin user if table is empty
|
// Seed first admin user if table is empty
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue