Skip to content

Commit

Permalink
edit
Browse files Browse the repository at this point in the history
  • Loading branch information
Agnes Lin committed Dec 13, 2019
1 parent 3789475 commit 5c95421
Showing 1 changed file with 28 additions and 27 deletions.
55 changes: 28 additions & 27 deletions lib/migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,30 +321,30 @@ function mixinMigration(PostgreSQL) {
return result;
};

/** Create extension for uuid when attribute is set to dataType uuid
* and auto-generated.
* @param {String} model The model name
*
*/
PostgreSQL.prototype.checksExtention = function(model) {
const self = this;

Object.keys(self.getModelDefinition(model).properties).forEach(function(prop, model) {
let postgreType = prop;
if (prop.postgresql && prop.postgresql.dataType) {
postgreType = prop.postgresql.dataType.toUpperCase();
}

if (prop.generated && postgreType === 'UUID') {
self.execute('CREATE EXTENSION IF NOT EXISTS "uuid-ossp";',
(err, fields) => {
if (err) {
return cb(err);
};
});
}
});
}
// /** Create extension for uuid when attribute is set to dataType uuid
// * and auto-generated.
// * @param {String} model The model name
// *
// */
// PostgreSQL.prototype.checksExtention = function(model) {
// const self = this;

// Object.keys(self.getModelDefinition(model).properties).forEach(function(prop, model) {
// let postgreType = prop;
// if (prop.postgresql && prop.postgresql.dataType) {
// postgreType = prop.postgresql.dataType.toUpperCase();
// }

// if (prop.generated && postgreType === 'UUID') {
// self.execute('CREATE EXTENSION IF NOT EXISTS "uuid-ossp";',
// (err, fields) => {
// if (err) {
// return cb(err);
// };
// });
// }
// });
// }

/*!
* Create a table for the given model
Expand All @@ -354,12 +354,13 @@ function mixinMigration(PostgreSQL) {
PostgreSQL.prototype.createTable = function(model, cb) {
const self = this;
const name = self.tableEscaped(model);
self.checksExtention(model, (err)=>{
cb(err);
});
// self.checksExtention(model, (err)=>{
// cb(err);
// });

// Please note IF NOT EXISTS is introduced in postgresql v9.3
self.execute(
'CREATE EXTENSION IF NOT EXISTS "uuid-ossp";'+
'CREATE SCHEMA ' +
self.escapeName(self.schema(model)),
function(err) {
Expand Down

0 comments on commit 5c95421

Please sign in to comment.