Skip to content

Commit

Permalink
fix: migration script
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelTaylor3D committed Aug 29, 2022
1 parent b23b6a1 commit 5395724
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
15 changes: 6 additions & 9 deletions src/controllers/project.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,8 @@ const update = async (req, res, isTransfer = false) => {

const newRecord = _.cloneDeep(req.body);

// Why do we need this? the orgUid should already be in the record
//const { orgUid } = await Organization.getHomeOrg();
//newRecord.orgUid = orgUid;

const { orgUid } = newRecord;
const { orgUid } = await Organization.getHomeOrg();
newRecord.orgUid = orgUid;

const childRecordsKeys = [
'projectLocations',
Expand Down Expand Up @@ -336,14 +333,14 @@ const update = async (req, res, isTransfer = false) => {
action: 'UPDATE',
table: Project.stagingTableName,
data: JSON.stringify(stagedRecord),
// If this is a transfer staging, push it directly into commited status
// Since we are downloading a offer file and shouldnt be allowed to operate
// until that file is either accepted or cancelled
commited: isTransfer,
};

if (isTransfer) {
// If this is a transfer staging, push it directly into commited status
// Since we are downloading a offer file and shouldnt be allowed to operate
// until that file is either accepted or cancelled
stagedData.isTransfer = true;
stagedData.commited = true;
}

await Staging.upsert(stagedData);
Expand Down
5 changes: 5 additions & 0 deletions src/database/migrations/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import AddOptionalMethodology2FieldToProject from './20220721212845-add-optional
import AddFiltStoreSubscribedColumnToProject from './20220809182156-AddFileStoreSubscribedColumn';
import PopulateUnitsFTS from './20220808192709-populate-units-fts';
import ResetDBForNewSingletons from './20220816155101-reset-db-for-new-singletons';
import AddIsTransferColumn from './20220825124702-add-isTransfer-column';

export const migrations = [
{
Expand Down Expand Up @@ -154,4 +155,8 @@ export const migrations = [
migration: ResetDBForNewSingletons,
name: '20220816155101-reset-db-for-new-singletons',
},
{
migration: AddIsTransferColumn,
name: '20220825124702-add-isTransfer-column',
},
];
8 changes: 3 additions & 5 deletions src/routes/v1/resources/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,14 @@ ProjectRouter.post(
ProjectController.create,
);

ProjectRouter.put(
'/',
validator.body(projectsUpdateSchema),
ProjectController.update,
ProjectRouter.put('/', validator.body(projectsUpdateSchema), (req, res) =>
ProjectController.update(req, res, false),
);

ProjectRouter.put(
'/transfer',
validator.body(projectsUpdateSchema),
ProjectController.transfer,
(req, res) => ProjectController.transfer(req, res),
);

ProjectRouter.put('/xlsx', ProjectController.updateFromXLS);
Expand Down

0 comments on commit 5395724

Please sign in to comment.