mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 06:57:33 +00:00
fix(eventstore): backfill column
This commit is contained in:
@@ -1,5 +1,15 @@
|
|||||||
ALTER TABLE eventstore.events ADD COLUMN created_at TIMESTAMPTZ;
|
BEGIN;
|
||||||
|
-- create table with empty created_at
|
||||||
|
ALTER TABLE eventstore.events ADD COLUMN created_at TIMESTAMPTZ DEFAULT NULL;
|
||||||
|
COMMIT;
|
||||||
|
|
||||||
|
BEGIN;
|
||||||
|
-- backfill created_at
|
||||||
UPDATE eventstore.events SET created_at = creation_date WHERE created_at IS NULL;
|
UPDATE eventstore.events SET created_at = creation_date WHERE created_at IS NULL;
|
||||||
|
COMMIT;
|
||||||
|
|
||||||
ALTER TABLE eventstore.events ALTER COLUMN created_at SET NOT NULL DEFAULT clock_timestamp();
|
BEGIN;
|
||||||
|
-- set column rules
|
||||||
|
ALTER TABLE eventstore.events ALTER COLUMN created_at SET DEFAULT clock_timestamp();
|
||||||
|
ALTER TABLE eventstore.events ALTER COLUMN created_at SET NOT NULL;
|
||||||
|
COMMIT;
|
Reference in New Issue
Block a user