Files
miem_workers/migrations/sqlite/014_system_user_council_role.sql
T
codex 508aae4f8a
CI / Fingerprint diagnostics (production deployment temporarily disabled) (pull_request) Canceled after 0s
CI / test (pull_request) Canceled after 10m43s
feat: add council user role and restrict crawl runs
2026-11-12 09:35:26 +00:00

32 lines
1.3 KiB
SQL

PRAGMA foreign_keys = OFF;
BEGIN IMMEDIATE;
CREATE TABLE system_users_new (
id INTEGER PRIMARY KEY,
username VARCHAR(64) NOT NULL UNIQUE,
full_name VARCHAR(255) NOT NULL,
role VARCHAR(16) NOT NULL CONSTRAINT ck_system_users_role CHECK (role IN ('admin', 'user', 'council')),
is_active BOOLEAN NOT NULL,
password_hash TEXT NOT NULL,
must_change_password BOOLEAN NOT NULL,
session_version INTEGER NOT NULL,
first_login_at DATETIME,
last_login_at DATETIME,
password_changed_at DATETIME,
password_reset_at DATETIME,
failed_login_attempts INTEGER NOT NULL,
locked_until DATETIME,
created_at DATETIME NOT NULL
);
INSERT INTO system_users_new
SELECT id, username, full_name, role, is_active, password_hash, must_change_password, session_version,
first_login_at, last_login_at, password_changed_at, password_reset_at, failed_login_attempts,
locked_until, created_at
FROM system_users;
DROP TABLE system_users;
ALTER TABLE system_users_new RENAME TO system_users;
CREATE TEMP TABLE check_user_action_references (violations INTEGER CHECK (violations = 0));
INSERT INTO check_user_action_references SELECT count(*) FROM pragma_foreign_key_check('user_actions');
DROP TABLE check_user_action_references;
COMMIT;
PRAGMA foreign_keys = ON;