Skip to content

Commit

Permalink
fix: rename column consolidation_id to consolidation_rule_id
Browse files Browse the repository at this point in the history
  • Loading branch information
Kpoke committed Oct 27, 2021
1 parent 1c832c9 commit 526c45b
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 2 deletions.
2 changes: 1 addition & 1 deletion __tests__/api-tests/seed-data-creation.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ before(async () => {
await knex.raw(`
INSERT INTO earnings.earnings(
id, worker_id, funder_id, amount, currency, calculated_at, consolidation_id, consolidation_period_start, consolidation_period_end, payment_confirmed_by, payment_confirmation_method, status, active, contract_id)
id, worker_id, funder_id, amount, currency, calculated_at, consolidation_rule_id, consolidation_period_start, consolidation_period_end, payment_confirmed_by, payment_confirmation_method, status, active, contract_id)
VALUES
('${earningsOne.id}','${workerId}', '${uuid()}', '${earningsPaymentObject.amount}', '${earningsPaymentObject.currency}', now(), '${uuid()}', now(), now(), '${uuid()}','single', '${earningsOne.status}', true, '${uuid()}'),
('${earningsTwo.id}','${workerId}', '${uuid()}', '${earningsPaymentObject.amount}', '${earningsPaymentObject.currency}', now(), '${uuid()}', now(), now(), '${uuid()}','single', '${earningsTwo.status}', true, '${uuid()}'),
Expand Down
53 changes: 53 additions & 0 deletions database/migrations/20211027043106-alterTableName.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
'use strict';

var dbm;
var type;
var seed;
var fs = require('fs');
var path = require('path');
var Promise;

/**
* We receive the dbmigrate dependency from dbmigrate initially.
* This enables us to not have to rely on NODE_PATH.
*/
exports.setup = function(options, seedLink) {
dbm = options.dbmigrate;
type = dbm.dataType;
seed = seedLink;
Promise = options.Promise;
};

exports.up = function(db) {
var filePath = path.join(__dirname, 'sqls', '20211027043106-alterTableName-up.sql');
return new Promise( function( resolve, reject ) {
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
if (err) return reject(err);
console.log('received data: ' + data);

resolve(data);
});
})
.then(function(data) {
return db.runSql(data);
});
};

exports.down = function(db) {
var filePath = path.join(__dirname, 'sqls', '20211027043106-alterTableName-down.sql');
return new Promise( function( resolve, reject ) {
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
if (err) return reject(err);
console.log('received data: ' + data);

resolve(data);
});
})
.then(function(data) {
return db.runSql(data);
});
};

exports._meta = {
"version": 1
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/* Replace with your SQL commands */
ALTER TABLE earnings.earnings RENAME COLUMN consolidation_rule_id TO consolidation_id;
2 changes: 2 additions & 0 deletions database/migrations/sqls/20211027043106-alterTableName-up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/* Replace with your SQL commands */
ALTER TABLE earnings.earnings RENAME COLUMN consolidation_id TO consolidation_rule_id;
1 change: 0 additions & 1 deletion server/models/Earnings.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const Earning = ({
status,
batch_id,
}) => {
// make a call to the contract microservice and get the consolidation_rule
const consolidation_rule = `CONSOLIDATION_RULE_${consolidation_rule_id}`;
return Object.freeze({
worker_id,
Expand Down

0 comments on commit 526c45b

Please sign in to comment.