Skip to content

Commit

Permalink
fix: update skeletons to use es6, closes #482
Browse files Browse the repository at this point in the history
  • Loading branch information
sushantdhiman committed Sep 9, 2017
1 parent c70231e commit 733ced9
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 14 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/assets/migrations/create-table.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

module.exports = {
up: function (queryInterface, Sequelize) {
up: (queryInterface, Sequelize) => {
return queryInterface
.createTable('<%= tableName %>', {
id: {
Expand Down Expand Up @@ -29,7 +29,7 @@ module.exports = {
});
},

down: function (queryInterface, Sequelize) {
down: (queryInterface, Sequelize) => {
return queryInterface.dropTable('<%= tableName %>');
}
};
4 changes: 2 additions & 2 deletions src/assets/migrations/skeleton.js
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -11,7 +11,7 @@ module.exports = {
*/
},

down: function (queryInterface, Sequelize) {
down: (queryInterface, Sequelize) => {
/*
Add reverting commands here.
Return a promise to correctly handle asynchronicity.
Expand Down
6 changes: 3 additions & 3 deletions src/assets/models/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/assets/models/model.js
Original file line number Diff line number Diff line change
@@ -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() %>
Expand Down
4 changes: 2 additions & 2 deletions src/assets/seeders/skeleton.js
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -14,7 +14,7 @@ module.exports = {
*/
},

down: function (queryInterface, Sequelize) {
down: (queryInterface, Sequelize) => {
/*
Add reverting commands here.
Return a promise to correctly handle asynchronicity.
Expand Down
4 changes: 2 additions & 2 deletions test/migration/create.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
});
Expand Down
4 changes: 2 additions & 2 deletions test/seed/create.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
});
Expand Down

0 comments on commit 733ced9

Please sign in to comment.