github / gh-ost

GitHub's Online Schema-migration Tool for MySQL
MIT License
12.11k stars 1.23k forks source link

[parser] support create-table flag #1383

Open najisawas opened 4 months ago

najisawas commented 4 months ago

Description

This PR adds a new flag called "--create-table", an alternative to the "--alter" flag. With "--create-table" you can redefine the table that you want gh-ost to migrate to, effectively supporting what would have required multiple ALTERs.

For example, If you need to restructure the secondary indexes on a MySQL table, you would need to do the following:

Assuming a and b are already columns in the table...

Now you can simply provide a "--create-table" flag like so

--create-table="( ..., x INT, y VARCHAR(24), ... KEY a_x_idx (a,x), KEY y_idx (y) ...)"

The PR is a bit large as it includes some refactors to maintain code cleanliness. I can separate out some of the refactors into separate PRs for ease of review

najisawas commented 4 months ago

1384

najisawas commented 4 months ago

tests still need to be expanded, but wanted to publish an initial revision for visibility