-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lib: Fix bug when migrating a table with no foreign keys to having some
- Loading branch information
Showing
2 changed files
with
52 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
'use strict'; | ||
|
||
const MySQLPlus = require('../../lib/MySQLPlus'); | ||
|
||
const config = require('../config'); | ||
|
||
const ColTypes = MySQLPlus.ColTypes; | ||
|
||
describe('when migrating a table with no foreign keys to having some foreign keys', function() { | ||
|
||
const pool = MySQLPlus.createPool(config); | ||
const pool2 = MySQLPlus.createPool(config); | ||
|
||
pool.defineTable('add_foreign_keys_foreign', { | ||
columns: { | ||
id: ColTypes.int().notNull().primaryKey(), | ||
}, | ||
}); | ||
pool.defineTable('add_foreign_keys_main', { | ||
columns: { | ||
id: ColTypes.int().notNull().index(), | ||
}, | ||
}); | ||
pool2.defineTable('add_foreign_keys_main', { | ||
columns: { | ||
id: ColTypes.int().notNull().index(), | ||
}, | ||
foreignKeys: { | ||
id: 'add_foreign_keys_foreign.id', | ||
}, | ||
}); | ||
|
||
before(done => { | ||
pool.sync(err => { | ||
if (err) { | ||
throw err; | ||
} | ||
|
||
pool.end(done); | ||
}); | ||
}); | ||
|
||
after(done => { | ||
pool2.end(done); | ||
}); | ||
|
||
it('should not error', done => { | ||
pool2.sync(done); | ||
}); | ||
|
||
}); |