graphql-engine/server/src-rsr/migrations/11_to_12.sql
Ajeet D'Souza a66fb42ce2 Make catalog metadata migrations work on all schema versions (fix #2826) (#2379)
* Separate DB and metadata migrations
* Refactor Migrate.hs to generate list of migrations at compile-time
* Replace ginger with shakespeare to improve performance
* Improve migration log messages
2019-10-11 00:13:57 -05:00

29 lines
986 B
SQL

ALTER TABLE hdb_catalog.event_triggers
DROP CONSTRAINT event_triggers_pkey;
ALTER TABLE hdb_catalog.event_triggers
DROP CONSTRAINT event_triggers_name_key;
ALTER TABLE hdb_catalog.event_triggers
ADD PRIMARY KEY (name);
ALTER TABLE hdb_catalog.event_triggers
DROP COLUMN id;
ALTER TABLE hdb_catalog.event_log
DROP COLUMN trigger_id;
CREATE INDEX ON hdb_catalog.event_log (trigger_name);
UPDATE hdb_catalog.hdb_relationship
SET rel_def = '{"manual_configuration":{"remote_table":{"schema":"hdb_catalog","name":"event_log"},"column_mapping":{"name":"trigger_name"}}}'
WHERE table_schema = 'hdb_catalog'
AND table_name = 'event_triggers'
AND rel_name = 'events';
UPDATE hdb_catalog.hdb_relationship
SET rel_def = '{"manual_configuration":{"remote_table":{"schema":"hdb_catalog","name":"event_triggers"},"column_mapping":{"trigger_name":"name"}}}'
WHERE table_schema = 'hdb_catalog'
AND table_name = 'event_log'
AND rel_name = 'trigger';