uat-seed-script
This commit is contained in:
@@ -42,11 +42,21 @@ function loadLocalEnv() {
|
||||
loadEnvFile(path.resolve(process.cwd(), '.env'));
|
||||
}
|
||||
|
||||
const ALLOW_DB_RESET_FLAG = '--allow-db-reset';
|
||||
|
||||
function assertSafeToReset(databaseUrl: string) {
|
||||
if (process.env.ALLOW_DB_RESET !== 'true') {
|
||||
throw new Error('ALLOW_DB_RESET=true is required.');
|
||||
const allowDbReset =
|
||||
process.env.ALLOW_DB_RESET === 'true' ||
|
||||
process.argv.includes(ALLOW_DB_RESET_FLAG);
|
||||
|
||||
if (!allowDbReset) {
|
||||
throw new Error(
|
||||
`Database reset requires explicit confirmation. Run "npm run db:reset -- ${ALLOW_DB_RESET_FLAG}".`
|
||||
);
|
||||
}
|
||||
|
||||
process.env.ALLOW_DB_RESET = 'true';
|
||||
|
||||
if ((process.env.NODE_ENV ?? '').toLowerCase() === 'production') {
|
||||
throw new Error('Database reset is blocked in NODE_ENV=production.');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user