Skip to content

Commit

Permalink
Fix SQLite dropColumn doesn't work for last column (fixes #544)
Browse files Browse the repository at this point in the history
  • Loading branch information
djmadcat authored and tgriesser committed Feb 25, 2015
1 parent bebbb1a commit 18072c0
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/dialects/sqlite3/schema/ddl.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,18 @@ SQLite3_DDL.prototype.dropColumn = Promise.method(function(column) {
.then(this.getTableSql)
.then(function(sql) {
var createTable = sql[0];
var a = this.formatter.wrap(column) + ' ' + currentCol.type + ', ';
if (createTable.sql.indexOf(a) === -1) {
var a;
var a0 = this.formatter.wrap(column) + ' ' + currentCol.type;
var al = a0 + ', ';
if (createTable.sql.indexOf(al) !== -1) {
a = al;
} else {
var af = ', ' + a0;
if (createTable.sql.indexOf(af) !== -1) {
a = af;
}
}
if (!a) {
throw new Error('Unable to find the column to change');
}
return Promise.bind(this)
Expand Down

0 comments on commit 18072c0

Please sign in to comment.