DaanHoogland commented on code in PR #7381:
URL: https://github.com/apache/cloudstack/pull/7381#discussion_r1152856955


##########
engine/schema/src/main/resources/META-INF/db/schema-41800to41810.sql:
##########
@@ -19,3 +19,12 @@
 -- Schema upgrade from 4.18.0.0 to 4.18.1.0
 --;
 
+DROP PROCEDURE IF EXISTS `cloud`.`IDEMPOTENT_ADD_FOREIGN_KEY`;
+CREATE PROCEDURE `cloud`.`IDEMPOTENT_ADD_FOREIGN_KEY` (
+    IN in_table_name VARCHAR(200),
+    IN in_table_column VARCHAR(200),
+    IN in_foreign_table_name VARCHAR(200),
+    IN in_foreign_column_name VARCHAR(200)
+)
+BEGIN
+    DECLARE CONTINUE HANDLER FOR 1005,1826 BEGIN END; SET @ddl = CONCAT('ALTER 
TABLE cloud.', in_table_name); SET @ddl = CONCAT(@ddl, ' ', ' ADD CONSTRAINT 
'); SET @ddl = CONCAT(@ddl, 'fk_', in_table_name, '__', in_foreign_table_name, 
'_', in_foreign_column_name); SET @ddl = CONCAT(@ddl, ' FOREIGN KEY (', 
in_table_column, ')'); SET @ddl = CONCAT(@ddl, ' REFERENCES ', 
in_foreign_table_name, '(', in_foreign_column_name, ')'); PREPARE stmt FROM 
@ddl; EXECUTE stmt; DEALLOCATE PREPARE stmt; END;

Review Comment:
   why do we need to recreate it? can“t we just use it as is?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to