mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 04:37:31 +00:00
chore: move the go code into a subfolder
This commit is contained in:
1
apps/api/cmd/setup/10/10_count_wrong_events.sql
Normal file
1
apps/api/cmd/setup/10/10_count_wrong_events.sql
Normal file
@@ -0,0 +1 @@
|
||||
SELECT COUNT(*) FROM wrong_events
|
6
apps/api/cmd/setup/10/10_create_temp_table.sql
Normal file
6
apps/api/cmd/setup/10/10_create_temp_table.sql
Normal file
@@ -0,0 +1,6 @@
|
||||
CREATE TEMPORARY TABLE IF NOT EXISTS wrong_events (
|
||||
instance_id TEXT
|
||||
, event_sequence BIGINT
|
||||
, current_cd TIMESTAMPTZ
|
||||
, next_cd TIMESTAMPTZ
|
||||
);
|
1
apps/api/cmd/setup/10/10_empty_table.sql
Normal file
1
apps/api/cmd/setup/10/10_empty_table.sql
Normal file
@@ -0,0 +1 @@
|
||||
TRUNCATE wrong_events
|
19
apps/api/cmd/setup/10/10_fill_table.sql
Normal file
19
apps/api/cmd/setup/10/10_fill_table.sql
Normal file
@@ -0,0 +1,19 @@
|
||||
INSERT INTO wrong_events (
|
||||
SELECT * FROM (
|
||||
SELECT
|
||||
instance_id
|
||||
, event_sequence
|
||||
, creation_date AS current_cd
|
||||
, lead(creation_date) OVER (
|
||||
PARTITION BY instance_id
|
||||
ORDER BY event_sequence DESC
|
||||
) AS next_cd
|
||||
FROM
|
||||
eventstore.events
|
||||
WHERE
|
||||
"position" IS NULL
|
||||
) sub WHERE
|
||||
current_cd < next_cd
|
||||
ORDER BY
|
||||
event_sequence DESC
|
||||
);
|
10
apps/api/cmd/setup/10/10_update.sql
Normal file
10
apps/api/cmd/setup/10/10_update.sql
Normal file
@@ -0,0 +1,10 @@
|
||||
UPDATE
|
||||
eventstore.events e
|
||||
SET
|
||||
creation_date = we.next_cd
|
||||
, "position" = (EXTRACT(EPOCH FROM we.next_cd))
|
||||
FROM
|
||||
wrong_events we
|
||||
WHERE
|
||||
e.event_sequence = we.event_sequence
|
||||
AND e.instance_id = we.instance_id;
|
Reference in New Issue
Block a user