update link registration site to executive dashboard

This commit is contained in:
Alberto-Audrix committed 2026-09-15 09:44:45 +07:00
1 parent 1e6f6b3b57
commit d0d1ae7d24
26 files changed
+1044 -55

No files matched your search

Binary file not shown.

Before

Width:  |  Height:  |  Size: 233 KiB

After

Width:  |  Height:  |  Size: 332 KiB

+17 -7
View File
@@ -1,6 +1,6 @@
-- =============================================================================
-- PostgreSQL Schema — CPSP Dashboard ERD
-- Source: ERD_dashboard.png (updated 2026-09-09 for GM cycle-close flow)
-- Source: ERD_dashboard.png (updated 2026-09-14 for slug site_id + pusat register)
--
-- user_access.status: active | inactive | superadmin
-- user_access.display_name: shown in dashboard UI (login still uses user_name)
@@ -10,6 +10,9 @@
-- left untouched so operators can be marked staff)
-- user_access → sites → kandang → cycles
-- user_access → api_keys (X-API-Key auth; hashed at rest)
-- sites.site_id: VARCHAR slug PK `{name-slug}-{4-digit}`, e.g. sukawarna-0001
-- sites.site_name UNIQUE
-- sites.pusat_*: code + executive active_site_id after register-to-central
-- cycles.status: active | pending_close | closed (GM approves end_date)
-- cycles.close_requested_by_id → user_access (optional)
-- kandang → flock → iot_panel
@@ -74,16 +77,23 @@ CREATE INDEX IF NOT EXISTS idx_api_keys_prefix ON api_keys (prefix);
-- -----------------------------------------------------------------------------
-- 2. Sites
-- site_id is a stable slug from site_name plus a 4-digit suffix
-- (e.g. sukawarna-4821), not a serial integer.
-- pusat_* filled when staff registers the site to executive HQ.
-- -----------------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS sites (
site_id SERIAL PRIMARY KEY,
site_name VARCHAR(30) NOT NULL,
user_id INTEGER NOT NULL REFERENCES user_access (user_id) ON DELETE CASCADE,
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP
site_id VARCHAR(64) PRIMARY KEY,
site_name VARCHAR(30) NOT NULL UNIQUE,
user_id INTEGER NOT NULL REFERENCES user_access (user_id) ON DELETE CASCADE,
pusat_code VARCHAR(64) NOT NULL DEFAULT '',
pusat_active_site_id BIGINT,
pusat_registered_at TIMESTAMP WITH TIME ZONE,
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX IF NOT EXISTS idx_sites_user_id ON sites (user_id);
CREATE INDEX IF NOT EXISTS idx_sites_pusat_active_site_id ON sites (pusat_active_site_id);
-- -----------------------------------------------------------------------------
-- 3. Kandang (Coop / Pen)
@@ -91,7 +101,7 @@ CREATE INDEX IF NOT EXISTS idx_sites_user_id ON sites (user_id);
CREATE TABLE IF NOT EXISTS kandang (
kandang_id SERIAL PRIMARY KEY,
kandang_name VARCHAR(30) NOT NULL,
site_id INTEGER NOT NULL REFERENCES sites (site_id) ON DELETE CASCADE,
site_id VARCHAR(64) NOT NULL REFERENCES sites (site_id) ON DELETE CASCADE,
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP
);