SysOps: approved_backup — 2026-08-16 11:01 UTC
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
-- Cockpit login users + page permissions
|
||||
CREATE TABLE IF NOT EXISTS cockpit_users (
|
||||
id SERIAL PRIMARY KEY,
|
||||
username TEXT NOT NULL UNIQUE,
|
||||
password_hash TEXT NOT NULL,
|
||||
display_name TEXT,
|
||||
role TEXT NOT NULL DEFAULT 'user' CHECK (role IN ('admin', 'user')),
|
||||
is_active BOOLEAN NOT NULL DEFAULT TRUE,
|
||||
permissions JSONB NOT NULL DEFAULT '{}'::jsonb,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
last_login_at TIMESTAMPTZ
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_cockpit_users_username ON cockpit_users (username);
|
||||
|
||||
COMMENT ON TABLE cockpit_users IS 'Foodlinkk Cockpit UI login accounts';
|
||||
COMMENT ON COLUMN cockpit_users.permissions IS 'JSON: {"pages":["dashboard","revenue",...], "manage_users": true}';
|
||||
@@ -0,0 +1,4 @@
|
||||
ALTER TABLE cockpit_users
|
||||
ADD COLUMN IF NOT EXISTS avatar_url TEXT;
|
||||
|
||||
COMMENT ON COLUMN cockpit_users.avatar_url IS 'Public URL under /static/uploads/avatars/…';
|
||||
@@ -0,0 +1,38 @@
|
||||
-- War Room + 1:1 agent chat rooms/messages
|
||||
CREATE TABLE IF NOT EXISTS warroom_rooms (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
kind TEXT NOT NULL CHECK (kind IN ('warroom', 'dm')),
|
||||
agent_key VARCHAR(64) REFERENCES agent_souls(agent_key) ON DELETE CASCADE,
|
||||
title TEXT NOT NULL DEFAULT '',
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
CONSTRAINT warroom_rooms_kind_agent CHECK (
|
||||
(kind = 'warroom' AND agent_key IS NULL) OR
|
||||
(kind = 'dm' AND agent_key IS NOT NULL)
|
||||
)
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS warroom_rooms_one_warroom
|
||||
ON warroom_rooms ((kind)) WHERE kind = 'warroom';
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS warroom_rooms_dm_agent
|
||||
ON warroom_rooms (agent_key) WHERE kind = 'dm';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS warroom_messages (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
room_id BIGINT NOT NULL REFERENCES warroom_rooms(id) ON DELETE CASCADE,
|
||||
sender_type TEXT NOT NULL CHECK (sender_type IN ('user', 'agent', 'system')),
|
||||
agent_key VARCHAR(64),
|
||||
username TEXT,
|
||||
sender_avatar_url TEXT,
|
||||
content TEXT NOT NULL,
|
||||
metadata JSONB NOT NULL DEFAULT '{}'::jsonb,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS warroom_messages_room_created
|
||||
ON warroom_messages (room_id, created_at);
|
||||
|
||||
INSERT INTO warroom_rooms (kind, agent_key, title)
|
||||
SELECT 'warroom', NULL, 'War Room'
|
||||
WHERE NOT EXISTS (SELECT 1 FROM warroom_rooms WHERE kind = 'warroom');
|
||||
Reference in New Issue
Block a user