mirror of
https://github.com/logto-io/logto.git
synced 2025-02-24 22:05:56 -05:00
29 lines
796 B
TypeScript
29 lines
796 B
TypeScript
|
import { sql } from '@silverhand/slonik';
|
||
|
|
||
|
import type { AlterationScript } from '../lib/types/alteration.js';
|
||
|
|
||
|
const alteration: AlterationScript = {
|
||
|
up: async (pool) => {
|
||
|
await pool.query(sql`
|
||
|
alter table applications drop constraint check_saml_app_third_party_consistency;
|
||
|
`);
|
||
|
await pool.query(sql`
|
||
|
update applications set is_third_party = false
|
||
|
where type = 'SAML';
|
||
|
`);
|
||
|
},
|
||
|
down: async (pool) => {
|
||
|
await pool.query(sql`
|
||
|
update applications set is_third_party = true
|
||
|
where type = 'SAML';
|
||
|
`);
|
||
|
await pool.query(sql`
|
||
|
alter table applications
|
||
|
add constraint check_saml_app_third_party_consistency
|
||
|
check (type != 'SAML' OR (type = 'SAML' AND is_third_party = true));
|
||
|
`);
|
||
|
},
|
||
|
};
|
||
|
|
||
|
export default alteration;
|