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:
commit
d675cf26a8
2 changed files with 36 additions and 1 deletions
|
@ -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;
|
|
@ -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
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue