Files
FamilyHUB/backend/migrations/000005_create_otp.up.sql
T
admin a0fb49a00f
Build and Deploy / build-and-deploy (push) Successful in 56s
Added possibility deploy with k3s
2026-05-24 21:58:46 +03:00

18 lines
427 B
SQL

CREATE UNLOGGED TABLE otp
(
user_id BIGINT NOT NULL,
otp TEXT NOT NULL,
expired_at TIMESTAMP NOT NULL,
FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE
);
CREATE INDEX idx_otp_user_id ON otp (user_id);
CREATE INDEX idx_otp_expired_at ON otp (expired_at);
SELECT cron.schedule(
'cleanup-expired-otp',
'*/10 * * * *',
$$DELETE FROM otp WHERE expired_at <= NOW()$$
);