Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merging schema changes #773

Closed
Hydrocharged opened this issue Jun 27, 2020 · 1 comment
Closed

Merging schema changes #773

Hydrocharged opened this issue Jun 27, 2020 · 1 comment

Comments

@Hydrocharged
Copy link
Contributor

Hydrocharged commented Jun 27, 2020

Right now, dolt merge only seems to consider schema changes that deal with the addition or deletion of columns. Other schema changes are not brought across. This can be replicated by the following:

dolt init
dolt sql <<SQL
CREATE TABLE test (
  pk BIGINT PRIMARY KEY,
  v1 BIGINT,
  v2 BIGINT
);
INSERT INTO test VALUES (0, 0, 0), (1, 1, 1);
SQL
dolt add -A
dolt commit -m "initial commit"

dolt checkout -b other
dolt checkout master
dolt sql -q "INSERT INTO test VALUES (2, 2, 2)"
dolt add -A
dolt commit -m "added 2 to master"

dolt checkout other
dolt sql <<SQL
INSERT INTO test VALUES (3, 3, 3);
ALTER TABLE test RENAME COLUMN v1 to v1_new;
ALTER TABLE test CHANGE COLUMN v2 v2 BIGINT NOT NULL;
SQL
dolt add -A
dolt commit -m "added 3 to other and change schema"

dolt checkout master
dolt merge other
dolt commit -m "merged other into master"

master: dolt schema show

test @ working
CREATE TABLE `test` (
  `pk` BIGINT NOT NULL COMMENT 'tag:3228',
  `v1` BIGINT COMMENT 'tag:5758',
  `v2` BIGINT COMMENT 'tag:3384',
  PRIMARY KEY (`pk`)
);

other: dolt schema show

test @ working
CREATE TABLE `test` (
  `pk` BIGINT NOT NULL COMMENT 'tag:3228',
  `v1_new` BIGINT COMMENT 'tag:5758',
  `v2` BIGINT NOT NULL COMMENT 'tag:3384',
  PRIMARY KEY (`pk`)
);

This applies to both indexes and foreign keys as well. The number of tested schema changes was not exhaustive, thus there may be more or less in either direction.

@VinaiRachakonda
Copy link
Contributor

This now fixed with both tables using v1_new

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants