Permalink
Browse files

Merge pull request #89 from sgibbons/master

Fix for postgres driver blindly recreating the migrations table
  • Loading branch information...
2 parents f1a8025 + 2dc4cfd commit 545b706a593df135add63a0632acc2959280e6e1 @kunklejr kunklejr committed Apr 18, 2013
Showing with 11 additions and 1 deletion.
  1. +11 −1 lib/driver/pg.js
View
@@ -62,7 +62,17 @@ var PgDriver = Base.extend({
}
}
- this.createTable('migrations', options, callback);
+ this.runSql("SELECT table_name FROM information_schema.tables WHERE table_schema = 'public' AND table_name = 'migrations'", function(err, result) {
+ if(err) {
+ return callback(err);
+ }
+
+ if (result.rows && result.rows.length < 1) {
+ this.createTable('migrations', options, callback);
+ } else {
+ callback();
+ }
+ });
}.bind(this));
},

0 comments on commit 545b706

Please sign in to comment.