zitadel/cmd/setup/11.sql

15 lines
440 B
MySQL
Raw Permalink Normal View History

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 11:14:42 +02:00
BEGIN;
-- backfill created_at
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 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;