Skip to content

Commit

Permalink
Merge pull request #2194 from shreddedbacon/as-column-migrations
Browse files Browse the repository at this point in the history
Add procedures to change prod and standby route column types
  • Loading branch information
Schnitzel authored Sep 14, 2020
2 parents ef00242 + c99c6a4 commit 5045fc5
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions services/api-db/docker-entrypoint-initdb.d/01-migrations.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1186,6 +1186,46 @@ CREATE OR REPLACE PROCEDURE
END;
$$

CREATE OR REPLACE PROCEDURE
convert_project_production_routes_to_text()

BEGIN
DECLARE column_type varchar(50);

SELECT DATA_TYPE INTO column_type
FROM INFORMATION_SCHEMA.COLUMNS
WHERE
table_name = 'project'
AND table_schema = 'infrastructure'
AND column_name = 'production_routes';

IF (column_type = 'varchar') THEN
ALTER TABLE project
MODIFY production_routes text;
END IF;
END;
$$

CREATE OR REPLACE PROCEDURE
convert_project_standby_routes_to_text()

BEGIN
DECLARE column_type varchar(50);

SELECT DATA_TYPE INTO column_type
FROM INFORMATION_SCHEMA.COLUMNS
WHERE
table_name = 'project'
AND table_schema = 'infrastructure'
AND column_name = 'standby_routes';

IF (column_type = 'varchar') THEN
ALTER TABLE project
MODIFY standby_routes text;
END IF;
END;
$$

DELIMITER ;

-- If adding new procedures, add them to the bottom of this list
Expand Down Expand Up @@ -1242,6 +1282,8 @@ CALL add_facts_ui_to_project();
CALL add_metadata_to_project();
CALL add_min_max_to_billing_modifier();
CALL add_content_type_to_project_notification();
CALL convert_project_production_routes_to_text();
CALL convert_project_standby_routes_to_text();

-- Drop legacy SSH key procedures
DROP PROCEDURE IF EXISTS CreateProjectSshKey;
Expand Down

0 comments on commit 5045fc5

Please sign in to comment.