Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagesql
DO
$$
DECLARE delete_before DATE := '2000-12-31';
BEGIN
DELETE FROM "Contexts" WHERE "ContextType" = 'ElementContext' AND "FlowContextId" IN (SELECT "Id" FROM "Contexts" WHERE "FlowContextIdContextType" IS= NULL'FlowContext' AND "CreateTime" < delete_before);
DELETE FROM "ContextIndices" WHERE "FlowContextId" IN (SELECT "Id" FROM "Contexts" WHERE "FlowContextIdContextType" IS= NULL'FlowContext' AND "CreateTime" < delete_before);
DELETE FROM "ContextLogs" WHERE "FlowContextId" IN (SELECT "Id" FROM "Contexts" WHERE "FlowContextIdContextType" IS= NULL'FlowContext' AND "CreateTime" < delete_before);
DELETE FROM "Contexts" WHERE "FlowContextIdContextType" IS= NULL'FlowContext' AND "CreateTime" < delete_before;
DELETE FROM "PerformanceRecords" WHERE "Time" < delete_before;
END
$$;

REINDEX TABLE "Contexts";
REINDEX TABLE "ContextIndices";
REINDEX TABLE "ContextLogs";
REINDEX TABLE "PerformanceRecords";

...