File tree Expand file tree Collapse file tree 2 files changed +52
-2
lines changed Expand file tree Collapse file tree 2 files changed +52
-2
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,6 @@ const Operation = require('./Operation');
5
5
6
6
const cloneDeep = require ( 'lodash/cloneDeep' ) ;
7
7
const diffKeys = require ( './utils/diffKeys' ) ;
8
- const isEmpty = require ( 'lodash/isEmpty' ) ;
9
8
const isEqual = require ( 'lodash/isEqual' ) ;
10
9
11
10
const KEY_TYPES = {
@@ -753,7 +752,7 @@ function generateForegnKeysSchema(createDefinitions) {
753
752
} ;
754
753
}
755
754
756
- return isEmpty ( foreignKeys ) ? null : foreignKeys ;
755
+ return foreignKeys ;
757
756
}
758
757
759
758
function arraysEqual ( a , b ) {
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ const MySQLPlus = require ( '../../lib/MySQLPlus' ) ;
4
+
5
+ const config = require ( '../config' ) ;
6
+
7
+ const ColTypes = MySQLPlus . ColTypes ;
8
+
9
+ describe ( 'when migrating a table with no foreign keys to having some foreign keys' , function ( ) {
10
+
11
+ const pool = MySQLPlus . createPool ( config ) ;
12
+ const pool2 = MySQLPlus . createPool ( config ) ;
13
+
14
+ pool . defineTable ( 'add_foreign_keys_foreign' , {
15
+ columns : {
16
+ id : ColTypes . int ( ) . notNull ( ) . primaryKey ( ) ,
17
+ } ,
18
+ } ) ;
19
+ pool . defineTable ( 'add_foreign_keys_main' , {
20
+ columns : {
21
+ id : ColTypes . int ( ) . notNull ( ) . index ( ) ,
22
+ } ,
23
+ } ) ;
24
+ pool2 . defineTable ( 'add_foreign_keys_main' , {
25
+ columns : {
26
+ id : ColTypes . int ( ) . notNull ( ) . index ( ) ,
27
+ } ,
28
+ foreignKeys : {
29
+ id : 'add_foreign_keys_foreign.id' ,
30
+ } ,
31
+ } ) ;
32
+
33
+ before ( done => {
34
+ pool . sync ( err => {
35
+ if ( err ) {
36
+ throw err ;
37
+ }
38
+
39
+ pool . end ( done ) ;
40
+ } ) ;
41
+ } ) ;
42
+
43
+ after ( done => {
44
+ pool2 . end ( done ) ;
45
+ } ) ;
46
+
47
+ it ( 'should not error' , done => {
48
+ pool2 . sync ( done ) ;
49
+ } ) ;
50
+
51
+ } ) ;
You can’t perform that action at this time.
0 commit comments