Files
foodlinkk-command-center/migrations/041_cockpit_users.sql
T

19 lines
800 B
SQL
Raw Normal View History

-- 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}';