0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

Merge pull request #2841 from logto-io/charles-log-5084-alter-passcodes-table-and-set-jti-to-nullable

refactor(schemas): alter passcodes table and set jti to nullable
This commit is contained in:
Charles Zhao 2023-01-09 11:53:25 +08:00 committed by GitHub
commit d675cf26a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 1 deletions

View file

@ -0,0 +1,23 @@
import { sql } from 'slonik';
import type { AlterationScript } from '../lib/types/alteration.js';
const alteration: AlterationScript = {
up: async (pool) => {
await pool.query(sql`
alter table passcodes alter column interaction_jti drop not null;
create index passcodes__email_type on passcodes (email, type);
create index passcodes__phone_type on passcodes (phone, type);
`);
},
down: async (pool) => {
await pool.query(sql`
delete from passcodes where interaction_jti is null;
drop index passcodes__email_type;
drop index passcodes__phone_type;
alter table passcodes alter column interaction_jti set not null;
`);
},
};
export default alteration;

View file

@ -1,6 +1,6 @@
create table passcodes (
id varchar(21) not null,
interaction_jti varchar(128) not null,
interaction_jti varchar(128),
phone varchar(32),
email varchar(128),
type varchar(32) not null,
@ -16,3 +16,15 @@ on passcodes (
interaction_jti,
type
);
create index passcodes__email_type
on passcodes (
email,
type
);
create index passcodes__phone_type
on passcodes (
phone,
type
);