You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Execute the SQL commands below to migrate existing databases for uuid-api #115, rather than dump and reload each database.
-- Add the new column in the DDL modifications for https://github.com/hubmapconsortium/uuid-api/issues/115
ALTER TABLE `hm_uuid`.`files`
ADD `LAST_MODIFIED` timestamp NOT NULL DEFAULT now() ON UPDATE now()
;
-- Change column to align with the DDL modifications for https://github.com/hubmapconsortium/uuid-api/issues/115
ALTER TABLE `hm_uuid`.`uuids`
ALTER `TIME_GENERATED` SET DEFAULT (now())
;
-- Revise column values set during ALTER statement above to a reasonable value pulled from UUID.TIME_GENERATED.
-- 2,989,892 rows in 98 seconds on Dev
-- 2,989,805 rows in 98 seconds on Test
-- 2,991,145 rows in 98 seconds on Prod
UPDATE `hm_uuid`.`files`
SET
`LAST_MODIFIED` = (SELECT `TIME_GENERATED` FROM `hm_uuid`.`uuids` where `uuids`.`UUID`=`files`.`UUID`)
;
-- verify times on two tables are the same after UPDATE
SELECT u.TIME_GENERATED, f.LAST_MODIFIED
FROM `hm_uuid`.`uuids` AS u
INNER JOIN `hm_uuid`.`files` AS f ON u.`UUID`=f.`UUID`
WHERE u.`TIME_GENERATED` <> f.`LAST_MODIFIED`
;
-- verify no other outliers
SELECT *
FROM `hm_uuid`.`files` AS f
WHERE f.`LAST_MODIFIED` IS NULL OR f.`LAST_MODIFIED` > now() OR f.`LAST_MODIFIED` < (SELECT min(time_generated) FROM hm_uuid.uuids);
The text was updated successfully, but these errors were encountered:
kburke
changed the title
Perform one-time migration of Dev, Test, Stage, Prod database for file modification time
Perform one-time migration of Test, Stage, Prod database for file modification time
Jan 12, 2023
Execute the SQL commands below to migrate existing databases for uuid-api #115, rather than dump and reload each database.
The text was updated successfully, but these errors were encountered: