Skip to content
This repository was archived by the owner on Sep 17, 2024. It is now read-only.
This repository was 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

Description

@lizhiyou88

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions