2023-05-11 11:14:42 +02:00
|
|
|
BEGIN;
|
|
|
|
-- create table with empty created_at
|
|
|
|
ALTER TABLE eventstore.events ADD COLUMN created_at TIMESTAMPTZ DEFAULT NULL;
|
|
|
|
COMMIT;
|
2023-05-11 10:31:33 +02:00
|
|
|
|
2023-05-11 11:14:42 +02:00
|
|
|
BEGIN;
|
|
|
|
-- backfill created_at
|
2023-05-11 10:31:33 +02:00
|
|
|
UPDATE eventstore.events SET created_at = creation_date WHERE created_at IS NULL;
|
2023-05-11 11:14:42 +02:00
|
|
|
COMMIT;
|
2023-05-11 10:31:33 +02:00
|
|
|
|
2023-05-11 11:14:42 +02:00
|
|
|
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;
|