Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Mysqldiff error: when the associated query primary key index is established on multiple columns, the diff result is wrong #53

Open
lizhiyou88 opened this issue Apr 25, 2022 · 0 comments

Comments

@lizhiyou88
Copy link

table structure in server1:
CREATE TABLE t1 (
a int NOT NULL,
b char(10) NOT NULL,
c varchar(100) DEFAULT '',
PRIMARY KEY (a,b),
KEY idx_a_b (a,b)
)

table structure in server2:
CREATE TABLE t1 (
a int(11) NOT NULL AUTO_INCREMENT,
b char(10) DEFAULT NULL COMMENT '保证金',
c varchar(100) NOT NULL DEFAULT '',
d datetime DEFAULT NULL,
e datetime DEFAULT NULL,
PRIMARY KEY (a),
KEY idx_b_c (b,c)
)

--changes-for=server1 result :
ALTER TABLE test.t1
DROP PRIMARY KEY,
DROP PRIMARY KEY,
DROP INDEX idx_a_b,
ADD PRIMARY KEY(a),
ADD INDEX idx_b_c (b,c),
CHANGE COLUMN a a int(11) NOT NULL AUTO_INCREMENT,
ADD COLUMN e datetime NULL,
ADD COLUMN d datetime NULL AFTER c,
CHANGE COLUMN c c varchar(100) NOT NULL DEFAULT '',
CHANGE COLUMN b b char(10) NULL COMMENT '保证金',
AUTO_INCREMENT=3, COLLATE=utf8_general_ci;

If it is a federated primary key, "drop primary key" will generate multiple primary keys

image

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

No branches or pull requests

1 participant