mirror of
https://github.com/logto-io/logto.git
synced 2025-02-03 21:48:55 -05:00
refactor(schemas): alter passcodes table and set jti to nullable
This commit is contained in:
parent
8bcb4de1c0
commit
0decdb796d
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 (
|
create table passcodes (
|
||||||
id varchar(21) not null,
|
id varchar(21) not null,
|
||||||
interaction_jti varchar(128) not null,
|
interaction_jti varchar(128),
|
||||||
phone varchar(32),
|
phone varchar(32),
|
||||||
email varchar(128),
|
email varchar(128),
|
||||||
type varchar(32) not null,
|
type varchar(32) not null,
|
||||||
|
@ -16,3 +16,15 @@ on passcodes (
|
||||||
interaction_jti,
|
interaction_jti,
|
||||||
type
|
type
|
||||||
);
|
);
|
||||||
|
|
||||||
|
create index passcodes__email_type
|
||||||
|
on passcodes (
|
||||||
|
email,
|
||||||
|
type
|
||||||
|
);
|
||||||
|
|
||||||
|
create index passcodes__phone_type
|
||||||
|
on passcodes (
|
||||||
|
phone,
|
||||||
|
type
|
||||||
|
);
|
||||||
|
|
Loading…
Add table
Reference in a new issue