diff --git a/src/db/migration/V20200131_1855__mantis18164.sql b/src/db/migration/V20200131_1855__mantis18164.sql new file mode 100644 index 000000000..d4dea9afc --- /dev/null +++ b/src/db/migration/V20200131_1855__mantis18164.sql @@ -0,0 +1,29 @@ +DECLARE + itemExists NUMBER; +BEGIN + itemExists := 0; + + SELECT COUNT(CONSTRAINT_NAME) INTO itemExists + FROM ALL_CONSTRAINTS + WHERE UPPER(CONSTRAINT_NAME) = UPPER('UNIQUE_CODANTT'); + + IF itemExists > 0 THEN + BEGIN + EXECUTE IMMEDIATE 'ALTER TABLE PARADA DROP CONSTRAINT UNIQUE_CODANTT'; + EXECUTE IMMEDIATE 'DROP INDEX UNIQUE_CODANTT;'; + exception when others THEN null; + END; + END IF; +END; +/ +DECLARE + object_exists exception; + except_01408 exception; + pragma exception_init (object_exists , -00955); + pragma exception_init (except_01408 , -01408); +BEGIN + execute IMMEDIATE 'CREATE UNIQUE INDEX UNIQUE_CODANTT ON PARADA (CASE WHEN ACTIVO = 1 THEN CODANTT ELSE NULL END)'; + exception + when object_exists THEN null; + when except_01408 THEN null; +END; \ No newline at end of file