mirror of
https://github.com/twentyhq/twenty.git
synced 2024-12-21 02:41:33 +03:00
ba69435339
* Display maxUpdatedAt for each workspace Schema * Factorize functions * Add max update for public workspaces * Merge everything in a single json * Enrich results * Get from proper table * Update * Move to proper command file * Add a dry-run option * Remove workspaces from database * Fix DeleteWorkspace method * Add new option * Remove proper data when deleting workspace * Minor improvements
33 lines
936 B
TypeScript
33 lines
936 B
TypeScript
import console from 'console';
|
|
|
|
import { connectionSource, performQuery } from './utils';
|
|
|
|
connectionSource
|
|
.initialize()
|
|
.then(async () => {
|
|
await performQuery(
|
|
`
|
|
CREATE OR REPLACE FUNCTION drop_all() RETURNS VOID AS $$
|
|
DECLARE schema_item RECORD;
|
|
BEGIN
|
|
FOR schema_item IN
|
|
SELECT subrequest."name" as schema_name
|
|
FROM (SELECT n.nspname AS "name"
|
|
FROM pg_catalog.pg_namespace n
|
|
WHERE n.nspname !~ '^pg_' AND n.nspname <> 'information_schema') as subrequest
|
|
LOOP
|
|
EXECUTE 'DROP SCHEMA ' || schema_item.schema_name || ' CASCADE';
|
|
END LOOP;
|
|
RETURN;
|
|
END;
|
|
$$ LANGUAGE plpgsql;
|
|
|
|
SELECT drop_all ();
|
|
`,
|
|
'Dropping all schemas...',
|
|
);
|
|
})
|
|
.catch((err) => {
|
|
console.error('Error during Data Source initialization:', err);
|
|
});
|