github / github/gh-ost

CHECK constraints being renamed to MySQL defaults

Open
#1,341 2 comments 3 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
13.6k
Forks
1.4k
Avg merge
2h 31m
Merged PRs (30d)
4

Description

gh-ost version: 1.1.6

We noticed when migrating tables with named `CHECK` constraints, they were renamed after the migration to the MySQL default names.

eg:
A `CHECK` constraint on a table `foo` named `my_check_constraint` is renamed to `foo_check_1` after a gh-ost migration of table `foo`.

I suspect this is because it looks like gh-ost is using a `CREATE TABLE ... LIKE` stmt referenced [here](https://github.com/github/gh-ost/blob/master/go/logic/applier.go#L223). `CREATE TABLE ... LIKE` will copy the CHECK constraints but generate their names. [[src]](https://dev.mysql.com/doc/refman/8.0/en/create-table-like.html)

> For CREATE TABLE ... LIKE, the destination table preserves CHECK constraints from the original table, except that all the constraint names are generated.

We'd like to keep these `CHECK` constraint names consistent if possible. Is this a feature that can be added in a future release or a welcomed PR?

Thanks for all of the great work on gh-ost!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.