File tree Expand file tree Collapse file tree 2 files changed +52
-1
lines changed Expand file tree Collapse file tree 2 files changed +52
-1
lines changed Original file line number Diff line number Diff line change @@ -243,7 +243,7 @@ class TableDefinition {
243
243
for ( columnNames in oldForeignKeys ) {
244
244
const columnNamesArray = columnNames . split ( ',' ) ;
245
245
246
- if ( isEqual ( oldForeignKeys [ columnNames ] , newForeignKeys [ columnNames ] ) ) {
246
+ if ( newForeignKeys && isEqual ( oldForeignKeys [ columnNames ] , newForeignKeys [ columnNames ] ) ) {
247
247
if ( ! mustAvoidforeignKeyConflict ( columnNamesArray , otherOperations ) ) {
248
248
continue ;
249
249
}
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 foreign keys to having no foreign keys' , function ( ) {
10
+
11
+ const pool = MySQLPlus . createPool ( config ) ;
12
+ const pool2 = MySQLPlus . createPool ( config ) ;
13
+
14
+ pool . defineTable ( 'remove_all_foreign_keys_foreign' , {
15
+ columns : {
16
+ id : ColTypes . int ( ) . notNull ( ) . primaryKey ( ) ,
17
+ } ,
18
+ } ) ;
19
+ pool . defineTable ( 'remove_all_foreign_keys_main' , {
20
+ columns : {
21
+ id : ColTypes . int ( ) . notNull ( ) . index ( ) ,
22
+ } ,
23
+ foreignKeys : {
24
+ id : 'remove_all_foreign_keys_foreign.id' ,
25
+ } ,
26
+ } ) ;
27
+ pool2 . defineTable ( 'remove_all_foreign_keys_main' , {
28
+ columns : {
29
+ id : ColTypes . int ( ) . notNull ( ) . index ( ) ,
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