mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 03:24:26 +00:00
fix: smaller outage on events migration first part (#2287)
This commit is contained in:
parent
31a91a0039
commit
f9203940fb
@ -44,10 +44,11 @@ func StartQueries(ctx context.Context, es *eventstore.Eventstore, projections pr
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = projection.Start(ctx, es, projections)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// turned off for this release
|
||||
// err = projection.Start(ctx, es, projections)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
|
||||
return repo, nil
|
||||
}
|
||||
|
@ -1,40 +0,0 @@
|
||||
BEGIN;
|
||||
|
||||
ALTER TABLE eventstore.events
|
||||
RENAME COLUMN previous_sequence TO previous_aggregate_sequence,
|
||||
ADD COLUMN previous_aggregate_type_sequence INT8,
|
||||
ADD CONSTRAINT prev_agg_type_seq_unique UNIQUE(previous_aggregate_type_sequence);
|
||||
|
||||
COMMIT;
|
||||
|
||||
SET CLUSTER SETTING kv.closed_timestamp.target_duration = '2m';
|
||||
|
||||
BEGIN;
|
||||
WITH data AS (
|
||||
SELECT
|
||||
event_sequence,
|
||||
LAG(event_sequence)
|
||||
OVER (
|
||||
PARTITION BY aggregate_type
|
||||
ORDER BY event_sequence
|
||||
) as prev_seq,
|
||||
aggregate_type
|
||||
FROM eventstore.events
|
||||
ORDER BY event_sequence
|
||||
) UPDATE eventstore.events
|
||||
SET previous_aggregate_type_sequence = data.prev_seq
|
||||
FROM data
|
||||
WHERE data.event_sequence = events.event_sequence;
|
||||
COMMIT;
|
||||
|
||||
SET CLUSTER SETTING kv.closed_timestamp.target_duration TO DEFAULT;
|
||||
|
||||
-- validation by hand:
|
||||
-- SELECT
|
||||
-- event_sequence,
|
||||
-- previous_aggregate_sequence,
|
||||
-- previous_aggregate_type_sequence,
|
||||
-- aggregate_type,
|
||||
-- aggregate_id,
|
||||
-- event_type
|
||||
-- FROM eventstore.events ORDER BY event_sequence;
|
@ -1 +0,0 @@
|
||||
CREATE INDEX agg_type ON eventstore.events (aggregate_type);
|
8
migrations/cockroach/V1.66__events_cols.sql
Normal file
8
migrations/cockroach/V1.66__events_cols.sql
Normal file
@ -0,0 +1,8 @@
|
||||
BEGIN;
|
||||
|
||||
ALTER TABLE eventstore.events
|
||||
RENAME COLUMN previous_sequence TO previous_aggregate_sequence,
|
||||
ADD COLUMN previous_aggregate_type_sequence INT8,
|
||||
ADD CONSTRAINT prev_agg_type_seq_unique UNIQUE(previous_aggregate_type_sequence);
|
||||
|
||||
COMMIT;
|
Loading…
Reference in New Issue
Block a user