-
Notifications
You must be signed in to change notification settings - Fork 892
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
SQLite adapter drops table on changeColumn if there's a foreign key #922
Comments
Can you run the migration with |
The exception itself is thrown when Looks like SqliteAdapter::changeColumn does some table juggling: it renames the table to tmp_tablename, creates a new table using the old table definition plus the new column, copies the data from the temp table to the new one, and then drops the temp table. Not sure where it's going wrong because it's tough to follow but my guess is that the preg_replace transformation on the table definition SQL breaks if there's a foreign key statement in there. The new table is never created, the data is never copied, but the temp table is dropped, leaving us with neither new table nor temp table. Dunno why the failed table creation doesn't throw an exception. |
Thanks for that analysis. Definitely the regex. It is removing a Just need to make sure all tests still pass and any other instances of this issue. |
Awesome, thank you! Does phinx have a donation page? |
I don't think so. But instead of a donation to us, maybe a donation to a https://www.codeclubworld.org/ |
Hi @bkanber you can contribute to the Phinx project at the bottom of https://phinx.org/ Cheers! Rob |
@robmorgan Ha! Didn't see that. |
@rquadling ;) |
I get the following error when running a
changeColumn
command with the SQLite adapter:Cannot update a table that doesn't exist!
After digging in, I've found that the error only occurs if the table has a foreign key, but that it occurs consistently with a FK.
Test case:
The text was updated successfully, but these errors were encountered: