I'm not really sure what I've done wrong. But this caused the other services to mess up the other db migration stuff.
Hoping someone will help me with the cause.
Thank you!
We have a db migration script that creates a table
V6__add_subscription_tables.sql
CREATE TABLE plan_subscription (
id bigint NOT NULL,
version bigint NOT NULL,
team_id bigint NOT NULL,
plan_id bigint NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY (plan_id) REFERENCES plan (id),
UNIQUE (team_id)
);
Added another script that would add to dev environment a plan_subscription
But in my current task, the migration will fail if it's a fresh database so I deleted the insertion
V5002__add_test_data.sql
//There are other test data here
/* THIS IS THE DATA THAT I DELETED
INSERT INTO plan_subscription VALUES (nextval('plan_subscription_sequence'), 0, 3, currval('plan_sequence'));
*/
And since I have to alter the table and add a column with constraint, I moved the adding of test data in the new db migration script but. There seems to be no error but it messed up something that I'm not sure what's the cause.
V5004__add_date_occurred_in_plan_subscription.sql
ALTER TABLE plan_subscription ADD
date_occurred TIMESTAMP WITHOUT TIME ZONE NOT NULL;
INSERT INTO plan_subscription VALUES (nextval('plan_subscription_sequence'), 0, 3, currval('plan_sequence'), current_date);
So what I did, I just removed the NOT NULL
constraint and reverted the deletion of the old test data.
I know this is kinda long and weird but I'm hoping someone would know the reason.
Thank you!