fix: database constraint on auth_tokens

This commit is contained in:
Sérgio Salgado 2021-04-07 02:16:16 +01:00 committed by Josh Harvey
parent 9b5cf32314
commit 3f6c0e6037
2 changed files with 6 additions and 5 deletions

View file

@ -25,8 +25,9 @@ exports.up = function (next) {
`CREATE TABLE auth_tokens (
token TEXT NOT NULL PRIMARY KEY,
type auth_token_type NOT NULL,
user_id UUID REFERENCES users(id) ON DELETE CASCADE UNIQUE,
expire TIMESTAMPTZ NOT NULL DEFAULT now() + interval '30 minutes'
user_id UUID REFERENCES users(id) ON DELETE CASCADE,
expire TIMESTAMPTZ NOT NULL DEFAULT now() + interval '30 minutes',
CONSTRAINT unique_userid_type UNIQUE (user_id, type)
)`,
`CREATE TABLE user_register_tokens (
token TEXT NOT NULL PRIMARY KEY,