Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core/migrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function getMigrator (type, args) {
migrations: {
params: [sequelize.getQueryInterface(), Sequelize],
path: helpers.path.getPath(type),
pattern: /\.js$/,
pattern: /\.c?js$/,
wrap: fun => {
if (fun.length === 3) {
return promisify(fun);
Expand Down
18 changes: 17 additions & 1 deletion test/db/migrate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ const _ = require('lodash');
const config = _.assign({}, helpers.getTestConfig(), options.config);
let configContent = JSON.stringify(config);

migrationFile = migrationFile + '.js';
if(!migrationFile.match(/\.cjs$/)){
migrationFile = migrationFile + '.js';
}
if (flag.match(/config\.js$/)) {
configPath = configPath + 'config.js';
configContent = 'module.exports = ' + configContent;
Expand Down Expand Up @@ -128,6 +130,20 @@ const _ = require('lodash');
});
});

describe('migrations with cjs extension', () => {
it('correctly migrates', function (done) {
const self = this;
prepare(() => {
helpers.readTables(self.sequelize, tables => {
expect(tables.sort()).to.contain('Comment');
done();
});
}, {
migrationFile: 'cjs/*createComment.cjs'
});
});
});

describe('custom meta table name', () => {
it('correctly uses the defined table name', function (done) {
const self = this;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict';

var nodeify = require('nodeify');

module.exports = {
up: function (migration, DataTypes, done) {
nodeify(migration
.createTable('Comment', {
title: DataTypes.STRING,
body: DataTypes.TEXT
}), done);
},

down: function (migration, DataTypes, done) {
nodeify(migration.dropTable('Comment'), done);
}
};