memleketmeselesi/migrations/0010_kyc_upgrade.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

18 lines
958 B
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.

-- TC kimlik no şifreli sakla
ALTER TABLE users ADD COLUMN IF NOT EXISTS tc_kimlik_enc BYTEA;
ALTER TABLE users ADD COLUMN IF NOT EXISTS tc_kimlik_hash TEXT; -- SHA-256, tekrar kayıt kontrolü
-- verification_requests: eski path kolonları yerine şifreli blob path'leri + view token
ALTER TABLE verification_requests ADD COLUMN IF NOT EXISTS enc_key_id TEXT; -- hangi key versiyonu ile şifrelendi
ALTER TABLE verification_requests ADD COLUMN IF NOT EXISTS rejection_count INT NOT NULL DEFAULT 0;
-- Tek seferlik view token'ları (fotoğraf erişimi için)
CREATE TABLE IF NOT EXISTS kyc_view_tokens (
token TEXT PRIMARY KEY,
request_id BIGINT NOT NULL REFERENCES verification_requests(id) ON DELETE CASCADE,
created_by BIGINT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
expires_at TIMESTAMPTZ NOT NULL,
used_at TIMESTAMPTZ
);
CREATE INDEX IF NOT EXISTS idx_kyc_view_tokens_expires ON kyc_view_tokens(expires_at);