File tree Expand file tree Collapse file tree 3 files changed +35
-2
lines changed
support/assets/migrations/cjs Expand file tree Collapse file tree 3 files changed +35
-2
lines changed Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ export function getMigrator (type, args) {
4949 migrations : {
5050 params : [ sequelize . getQueryInterface ( ) , Sequelize ] ,
5151 path : helpers . path . getPath ( type ) ,
52- pattern : / \. j s $ / ,
52+ pattern : / \. c ? j s $ / ,
5353 wrap : fun => {
5454 if ( fun . length === 3 ) {
5555 return promisify ( fun ) ;
Original file line number Diff line number Diff line change @@ -26,7 +26,9 @@ const _ = require('lodash');
2626 const config = _ . assign ( { } , helpers . getTestConfig ( ) , options . config ) ;
2727 let configContent = JSON . stringify ( config ) ;
2828
29- migrationFile = migrationFile + '.js' ;
29+ if ( ! migrationFile . match ( / \. c j s $ / ) ) {
30+ migrationFile = migrationFile + '.js' ;
31+ }
3032 if ( flag . match ( / c o n f i g \. j s $ / ) ) {
3133 configPath = configPath + 'config.js' ;
3234 configContent = 'module.exports = ' + configContent ;
@@ -128,6 +130,20 @@ const _ = require('lodash');
128130 } ) ;
129131 } ) ;
130132
133+ describe ( 'migrations with cjs extension' , ( ) => {
134+ it ( 'correctly migrates' , function ( done ) {
135+ const self = this ;
136+ prepare ( ( ) => {
137+ helpers . readTables ( self . sequelize , tables => {
138+ expect ( tables . sort ( ) ) . to . contain ( 'Comment' ) ;
139+ done ( ) ;
140+ } ) ;
141+ } , {
142+ migrationFile : 'cjs/*createComment.cjs'
143+ } ) ;
144+ } ) ;
145+ } ) ;
146+
131147 describe ( 'custom meta table name' , ( ) => {
132148 it ( 'correctly uses the defined table name' , function ( done ) {
133149 const self = this ;
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ var nodeify = require ( 'nodeify' ) ;
4+
5+ module . exports = {
6+ up : function ( migration , DataTypes , done ) {
7+ nodeify ( migration
8+ . createTable ( 'Comment' , {
9+ title : DataTypes . STRING ,
10+ body : DataTypes . TEXT
11+ } ) , done ) ;
12+ } ,
13+
14+ down : function ( migration , DataTypes , done ) {
15+ nodeify ( migration . dropTable ( 'Comment' ) , done ) ;
16+ }
17+ } ;
You can’t perform that action at this time.
0 commit comments