v0.12.0 codes for FCM and rebranded jama to RosterChirp
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* db.js — Postgres database layer for jama
|
||||
* db.js — Postgres database layer for rosterchirp
|
||||
*
|
||||
* APP_TYPE environment variable controls tenancy:
|
||||
* selfhost (default) → single schema 'public', one Postgres database
|
||||
@@ -32,8 +32,8 @@ if (APP_TYPE !== 'host') APP_TYPE = 'selfhost'; // only two valid values
|
||||
const pool = new Pool({
|
||||
host: process.env.DB_HOST || 'db',
|
||||
port: parseInt(process.env.DB_PORT || '5432'),
|
||||
database: process.env.DB_NAME || 'jama',
|
||||
user: process.env.DB_USER || 'jama',
|
||||
database: process.env.DB_NAME || 'rosterchirp',
|
||||
user: process.env.DB_USER || 'rosterchirp',
|
||||
password: process.env.DB_PASSWORD || '',
|
||||
max: 20,
|
||||
idleTimeoutMillis: 30000,
|
||||
@@ -52,12 +52,12 @@ function resolveSchema(req) {
|
||||
if (APP_TYPE === 'selfhost') return 'public';
|
||||
|
||||
const host = (req.headers.host || '').toLowerCase().split(':')[0];
|
||||
const baseDomain = (process.env.HOST_DOMAIN || 'jamachat.com').toLowerCase();
|
||||
const baseDomain = (process.env.HOST_DOMAIN || 'rosterchirp.com').toLowerCase();
|
||||
|
||||
// Internal requests (Docker health checks, localhost) → public schema
|
||||
if (host === 'localhost' || host === '127.0.0.1' || host === '::1') return 'public';
|
||||
|
||||
// Subdomain: team1.jamachat.com → tenant_team1
|
||||
// Subdomain: team1.rosterchirp.com → tenant_team1
|
||||
if (host.endsWith(`.${baseDomain}`)) {
|
||||
const slug = host.slice(0, -(baseDomain.length + 1));
|
||||
if (!slug || slug === 'www') throw new Error(`Invalid tenant slug: ${slug}`);
|
||||
@@ -198,7 +198,7 @@ async function runMigrations(schema) {
|
||||
|
||||
async function seedSettings(schema) {
|
||||
const defaults = [
|
||||
['app_name', process.env.APP_NAME || 'jama'],
|
||||
['app_name', process.env.APP_NAME || 'rosterchirp'],
|
||||
['logo_url', ''],
|
||||
['pw_reset_active', process.env.ADMPW_RESET === 'true' ? 'true' : 'false'],
|
||||
['icon_newchat', ''],
|
||||
@@ -213,7 +213,7 @@ async function seedSettings(schema) {
|
||||
['feature_branding', 'false'],
|
||||
['feature_group_manager', 'false'],
|
||||
['feature_schedule_manager', 'false'],
|
||||
['app_type', 'JAMA-Chat'],
|
||||
['app_type', 'RosterChirp-Chat'],
|
||||
['team_group_managers', ''],
|
||||
['team_schedule_managers', ''],
|
||||
['team_tool_managers', ''],
|
||||
@@ -269,7 +269,7 @@ async function seedUserGroups(schema) {
|
||||
|
||||
async function seedAdmin(schema) {
|
||||
const strip = s => (s || '').replace(/^['"]+|['"]+$/g, '').trim();
|
||||
const adminEmail = strip(process.env.ADMIN_EMAIL) || 'admin@jama.local';
|
||||
const adminEmail = strip(process.env.ADMIN_EMAIL) || 'admin@rosterchirp.local';
|
||||
const adminName = strip(process.env.ADMIN_NAME) || 'Admin User';
|
||||
const adminPass = strip(process.env.ADMIN_PASS) || 'Admin@1234';
|
||||
const pwReset = process.env.ADMPW_RESET === 'true';
|
||||
@@ -350,11 +350,11 @@ async function initDb() {
|
||||
await seedAdmin('public');
|
||||
await seedUserGroups('public');
|
||||
|
||||
// Host mode: the public schema is the host's own workspace — always full JAMA-Team plan.
|
||||
// Host mode: the public schema is the host's own workspace — always full RosterChirp-Team plan.
|
||||
// ON CONFLICT DO UPDATE ensures existing installs get corrected on restart too.
|
||||
if (APP_TYPE === 'host') {
|
||||
const hostPlan = [
|
||||
['app_type', 'JAMA-Team'],
|
||||
['app_type', 'RosterChirp-Team'],
|
||||
['feature_branding', 'true'],
|
||||
['feature_group_manager', 'true'],
|
||||
['feature_schedule_manager', 'true'],
|
||||
@@ -365,7 +365,7 @@ async function initDb() {
|
||||
[key, value]
|
||||
);
|
||||
}
|
||||
console.log('[DB] Host mode: public schema upgraded to JAMA-Team plan');
|
||||
console.log('[DB] Host mode: public schema upgraded to RosterChirp-Team plan');
|
||||
}
|
||||
|
||||
console.log('[DB] Initialisation complete');
|
||||
|
||||
5
backend/src/models/migrations/007_fcm_push.sql
Normal file
5
backend/src/models/migrations/007_fcm_push.sql
Normal file
@@ -0,0 +1,5 @@
|
||||
-- Migration 007: FCM push — add fcm_token column, relax NOT NULL on legacy web-push columns
|
||||
ALTER TABLE push_subscriptions ADD COLUMN IF NOT EXISTS fcm_token TEXT;
|
||||
ALTER TABLE push_subscriptions ALTER COLUMN endpoint DROP NOT NULL;
|
||||
ALTER TABLE push_subscriptions ALTER COLUMN p256dh DROP NOT NULL;
|
||||
ALTER TABLE push_subscriptions ALTER COLUMN auth DROP NOT NULL;
|
||||
4
backend/src/models/migrations/008_rebrand.sql
Normal file
4
backend/src/models/migrations/008_rebrand.sql
Normal file
@@ -0,0 +1,4 @@
|
||||
-- Migration 008: Rebrand — update app_type values from JAMA-* to RosterChirp-*
|
||||
UPDATE settings SET value = 'RosterChirp-Chat' WHERE key = 'app_type' AND value = 'JAMA-Chat';
|
||||
UPDATE settings SET value = 'RosterChirp-Brand' WHERE key = 'app_type' AND value = 'JAMA-Brand';
|
||||
UPDATE settings SET value = 'RosterChirp-Team' WHERE key = 'app_type' AND value = 'JAMA-Team';
|
||||
Reference in New Issue
Block a user