0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00
logto/packages/schemas/alterations/next-1712912361-delete-jwt-customier-with-empty-script.ts
simeng-li 559331d51e
refactor(core,schemas): make the jwt customizer script field mandatory (#5696)
* refactor(core,schemas): make the jwt customizer script field mandatory

make the jwt customizer script field mandatory

* fix(schemas): fix the alteration script

fix the alteration script

* fix(schemas): fix ut

fix ut
2024-04-15 10:38:30 +08:00

23 lines
754 B
TypeScript

import { sql } from '@silverhand/slonik';
import type { AlterationScript } from '../lib/types/alteration.js';
const alteration: AlterationScript = {
// We are making the jwt-customizer script field mandatory
// Delete the records in logto_configs where key is jwt.accessToken or jwt.clientCredentials and value jsonb's script field is undefined
up: async (pool) => {
await pool.query(
sql`
delete from logto_configs
where key in ('jwt.accessToken', 'jwt.clientCredentials')
and value->>'script' is null
`
);
},
down: async () => {
// No down script available, this is a non-reversible operation
// It is fine since we have not released this feature yet
},
};
export default alteration;