Rocket DevOps (formerly Aldon)

 View Only

 Change to CONSTRAINTS in SQL Table NOT working

robert damery's profile image
robert damery posted 02-26-2024 11:15

Running Rel 10.2        Rocket DevOps core for IBM i

I have a new table I am building that has a Foreign Key Constraint. I use CREATE OR REPLACE TABLE with an ALTER TABLE in the source file.

I promoted the object to my QUA and tested it and realized I want to change the constraint, so I checked it out.

made a field name change as well as change to the ALTER TABLE script to use the NEW Foreign Key...however when I promoted it it instead tried to apply the old constraint and did NOT apply the changes I made to the source.

Error from promote:

CMS2045 20  Recreate of constraint FK_SWRCQ_SWRCN_SWRCNID in library OPCAT259 failed.  The SQL code generated from
            the object follows:                                                                                   

ALTER TABLE          SWRCQ                      
  ADD CONSTRAINT          FK_SWRCQ_SWRCN_SWRCNID
  FOREIGN KEY( SWRCNID )                        
  REFERENCES          SWRCN ( SWRCNID )         
  ON DELETE CASCADE                             
  ON UPDATE RESTRICT ;                          

CMS4203 20  Recreate of constraint FK_SWRCQ_SWRCN_SWRCNID failed due to changes in object SWRCQ type *TABLE.
            constraint FK_SWRCQ_SWRCN_SWRCNID must be corrected and recreated in environment QUA.           
CMS4238  0  Object SWRCQ type *TABLE successfully promoted to environment QUA.                              

New script in the source for the CREATE OR REPLACE TABLE

ALTER TABLE SWRCQ                     
 ADD CONSTRAINT FK_SWRCQ_SWRCA_SWRCAID
 FOREIGN KEY( SWRCAID )               
 REFERENCES SWRCA ( SWRCAID )         
 ON DELETE CASCADE                    
 ON UPDATE RESTRICT ;                 

Do I need separate source for constraints or any ALTER TABLE scripts?

seems the CMS is trying to use the old object and its constraints as part of the recreation of the table.

We also find this when we change Unique and Primary Keys.

Any one have an Idea of how this CMS needs to be set up to properly handle these changes?

Dale Asher's profile image
ROCKETEER Dale Asher

Robert, our use of 'create like existing' may step on constraint changes as you're indicating. 

We do have recommendations and should probably work thru them in a support case...