diff --git a/test/postgresql.migration.test.js b/test/postgresql.migration.test.js index fa91cf1e..0d38217d 100644 --- a/test/postgresql.migration.test.js +++ b/test/postgresql.migration.test.js @@ -14,8 +14,7 @@ describe('migrations', function() { before(setup); it('should run migration', function(done) { - db.automigrate('UserDataWithIndexes', done); - db.automigrate('OrderData', done); + db.automigrate(['UserDataWithIndexes', 'OrderData'], done); }); it('UserDataWithIndexes should have correct indexes', function(done) { @@ -76,20 +75,20 @@ describe('migrations', function() { }); it('OrderData should have correct id type uuid and default function', function(done) { - checkDefault('OrderData', function(err, cols){ + checkDefault('OrderData', function(err, cols) { assert.deepEqual(cols, { - ordercode: - { column_name: 'ordercode', + ordercode: + {column_name: 'ordercode', column_default: 'uuid_generate_v4()', - data_type: 'uuid' }, - ordername: - { column_name: 'ordername', + data_type: 'uuid'}, + ordername: + {column_name: 'ordername', column_default: null, - data_type: 'text' }, - id: - { column_name: 'id', + data_type: 'text'}, + id: + {column_name: 'id', column_default: 'nextval(\'orderdata_id_seq\'::regclass)', - data_type: 'integer' } + data_type: 'integer'}, }); done(); }); @@ -141,10 +140,10 @@ function setup(done) { }); const OrderData = db.define('OrderData', { ordercode: {type: 'String', required: true, generated: true, useDefaultIdType: false, - postgresql: { - dataType: 'uuid', - }}, - ordername: {type: 'String'} + postgresql: { + dataType: 'uuid', + }}, + ordername: {type: 'String'}, }); done(); @@ -189,8 +188,9 @@ function table(model) { function query(sql, cb) { db.adapter.query(sql, cb); } -function checkDefault(model, cb){ - query(`SELECT column_name, column_default, data_type FROM information_schema.columns WHERE(table_schema, table_name) = ('public', 'orderdata');`, +function checkDefault(model, cb) { + query('SELECT column_name, column_default, data_type FROM information_schema.columns \ + WHERE(table_schema, table_name) = (\'public\', \'orderdata\');', function(err, data) { const cols = {}; if (!err) { @@ -200,5 +200,5 @@ function checkDefault(model, cb){ }); } cb(err, cols); - },) + }); }