diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d10691d..53ad5948 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ All notable changes to this project will be documented in this file. ### Added - Warning with Sequelize v4 +### Changed +- Skeletons are now ES6 based [#482](https://github.com/sequelize/cli/issues/482) + ## v3.0.0-0 - 8th, Sep 2017 ### Removed diff --git a/src/assets/migrations/create-table.js b/src/assets/migrations/create-table.js index 112f202e..2980e7b9 100644 --- a/src/assets/migrations/create-table.js +++ b/src/assets/migrations/create-table.js @@ -1,7 +1,7 @@ 'use strict'; module.exports = { - up: function (queryInterface, Sequelize) { + up: (queryInterface, Sequelize) => { return queryInterface .createTable('<%= tableName %>', { id: { @@ -29,7 +29,7 @@ module.exports = { }); }, - down: function (queryInterface, Sequelize) { + down: (queryInterface, Sequelize) => { return queryInterface.dropTable('<%= tableName %>'); } }; diff --git a/src/assets/migrations/skeleton.js b/src/assets/migrations/skeleton.js index f9b590d9..9ef68be8 100644 --- a/src/assets/migrations/skeleton.js +++ b/src/assets/migrations/skeleton.js @@ -1,7 +1,7 @@ 'use strict'; module.exports = { - up: function (queryInterface, Sequelize) { + up: (queryInterface, Sequelize) => { /* Add altering commands here. Return a promise to correctly handle asynchronicity. @@ -11,7 +11,7 @@ module.exports = { */ }, - down: function (queryInterface, Sequelize) { + down: (queryInterface, Sequelize) => { /* Add reverting commands here. Return a promise to correctly handle asynchronicity. diff --git a/src/assets/models/index.js b/src/assets/models/index.js index d6042079..468ec408 100644 --- a/src/assets/models/index.js +++ b/src/assets/models/index.js @@ -16,15 +16,15 @@ if (config.use_env_variable) { fs .readdirSync(__dirname) - .filter(function(file) { + .filter(file => { return (file.indexOf('.') !== 0) && (file !== basename) && (file.slice(-3) === '.js'); }) - .forEach(function(file) { + .forEach(file => { var model = sequelize['import'](path.join(__dirname, file)); db[model.name] = model; }); -Object.keys(db).forEach(function(modelName) { +Object.keys(db).forEach(modelName => { if (db[modelName].associate) { db[modelName].associate(db); } diff --git a/src/assets/models/model.js b/src/assets/models/model.js index a9b4eee1..3ec4351f 100644 --- a/src/assets/models/model.js +++ b/src/assets/models/model.js @@ -1,6 +1,6 @@ 'use strict'; -module.exports = function(sequelize, DataTypes) { +module.exports = (sequelize, DataTypes) => { var <%= name %> = sequelize.define('<%= name %>', { <% Object.keys(attributes).forEach(function(fieldName, index) { %> <%= fieldName %>: DataTypes.<%= attributes[fieldName].toUpperCase() %> diff --git a/src/assets/seeders/skeleton.js b/src/assets/seeders/skeleton.js index 4033d4d2..e667a8b6 100644 --- a/src/assets/seeders/skeleton.js +++ b/src/assets/seeders/skeleton.js @@ -1,7 +1,7 @@ 'use strict'; module.exports = { - up: function (queryInterface, Sequelize) { + up: (queryInterface, Sequelize) => { /* Add altering commands here. Return a promise to correctly handle asynchronicity. @@ -14,7 +14,7 @@ module.exports = { */ }, - down: function (queryInterface, Sequelize) { + down: (queryInterface, Sequelize) => { /* Add reverting commands here. Return a promise to correctly handle asynchronicity. diff --git a/test/migration/create.test.js b/test/migration/create.test.js index eaec0df8..af6718ce 100644 --- a/test/migration/create.test.js +++ b/test/migration/create.test.js @@ -46,8 +46,8 @@ const gulp = require('gulp'); .src(Support.resolveSupportPath('tmp', 'migrations')) .pipe(helpers.readFile('*-' + migrationFile)) .pipe(helpers.expect(stdout => { - expect(stdout).to.contain('up: function (queryInterface, Sequelize) {'); - expect(stdout).to.contain('down: function (queryInterface, Sequelize) {'); + expect(stdout).to.contain('up: (queryInterface, Sequelize) => {'); + expect(stdout).to.contain('down: (queryInterface, Sequelize) => {'); })) .pipe(helpers.teardown(done)); }); diff --git a/test/seed/create.test.js b/test/seed/create.test.js index c168d8e0..a856705a 100644 --- a/test/seed/create.test.js +++ b/test/seed/create.test.js @@ -48,8 +48,8 @@ const gulp = require('gulp'); .src(Support.resolveSupportPath('tmp', 'seeders')) .pipe(helpers.readFile('*-' + seedFile)) .pipe(helpers.expect(stdout => { - expect(stdout).to.contain('up: function (queryInterface, Sequelize) {'); - expect(stdout).to.contain('down: function (queryInterface, Sequelize) {'); + expect(stdout).to.contain('up: (queryInterface, Sequelize) => {'); + expect(stdout).to.contain('down: (queryInterface, Sequelize) => {'); })) .pipe(helpers.teardown(done)); });