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.
24 lines
1.3 KiB
SQL
24 lines
1.3 KiB
SQL
-- 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;
|