From c99c6a411c3a8a077a0ef244ab92183b7ab3dc02 Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Thu, 10 Sep 2020 13:11:12 +1000 Subject: [PATCH] add procedures to convert prod/sby routes to text from varchar --- .../01-migrations.sql | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/services/api-db/docker-entrypoint-initdb.d/01-migrations.sql b/services/api-db/docker-entrypoint-initdb.d/01-migrations.sql index 6b6e8b051d..4b9d9a8219 100644 --- a/services/api-db/docker-entrypoint-initdb.d/01-migrations.sql +++ b/services/api-db/docker-entrypoint-initdb.d/01-migrations.sql @@ -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 @@ -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;