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 dropColumn doesn't work for last column #544
Comments
I looked into adding a test (there isn't one for dropColumn or renameColumn), but all of the sqlite3 tests just verify the SchemaBuilder sql output. The dropColumn function opens a transaction and copies data to a different table, which explains why there isn't currently a test for it. I'm unsure how to write a test for a function like that. |
Replacing if (createTable.sql.indexOf(a) === -1) {
throw new Error('Unable to find the column to change');
} With the following snippt fix it. if (createTable.sql.indexOf(a) === -1) {
var a1 = a.substring(0, a.length - 2);
if(createTable.sql.indexOf(a1) === -1) {
throw new Error('Unable to find the column to change');
} else {
a = ', ' + a1;
}
} |
Thanks @mabuzer. I'll look at getting tests against this behavior. |
I just stumbled on this one too. Fortunately, it only affects rolling back my migrations, which hopefully I won't have to do for a while. Can I help? |
A tested PR is very welcome |
The logic for dropping a column prevents the last column in a table from being dropped.
The comma after the column definition prevents it from matching the last column.
Here is a link to the code with the above snippet: https://github.com/tgriesser/knex/blob/master/lib/dialects/sqlite3/schema/ddl.js#L150
The text was updated successfully, but these errors were encountered: