@@ -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,23 @@ 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 : { 
622+       type : String , 
623+       mysql : { 
624+         columnName : 'type' , 
625+         dataType : 'enum' , 
626+         value : "'INPATIENT','OUTPATIENT'" , 
627+         dataPrecision : null , 
628+         dataScale : null , 
629+         nullable : 'Y' , 
630+         generated : false , 
631+       } , 
632+     } , 
633+   } ) ; 
634+ 
606635  query ( 'SELECT VERSION()' ,  function ( err ,  res )  { 
607636    mysqlVersion  =  res  &&  res [ 0 ]  &&  res [ 0 ] [ 'VERSION()' ] ; 
608637    blankDatabase ( db ,  done ) ; 
0 commit comments