Merge pull request #3 from chilts/i1-use-lowercase-table-names
Fixes #1 - Use lowercase tablename for cross-platform compatibility in t...
This commit is contained in:
Коммит
eb85a9859c
|
@ -14,6 +14,7 @@ var options = {
|
|||
database : 'patcher',
|
||||
// password : '',
|
||||
dir : path.join(__dirname, 'end-to-end'),
|
||||
metaTable : 'metadata',
|
||||
patchKey : 'schema-patch-level',
|
||||
patchLevel : 3,
|
||||
mysql : mysql,
|
||||
|
@ -27,14 +28,15 @@ test('run an end to end test, with no error (to patch 0)', function(t) {
|
|||
options.patchLevel = 0
|
||||
|
||||
patcher.patch(options, function(err, res) {
|
||||
console.log(err, res)
|
||||
t.ok(!err, 'There was no error when patching the database')
|
||||
|
||||
// create a connection and check the dbMetadata key has been updated to 3
|
||||
connection.query("SELECT value FROM dbMetadata WHERE name = 'schema-patch-level'", function(err, res) {
|
||||
// create a connection and check the metadata key has been updated to 3
|
||||
connection.query("SELECT value FROM metadata WHERE name = 'schema-patch-level'", function(err, res) {
|
||||
t.ok(err, 'There was an error getting the database patch level')
|
||||
t.equal(err.code, 'ER_NO_SUCH_TABLE', 'No dbMetadata table')
|
||||
t.equal(err.code, 'ER_NO_SUCH_TABLE', 'No metadata table')
|
||||
t.equal(err.errno, 1146, 'Correct error number')
|
||||
t.equal(err.message, "ER_NO_SUCH_TABLE: Table 'patcher.dbMetadata' doesn't exist", 'Correct message')
|
||||
t.equal(err.message, "ER_NO_SUCH_TABLE: Table 'patcher.metadata' doesn't exist", 'Correct message')
|
||||
|
||||
t.end()
|
||||
})
|
||||
|
@ -48,8 +50,8 @@ test('run an end to end test, with no error(to patch 3)', function(t) {
|
|||
patcher.patch(options, function(err, res) {
|
||||
t.ok(!err, 'There was no error when patching the database')
|
||||
|
||||
// create a connection and check the dbMetadata key has been updated to 3
|
||||
connection.query("SELECT value FROM dbMetadata WHERE name = 'schema-patch-level'", function(err, res) {
|
||||
// create a connection and check the metadata key has been updated to 3
|
||||
connection.query("SELECT value FROM metadata WHERE name = 'schema-patch-level'", function(err, res) {
|
||||
t.ok(!err, 'There was no error getting the database patch level')
|
||||
|
||||
t.equal(res[0].value, '3', 'The database patch level is correct')
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
-- Create the 'dbMetadata' table.
|
||||
-- Create the 'metadata' table.
|
||||
-- Note: This should be the only thing in this initial patch.
|
||||
|
||||
CREATE TABLE dbMetadata (
|
||||
CREATE TABLE metadata (
|
||||
name VARCHAR(255) NOT NULL PRIMARY KEY,
|
||||
value VARCHAR(255) NOT NULL
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
INSERT INTO dbMetadata SET name = 'schema-patch-level', value = '1';
|
||||
INSERT INTO metadata SET name = 'schema-patch-level', value = '1';
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
-- -- drop the dbMetadata table
|
||||
DROP TABLE dbMetadata;
|
||||
-- -- drop the metadata table
|
||||
DROP TABLE metadata;
|
||||
|
|
|
@ -4,4 +4,4 @@ CREATE TABLE accounts (
|
|||
createdAt BIGINT UNSIGNED NOT NULL
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
UPDATE dbMetadata SET value = '2' WHERE name = 'schema-patch-level';
|
||||
UPDATE metadata SET value = '2' WHERE name = 'schema-patch-level';
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
DROP TABLE accounts;
|
||||
|
||||
UPDATE dbMetadata SET value = '1' WHERE name = 'schema-patch-level';
|
||||
UPDATE metadata SET value = '1' WHERE name = 'schema-patch-level';
|
||||
|
|
|
@ -4,4 +4,4 @@ CREATE TABLE kv (
|
|||
createdAt BIGINT UNSIGNED NOT NULL
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
UPDATE dbMetadata SET value = '3' WHERE name = 'schema-patch-level';
|
||||
UPDATE metadata SET value = '3' WHERE name = 'schema-patch-level';
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
DROP TABLE kv;
|
||||
|
||||
UPDATE dbMetadata SET value = '2' WHERE name = 'schema-patch-level';
|
||||
UPDATE metadata SET value = '2' WHERE name = 'schema-patch-level';
|
||||
|
|
Загрузка…
Ссылка в новой задаче