0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-06 20:40:08 -05:00
logto/packages/schemas/alterations/next-1735012422-add-saml-application-sessions-table.ts

38 lines
1.3 KiB
TypeScript
Raw Permalink Normal View History

2024-12-12 04:41:17 -05:00
import { sql } from '@silverhand/slonik';
import type { AlterationScript } from '../lib/types/alteration.js';
import { applyTableRls, dropTableRls } from './utils/1704934999-tables.js';
const alteration: AlterationScript = {
up: async (pool) => {
await pool.query(sql`
create table saml_application_sessions (
tenant_id varchar(21) not null
references tenants (id) on update cascade on delete cascade,
id varchar(32) not null,
application_id varchar(21) not null
references applications (id) on update cascade on delete cascade,
2024-12-25 23:22:17 -05:00
saml_request_id varchar(128) not null,
2024-12-12 04:41:17 -05:00
oidc_state varchar(32),
relay_state varchar(256),
2024-12-25 23:22:17 -05:00
raw_auth_request text not null,
2024-12-12 04:41:17 -05:00
created_at timestamptz not null default(now()),
expires_at timestamptz not null,
primary key (tenant_id, id),
constraint saml_application_sessions__application_type
check (check_application_type(application_id, 'SAML'))
);
`);
await applyTableRls(pool, 'saml_application_sessions');
},
down: async (pool) => {
await dropTableRls(pool, 'saml_application_sessions');
await pool.query(sql`
drop table if exists saml_application_sessions;
`);
},
};
export default alteration;