Skip to content

Commit

Permalink
Merge pull request #1528 from eiffel777/95-upgrade-host-key-collision
Browse files Browse the repository at this point in the history
Update host dimension migration sql to avoid primary key duplicate during migration
  • Loading branch information
eiffel777 authored Apr 28, 2021
2 parents 0f8d1b7 + e9f5d05 commit abf723c
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ LOCK TABLES
ALTER TABLE modw_cloud.host MODIFY host_id INT NOT NULL;
ALTER TABLE modw_cloud.host DROP INDEX autoincrement_key;
ALTER TABLE modw_cloud.host ADD COLUMN new_host_id INT(11) UNSIGNED NOT NULL auto_increment unique;
ALTER TABLE modw_cloud.event DROP PRIMARY KEY;
CREATE INDEX host_resource_idx ON modw_cloud.event (host_id, resource_id);
CREATE INDEX host_resource_idx ON modw_cloud.host (host_id, resource_id);

UPDATE
Expand All @@ -20,6 +22,8 @@ SET

ALTER TABLE modw_cloud.host DROP COLUMN host_id;
ALTER TABLE modw_cloud.host CHANGE new_host_id host_id INT(11) UNSIGNED;
ALTER TABLE modw_cloud.event ADD PRIMARY KEY(resource_id, instance_id, event_time_ts, event_type_id, host_id);
DROP INDEX host_resource_idx ON modw_cloud.host;
DROP INDEX host_resource_idx ON modw_cloud.event;

UNLOCK TABLES;

0 comments on commit abf723c

Please sign in to comment.