memleketmeselesi/migrations/0008_permissions_scope.sql
Mukan Erkin 2498e75594 init: memleketmeselesi platform — API + migrations
FastAPI + PostgreSQL 16. KYC, issue sistemi, permission/group yönetimi,
session yönetimi, API client auth (kışla kapısı), officials/persons CRUD.
Migration 0001–0013 dahil.
2026-04-27 23:06:59 +03:00

24 lines
1.3 KiB
SQL
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- permissions tablosuna scope kolonu ekle
-- scope=FALSE → kullanıcının yalnızca kendi içeriğine uygulanır (örn. kendi yorumunu sil)
-- scope=TRUE → admin kapsamı, herhangi bir içeriğe uygulanır
ALTER TABLE permissions ADD COLUMN IF NOT EXISTS scope BOOLEAN NOT NULL DEFAULT FALSE;
-- Eski unique constraint'i kaldır, scope dahil yeni constraint ekle
ALTER TABLE permissions DROP CONSTRAINT IF EXISTS permissions_module_action_key;
ALTER TABLE permissions ADD CONSTRAINT permissions_module_action_scope_key UNIQUE (module, action, scope);
-- Mevcut izinlere scope=FALSE atandı (DEFAULT ile zaten geldi)
-- Admin scope varyantlarını ekle
INSERT INTO permissions (module, action, description, scope) VALUES
-- comment admin scope
('comment', 'delete', 'Herhangi bir yorumu sil', TRUE),
-- issue admin scope
('issue', 'update', 'Herhangi bir sorunu güncelle', TRUE),
('issue', 'delete', 'Herhangi bir sorunu sil', TRUE),
-- profile admin scope
('profile', 'update', 'Herhangi bir profili güncelle', TRUE),
('profile', 'delete', 'Herhangi bir profili sil', TRUE),
-- report admin scope
('report', 'create', 'Herhangi bir kullanıcı için rapor oluştur', TRUE)
ON CONFLICT (module, action, scope) DO NOTHING;