@@ -10,7 +10,7 @@ const platform = require('./helpers/platform');
10
10
const should = require ( './init' ) ;
11
11
const Schema = require ( 'loopback-datasource-juggler' ) . Schema ;
12
12
13
- let db , UserData , StringData , NumberData , DateData , DefaultData , SimpleEmployee ;
13
+ let db , UserData , StringData , NumberData , DateData , DefaultData , SimpleEmployee , SimplePatient ;
14
14
let mysqlVersion ;
15
15
16
16
describe ( 'migrations' , function ( ) {
@@ -32,6 +32,18 @@ describe('migrations', function() {
32
32
} ) ;
33
33
} ) ;
34
34
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
+
35
47
it ( 'UserData should have correct columns' , function ( done ) {
36
48
getFields ( 'UserData' , function ( err , fields ) {
37
49
if ( ! fields ) return done ( ) ;
@@ -603,6 +615,12 @@ function setup(done) {
603
615
name : { type : String } ,
604
616
} ) ;
605
617
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
+
606
624
query ( 'SELECT VERSION()' , function ( err , res ) {
607
625
mysqlVersion = res && res [ 0 ] && res [ 0 ] [ 'VERSION()' ] ;
608
626
blankDatabase ( db , done ) ;
0 commit comments