1

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!

mengmeng
  • 1,266
  • 2
  • 22
  • 46
  • And what's the actual problem ? What error do you get ? As far as I remember, FLyaway is calculating checksums for the migration scrips and does not allow you to modify them after they have been applied. – Svetlin Zarev Jun 18 '20 at 18:56
  • @SvetlinZarev ok I just realized my problem. It's because of the sequence and wrong data has been added :( I thought there's something wrong with how I renamed the files or how I used it. Thank you, Sventlin, for taking time to help and read my question :) – mengmeng Jun 19 '20 at 07:42

0 Answers0