From 86f4477ae14abcf5aea9a3a69103ae65f7eaf851 Mon Sep 17 00:00:00 2001 From: Silvan Date: Thu, 27 Apr 2023 10:28:26 +0200 Subject: [PATCH] fix(step10): separate executions (#5754) * feat: allow skip of success page for native apps (#5627) add possibility to return to callback directly after login without rendering the successful login page * build next * fix(console): disallow inline fonts, critical styles (#5714) fix: disallow inline * fix(setup): step 10 for postgres (#5717) * fix(setup): smaller transactions (#5743) * fix(step10): split statements * fix(step10): split into separate execs * chore: prerelease * add truncate before insert * fix: add truncate * Merge branch 'main' into optimise-step-10 * chore: reset release definition --------- Co-authored-by: Livio Spring Co-authored-by: Max Peintner --- .releaserc.js | 1 - cmd/setup/10.go | 20 +++++++++++++++++--- cmd/setup/10_create_temp_table.sql | 6 ++++++ cmd/setup/{10.sql => 10_fill_table.sql} | 9 +-------- cmd/setup/10_update.sql | 1 + 5 files changed, 25 insertions(+), 12 deletions(-) create mode 100644 cmd/setup/10_create_temp_table.sql rename cmd/setup/{10.sql => 10_fill_table.sql} (58%) create mode 100644 cmd/setup/10_update.sql diff --git a/.releaserc.js b/.releaserc.js index 177956a628..b8d5a8551a 100644 --- a/.releaserc.js +++ b/.releaserc.js @@ -1,7 +1,6 @@ module.exports = { branches: [ {name: 'main', channel: 'next'}, - {name: '1.87.x', range: '1.87.x', channel: '1.87.x'}, {name: 'next', prerelease: true} ], plugins: [ diff --git a/cmd/setup/10.go b/cmd/setup/10.go index 4efccc6537..fd8683f49d 100644 --- a/cmd/setup/10.go +++ b/cmd/setup/10.go @@ -13,8 +13,12 @@ import ( ) var ( - //go:embed 10.sql - correctCreationDate10 string + //go:embed 10_create_temp_table.sql + correctCreationDate10CreateTable string + //go:embed 10_fill_table.sql + correctCreationDate10FillTable string + //go:embed 10_update.sql + correctCreationDate10Update string ) type CorrectCreationDate struct { @@ -34,7 +38,17 @@ func (mig *CorrectCreationDate) Execute(ctx context.Context) (err error) { return err } } - res, err := tx.ExecContext(ctx, correctCreationDate10) + _, err := tx.ExecContext(ctx, correctCreationDate10CreateTable) + if err != nil { + return err + } + + _, err = tx.ExecContext(ctx, correctCreationDate10FillTable) + if err != nil { + return err + } + + res, err := tx.ExecContext(ctx, correctCreationDate10Update) if err != nil { return err } diff --git a/cmd/setup/10_create_temp_table.sql b/cmd/setup/10_create_temp_table.sql new file mode 100644 index 0000000000..fb823b2ecf --- /dev/null +++ b/cmd/setup/10_create_temp_table.sql @@ -0,0 +1,6 @@ +CREATE temporary TABLE IF NOT EXISTS wrong_events ( + instance_id TEXT + , event_sequence BIGINT + , current_cd TIMESTAMPTZ + , next_cd TIMESTAMPTZ +); diff --git a/cmd/setup/10.sql b/cmd/setup/10_fill_table.sql similarity index 58% rename from cmd/setup/10.sql rename to cmd/setup/10_fill_table.sql index 591d0b3d88..8c23687aff 100644 --- a/cmd/setup/10.sql +++ b/cmd/setup/10_fill_table.sql @@ -1,9 +1,4 @@ -CREATE temporary TABLE IF NOT EXISTS wrong_events ( - instance_id TEXT - , event_sequence BIGINT - , current_cd TIMESTAMPTZ - , next_cd TIMESTAMPTZ -); +TRUNCATE wrong_events; INSERT INTO wrong_events ( SELECT * FROM ( @@ -22,5 +17,3 @@ INSERT INTO wrong_events ( ORDER BY event_sequence DESC ); - -UPDATE eventstore.events e SET creation_date = we.next_cd FROM wrong_events we WHERE e.event_sequence = we.event_sequence and e.instance_id = we.instance_id; \ No newline at end of file diff --git a/cmd/setup/10_update.sql b/cmd/setup/10_update.sql new file mode 100644 index 0000000000..5254ba8dda --- /dev/null +++ b/cmd/setup/10_update.sql @@ -0,0 +1 @@ +UPDATE eventstore.events e SET creation_date = we.next_cd FROM wrong_events we WHERE e.event_sequence = we.event_sequence and e.instance_id = we.instance_id;