erp_be/scripts/patch-users-mobile-encryption.sql
2026-06-20 14:00:46 +05:30

13 lines
442 B
SQL

-- Expand users.mobile for AES-256-GCM ciphertext and add blind index for lookup.
-- Run once on deployed DB: psql "$DATABASE_URL" -f scripts/patch-users-mobile-encryption.sql
ALTER TABLE users
ALTER COLUMN mobile TYPE VARCHAR(255);
ALTER TABLE users
ADD COLUMN IF NOT EXISTS mobile_index VARCHAR(64);
CREATE INDEX IF NOT EXISTS idx_users_mobile_index
ON users (mobile_index)
WHERE deleted_at IS NULL AND mobile_index IS NOT NULL;