Files
Enterprise-Knowledge-Base/migrations/versioned/000052_user_system_admin.up.sql
T
wizardchen 47a183aa65 feat(system-admin): implement bootstrap for system admin promotion and enhance system settings management
- Added WEKNORA_BOOTSTRAP_SYSTEM_ADMIN_EMAIL environment variable to promote a specified user to system admin on startup.
- Introduced a new bootstrap process in `bootstrap.go` to handle the promotion logic.
- Updated `.env.example` to document the new environment variable and its behavior.
- Created new views for managing system administrators and system settings, including listing, promoting, and revoking admin privileges.
- Enhanced the frontend to reflect the new system admin features, including UI elements for admin management and settings configuration.
- Updated API interfaces to support system admin functionalities, ensuring proper data handling and user management.
2026-05-26 21:13:56 +08:00

18 lines
849 B
SQL

-- Migration: 000052_user_system_admin
-- Adds system-level administrator flag to users table. System admins operate
-- independently of tenant-scoped roles and have platform-wide privileges.
-- This enables organization-level superuser management, separate from per-tenant
-- admin/owner roles. The IsSystemAdmin flag is indexed for efficient queries
-- on privilege checks and admin listing.
DO $$ BEGIN RAISE NOTICE '[Migration 000052] Adding users.is_system_admin column...'; END $$;
ALTER TABLE users
ADD COLUMN IF NOT EXISTS is_system_admin BOOLEAN NOT NULL DEFAULT FALSE;
CREATE INDEX IF NOT EXISTS idx_users_is_system_admin ON users (is_system_admin);
COMMENT ON COLUMN users.is_system_admin IS 'Whether the user is a system administrator (independent of tenant roles)';
DO $$ BEGIN RAISE NOTICE '[Migration 000052] Done.'; END $$;