diff --git a/database/migrations/20260126_add_tenant_id_to_all_tables.sql b/database/migrations/20260126_add_tenant_id_to_all_tables.sql index 838af8f..6c87db1 100644 --- a/database/migrations/20260126_add_tenant_id_to_all_tables.sql +++ b/database/migrations/20260126_add_tenant_id_to_all_tables.sql @@ -24,6 +24,7 @@ COMMENT ON COLUMN verification_codes.tenant_id IS 'Tenant ID for multi-tenancy s -- ============================================================================ ALTER TABLE admins ADD COLUMN IF NOT EXISTS tenant_id uuid; +ALTER TABLE admins ADD COLUMN IF NOT EXISTS is_super_admin boolean DEFAULT false; ALTER TABLE admin_users ADD COLUMN IF NOT EXISTS tenant_id uuid; ALTER TABLE audit_logs ADD COLUMN IF NOT EXISTS tenant_id uuid; ALTER TABLE evolution_logs ADD COLUMN IF NOT EXISTS tenant_id uuid; @@ -31,6 +32,7 @@ ALTER TABLE daily_statistics ADD COLUMN IF NOT EXISTS tenant_id uuid; ALTER TABLE monthly_financial_reports ADD COLUMN IF NOT EXISTS tenant_id uuid; CREATE INDEX IF NOT EXISTS idx_admins_tenant ON admins(tenant_id); +CREATE INDEX IF NOT EXISTS idx_admins_super_admin ON admins(is_super_admin); CREATE INDEX IF NOT EXISTS idx_admin_users_tenant ON admin_users(tenant_id); CREATE INDEX IF NOT EXISTS idx_audit_logs_tenant ON audit_logs(tenant_id); CREATE INDEX IF NOT EXISTS idx_evolution_logs_tenant ON evolution_logs(tenant_id);