@@ -10,7 +10,7 @@ const platform = require('./helpers/platform');
1010const should = require ( './init' ) ;
1111const Schema = require ( 'loopback-datasource-juggler' ) . Schema ;
1212
13- let db , UserData , StringData , NumberData , DateData , DefaultData , SimpleEmployee ;
13+ let db , UserData , StringData , NumberData , DateData , DefaultData , SimpleEmployee , SimplePatient ;
1414let mysqlVersion ;
1515
1616describe ( 'migrations' , function ( ) {
@@ -32,6 +32,18 @@ describe('migrations', function() {
3232 } ) ;
3333 } ) ;
3434
35+ it ( 'Migrating models that has enum' , function ( done ) {
36+ query ( 'describe SimplePatient' , function ( err , result ) {
37+ should . not . exist ( err ) ;
38+ should . exist ( result ) ;
39+ result [ 0 ] . Key . should . equal ( 'PRI' ) ;
40+ result [ 0 ] . Type . should . equal ( 'bigint' ) ;
41+ result [ 2 ] . Key . should . equal ( 'type' ) ;
42+ result [ 2 ] . Type . should . equal ( 'enum(\'INPATIENT\',\'OUTPATIENT\')' ) ;
43+ done ( ) ;
44+ } ) ;
45+ } ) ;
46+
3547 it ( 'UserData should have correct columns' , function ( done ) {
3648 getFields ( 'UserData' , function ( err , fields ) {
3749 if ( ! fields ) return done ( ) ;
@@ -603,6 +615,12 @@ function setup(done) {
603615 name : { type : String } ,
604616 } ) ;
605617
618+ SimplePatient = db . define ( 'SimplePatient' , {
619+ pid : { type : Number , generated : true , id : true , mysql : { dataType : 'bigint' , dataLength : 20 } } ,
620+ name : { type : String } ,
621+ patient : { type : String , mysql : { columnName : 'type' , dataType : 'enum' , value : "'INPATIENT','OUTPATIENT'" , dataPrecision : null , dataScale : null , nullable : 'Y' , generated : false } } ,
622+ } ) ;
623+
606624 query ( 'SELECT VERSION()' , function ( err , res ) {
607625 mysqlVersion = res && res [ 0 ] && res [ 0 ] [ 'VERSION()' ] ;
608626 blankDatabase ( db , done ) ;
0 commit comments