mirror of
https://github.com/twentyhq/twenty.git
synced 2024-12-18 00:52:21 +03:00
e293abe332
* fix: memory issue with truncate command * fix: LINK doesn't have any default value * fix: Cannot convert LINK to column type. * fix: handle old column type and add a warn to fix them manually
37 lines
969 B
TypeScript
37 lines
969 B
TypeScript
import console from 'console';
|
|
|
|
import { connectionSource, performQuery } from './utils';
|
|
|
|
async function dropSchemasSequentially() {
|
|
try {
|
|
await connectionSource.initialize();
|
|
|
|
// Fetch all schemas
|
|
const schemas = await performQuery(
|
|
`
|
|
SELECT n.nspname AS "schema_name"
|
|
FROM pg_catalog.pg_namespace n
|
|
WHERE n.nspname !~ '^pg_' AND n.nspname <> 'information_schema'
|
|
`,
|
|
'Fetching schemas...',
|
|
);
|
|
|
|
// Iterate over each schema and drop it
|
|
// This is to avoid dropping all schemas at once, which would cause an out of shared memory error
|
|
for (const schema of schemas) {
|
|
await performQuery(
|
|
`
|
|
DROP SCHEMA IF EXISTS "${schema.schema_name}" CASCADE;
|
|
`,
|
|
`Dropping schema ${schema.schema_name}...`,
|
|
);
|
|
}
|
|
|
|
console.log('All schemas dropped successfully.');
|
|
} catch (err) {
|
|
console.error('Error during schema dropping:', err);
|
|
}
|
|
}
|
|
|
|
dropSchemasSequentially();
|