Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Agnes Lin committed Dec 13, 2019
1 parent 1f11568 commit 684a4ef
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions test/postgresql.migration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
});
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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) {
Expand All @@ -200,5 +200,5 @@ function checkDefault(model, cb){
});
}
cb(err, cols);
},)
});
}

0 comments on commit 684a4ef

Please sign in to comment.