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

Dropping and readding constraints generates schema diff #2594

Closed
CaptainStabs opened this issue Jan 11, 2022 · 1 comment
Closed

Dropping and readding constraints generates schema diff #2594

CaptainStabs opened this issue Jan 11, 2022 · 1 comment

Comments

@CaptainStabs
Copy link

  1. Dropped constraint
us_housing_prices> ALTER TABLE `sales` DROP CONSTRAINT extra_spaces_removed;
  1. Readded constraint (no changes to schema)

  2. Generated diff
    dolt diff --limit 5

Schema diff generated
image

Interestingly, dolthub showed no changes to the schema
image

@timsehn
Copy link
Sponsor Contributor

timsehn commented Aug 30, 2022

Can't repro:

mysql> create table t (pk int primary key, check (pk > 3));
Query OK, 0 rows affected (0.01 sec)

mysql> call dolt_add('t');
+--------+
| status |
+--------+
|      0 |
+--------+
1 row in set (0.00 sec)

mysql> call dolt_commit('-m', 'Added table');
+----------------------------------+
| hash                             |
+----------------------------------+
| ko6m98822gl80i5qnj7e92koq1t0nil9 |
+----------------------------------+
1 row in set (0.00 sec)

mysql> show create table t;
+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                                                  |
+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t     | CREATE TABLE `t` (
  `pk` int NOT NULL,
  PRIMARY KEY (`pk`),
  CONSTRAINT `chk_3quoua1t` CHECK ((`pk` > 3))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin |
+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> alter table t drop constraint chk_3quoua1t;
Query OK, 0 rows affected (0.00 sec)

mysql> select * from dolt_status;
+------------+--------+----------+
| table_name | staged | status   |
+------------+--------+----------+
| t          |      0 | modified |
+------------+--------+----------+
1 row in set (0.00 sec)

mysql> alter table t add constraint CHECK (`pk` > 3);
Query OK, 0 rows affected (0.00 sec)

mysql> select * from dolt_status;
Empty set (0.00 sec)

You have to make sure you named and defined the constraint exactly.

@timsehn timsehn closed this as completed Aug 30, 2022
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