From 439ec927bce972da38547e9456919f731fdc22d3 Mon Sep 17 00:00:00 2001 From: Felix Wittmann Date: Sun, 21 May 2017 16:29:28 +0200 Subject: [PATCH] Update mysql.js For the following model the index for "testcolumn" is not created for the current master (due to a resulting conflict in l 249 mysql, because the unique property already exists in the table); This is avoided by the proposed change. /** * Define User Model * @param {Object} schema * @return {Object} **/ module.exports = function (schema) { const user = schema.define('user', { active : { type : schema.Number }, username : { type : schema.String, unique : true }, email : { type : schema.String, unique :true }, password : { type : schema.String}, note : { type : schema.Text }, testcolumn : { type : schema.Date, index:true } },{ // primaryKeys:["email"] // fails }); user.validatesPresenceOf('username', 'email', 'password'); // additional methods and validation here return user; }; --- lib/adapters/mysql.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/adapters/mysql.js b/lib/adapters/mysql.js index e9fbaa3..b8752a2 100644 --- a/lib/adapters/mysql.js +++ b/lib/adapters/mysql.js @@ -775,9 +775,6 @@ MySQL.prototype.propertySettingsSQL = function (model, prop) { if (typeof p['default'] !== 'undefined' && acceptedDefaults(p) && typeof p['default'] !== 'function') { field.push('DEFAULT ' + getDefaultValue(p)); } - if (p.unique === true) { - field.push('UNIQUE'); - } return field.join(" "); };