@@ -96,6 +96,15 @@ const reverseSequelizeColType = function(col, prefix = 'Sequelize.')
9696 return prefix + 'GEOGRAPHY' ;
9797
9898 case DataTypes . ARRAY . key :
99+ const _type = attrObj . toString ( ) ;
100+ let arrayType ;
101+ if ( _type === 'INTEGER[]' || _type === 'STRING[]' ) {
102+ arrayType = prefix + _type . replace ( '[]' , '' ) ;
103+ } else {
104+ arrayType = ( col . seqType === 'Sequelize.ARRAY(Sequelize.INTEGER)' ) ? prefix + 'INTEGER' : prefix + 'STRING' ;
105+ }
106+ return prefix + `ARRAY(${ arrayType } )` ;
107+
99108 case DataTypes . RANGE . key :
100109 console . warn ( attrName + ' type not supported, you should make it by' )
101110 return prefix + attrObj . toSql ( )
@@ -201,12 +210,24 @@ const reverseModels = function(sequelize, models)
201210 delete attributes [ column ] [ property ] ;
202211 }
203212
204- if ( typeof attributes [ column ] [ 'type' ] === 'undefined' )
213+ if ( typeof attributes [ column ] [ 'type' ] === 'undefined' )
205214 {
215+ if ( ! attributes [ column ] [ 'seqType' ] )
216+ {
206217 log ( `[Not supported] Skip column with undefined type ${ model } :${ column } ` ) ;
207218 delete attributes [ column ] ;
208219 continue ;
220+ } else {
221+ if ( ! [ 'Sequelize.ARRAY(Sequelize.INTEGER)' , 'Sequelize.ARRAY(Sequelize.STRING)' ] . includes ( attributes [ column ] [ 'seqType' ] ) ) {
222+ delete attributes [ column ] ;
223+ continue ;
224+ }
225+ attributes [ column ] [ 'type' ] = {
226+ key : Sequelize . ARRAY . key
227+ }
228+ }
209229 }
230+
210231 let seqType = reverseSequelizeColType ( attributes [ column ] ) ;
211232
212233 // NO virtual types in migration
@@ -820,4 +841,3 @@ const executeMigration = function(queryInterface, filename, pos, cb)
820841} ;
821842
822843module . exports = { writeMigration, getMigration, sortActions, parseDifference, reverseModels, executeMigration } ;
823-
0 commit comments