Skip to content

Commit

Permalink
run GC in a separate query() call (allow to run it in its own transac…
Browse files Browse the repository at this point in the history
…tion)
  • Loading branch information
hotzevzl committed Sep 3, 2022
1 parent 04fc103 commit 4be3360
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,8 @@ export class AddIndexesForCascades16621283230000 implements MigrationInterface {
create index output_scenarios_features_data__scenario_features_data__idx on output_scenarios_features_data(scenario_features_id);
`);

// and index in the table we are about to reference via a new fk, for
// indexed resolution of cascades
await queryRunner.query(`
create index output_scenarios_pu_data__scenarios_pu_data__idx on output_scenarios_pu_data(scenario_pu_id);
`);

// add missing fk, running some garbage collection first
// Run some garbage collection to make sure we can create then create a
// fk.
await queryRunner.query(`
delete from
output_scenarios_pu_data
Expand All @@ -49,7 +44,10 @@ export class AddIndexesForCascades16621283230000 implements MigrationInterface {
id
from
scenarios_pu_data);
`);

// Add missing fk.
await queryRunner.query(`
alter table
output_scenarios_pu_data
add constraint
Expand All @@ -60,6 +58,12 @@ export class AddIndexesForCascades16621283230000 implements MigrationInterface {
on update cascade on delete cascade;
`);

// Add index to allow for indexed resolution of cascades on the new fk added
// just above.
await queryRunner.query(`
create index output_scenarios_pu_data__scenarios_pu_data__idx on output_scenarios_pu_data(scenario_pu_id);
`);

await queryRunner.query(`
alter table output_scenarios_features_data
rename constraint
Expand Down

2 comments on commit 4be3360

@vercel
Copy link

@vercel vercel bot commented on 4be3360 Sep 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

marxan-storybook – ./app

marxan-storybook.vercel.app
marxan-storybook-git-main-vizzuality1.vercel.app
marxan-storybook-vizzuality1.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 4be3360 Sep 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

marxan – ./app

marxan-production.vercel.app
marxan-git-main-vizzuality1.vercel.app
marxan-vizzuality1.vercel.app

Please sign in to comment.