Skip to content

Commit

Permalink
reapply with fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wzrdtales committed Jun 25, 2017
1 parent 9f749ed commit 01fa7fb
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ var Base = Class.extend({

var columnDefs = [];
var foreignKeys = [];
var extensions = '';
var tableOptions = '';

for (var columnName in columnSpecs) {
var columnSpec = columnSpecs[columnName];
Expand All @@ -207,8 +209,16 @@ var Base = Class.extend({
foreignKeys.push(constraint.foreignKey);
}

var sql = util.format('CREATE TABLE %s %s (%s%s)', ifNotExistsSql,
this.escapeDDL(tableName), columnDefs.join(', '), pkSql);
if(typeof(this._applyExtensions) === 'function') {
extensions = this._applyExtensions(options);
}

if(typeof(this._applyTableOptions) === 'function') {
tableOptions = this._applyTableOptions(options);
}

var sql = util.format('CREATE TABLE %s %s (%s%s%s) %s', ifNotExistsSql,
this.escapeDDL(tableName), columnDefs.join(', '), extensions, tableOptions, pkSql);

return this.runSql(sql)
.then(function()
Expand Down Expand Up @@ -246,8 +256,14 @@ var Base = Class.extend({

var def = this.createColumnDef(columnName,
this.normalizeColumnSpec(columnSpec), {}, tableName);
var sql = util.format('ALTER TABLE %s ADD COLUMN %s',
this.escapeDDL(tableName), def.constraints);
var extensions = '';

if(typeof(this._applyAddColumnExtension) === 'function') {
extensions = this._applyAddColumnExtension(def);
}

var sql = util.format('ALTER TABLE %s ADD COLUMN %s %s',
this.escapeDDL(tableName), def.constraints, extensions);

return this.runSql(sql)
.then(function()
Expand Down

0 comments on commit 01fa7fb

Please sign in to comment.