Skip to content

MySQL: changeColumn errors out #127

tbjers opened this Issue Dec 5, 2013 · 1 comment

2 participants

tbjers commented Dec 5, 2013

When using MySQL the changeColumn() method errors out with the following error:

Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TYPE TEXT' at line 1

The query executed:

ALTER TABLE tablename ALTER COLUMN `columnname` TYPE TEXT;

This breaks in MySQL.

This is because the syntax of MySQL differs slightly from that of PostgreSQL in that it needs the statement to look as follows:

ALTER TABLE tablename ALTER COLUMN `columnname` `columnname` TEXT;

Alternatively, I think we should use modify instead:

ALTER TABLE tablename MODIFY `columnname` TEXT;

Since this involves the SQL generator I didn't want to bumble about in the code making changes and create a PR since I do not have the type of grasp of Model that you guys do. I think the right thing to do here is detect the driver for the specific table and then switch based on driver to generate the proper statement.

This stemmed from an attempt to change a column type in a migration for Geddy. Full information for this specific migration can be found here:

mde commented Dec 6, 2013

Fixed in 250ef36, pushed to NPM in v0.4.8. Thanks for catching this!

@mde mde closed this Dec 6, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.