0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-23 20:33:16 -05:00
logto/packages/schemas/alterations/1.0.0_rc.1-1676906977-remove-demo-app.ts
silverhand-bot cda2c821cd
release: version core packages (#3225)
Co-authored-by: Gao Sun <gao@silverhand.io>
2023-02-25 23:15:42 +08:00

50 lines
1.4 KiB
TypeScript

import { generateStandardId } from '@logto/core-kit';
import chalk from 'chalk';
import inquirer from 'inquirer';
import { sql } from 'slonik';
import type { AlterationScript } from '../lib/types/alteration.js';
const alteration: AlterationScript = {
up: async (pool) => {
const isCi = process.env.CI;
const { confirm } = await inquirer.prompt<{ confirm: boolean }>({
type: 'confirm',
name: 'confirm',
message: String(
chalk.bold(chalk.yellow('***CAUTION***')) +
'\n' +
'The application `demo-app` will be removed from your database.\n' +
'Usually this is harmless since the demo app will be still functional with predefined data.\n' +
'Are you sure to continue?'
),
default: false,
when: !isCi,
});
if (!isCi && !confirm) {
throw new Error('User cancelled alteration.');
}
await pool.query(sql`
delete from applications where id = 'demo-app';
`);
},
down: async (pool) => {
await pool.query(sql`
insert into applications
(tenant_id, id, secret, name, description, type, oidc_client_metadata)
values (
'default',
'demo-app',
${generateStandardId()},
'Demo App',
'Logto demo app.',
'SPA',
'{ "redirectUris": [], "postLogoutRedirectUris": [] }'::jsonb
);
`);
},
};
export default alteration;