1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00
unleash.unleash/src/migrations/20220908093515-add-public-signup-tokens.js
2022-09-30 15:20:24 +03:00

37 lines
1.1 KiB
JavaScript

'use strict';
exports.up = function (db, callback) {
db.runSql(
`
create table IF NOT EXISTS public_signup_tokens
(
secret text primary key,
name text,
expires_at timestamp with time zone not null,
created_at timestamp with time zone not null default now(),
created_by text,
role_id integer not null references roles (id) ON DELETE CASCADE
);
create table IF NOT EXISTS public_signup_tokens_user
(
secret text not null references public_signup_tokens (secret) on DELETE CASCADE,
user_id integer not null references users (id) ON DELETE CASCADE,
created_at timestamp with time zone not null default now(),
primary key (secret, user_id)
);
`,
callback,
);
};
exports.down = function (db, callback) {
db.runSql(
`
DROP TABLE IF EXISTS public_signup_tokens_user;
DROP TABLE IF EXISTS public_signup_tokens;
`,
callback,
);
};