-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* When a report is saved the goals and objectives from the report are saved to the DB, udpated or created if needed * An ActivityReportObjective record is created for every objective associating the report to objective * Objectives that are no longer used in the report are removed from the DB, along with the ActivityReportObjective * If the goal hasn't been used on a previous report and is removed from the current report it is also removed * When a report is approved a GrantGoal record is created for every goal/grant pair
- Loading branch information
1 parent
cf78ad4
commit cb1b865
Showing
18 changed files
with
650 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module.exports = { | ||
up: async (queryInterface) => { | ||
queryInterface.addIndex('GrantGoals', ['grantId', 'goalId', 'granteeId'], { unique: true }); | ||
}, | ||
|
||
down: async (queryInterface) => { | ||
queryInterface.removeIndex('GrantGoals', ['grantId', 'goalId', 'granteeId']); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
module.exports = { | ||
up: async (queryInterface, Sequelize) => { | ||
queryInterface.createTable('Objectives', { | ||
id: { | ||
type: Sequelize.INTEGER, | ||
allowNull: false, | ||
primaryKey: true, | ||
autoIncrement: true, | ||
}, | ||
goalId: { | ||
type: Sequelize.INTEGER, | ||
allowNull: false, | ||
references: { | ||
model: { | ||
tableName: 'Goals', | ||
}, | ||
key: 'id', | ||
}, | ||
}, | ||
title: { | ||
type: Sequelize.TEXT, | ||
}, | ||
ttaProvided: { | ||
type: Sequelize.TEXT, | ||
}, | ||
status: { | ||
type: Sequelize.STRING, | ||
}, | ||
createdAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE, | ||
defaultValue: Sequelize.fn('NOW'), | ||
}, | ||
updatedAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE, | ||
defaultValue: Sequelize.fn('NOW'), | ||
}, | ||
}); | ||
}, | ||
|
||
down: (queryInterface) => queryInterface.dropTable('Objectives'), | ||
}; |
42 changes: 42 additions & 0 deletions
42
src/migrations/20210305181122-create-activity-report-objectives.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
module.exports = { | ||
up: async (queryInterface, Sequelize) => { | ||
queryInterface.createTable('ActivityReportObjectives', { | ||
id: { | ||
type: Sequelize.INTEGER, | ||
allowNull: false, | ||
primaryKey: true, | ||
autoIncrement: true, | ||
}, | ||
activityReportId: { | ||
type: Sequelize.INTEGER, | ||
allowNull: false, | ||
references: { | ||
model: { | ||
tableName: 'ActivityReports', | ||
}, | ||
}, | ||
}, | ||
objectiveId: { | ||
type: Sequelize.INTEGER, | ||
allowNull: false, | ||
references: { | ||
model: { | ||
tableName: 'Objectives', | ||
}, | ||
}, | ||
}, | ||
createdAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE, | ||
defaultValue: Sequelize.fn('NOW'), | ||
}, | ||
updatedAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE, | ||
defaultValue: Sequelize.fn('NOW'), | ||
}, | ||
}); | ||
}, | ||
|
||
down: (queryInterface) => queryInterface.dropTable('ActivityReportObjectives'), | ||
}; |
44 changes: 44 additions & 0 deletions
44
src/migrations/20210308162757-remove-activity-report-goals-table.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
module.exports = { | ||
up: async (queryInterface) => { | ||
await queryInterface.dropTable('ActivityReportGoals'); | ||
}, | ||
|
||
down: async (queryInterface, Sequelize) => { | ||
await queryInterface.createTable('ActivityReportGoals', { | ||
id: { | ||
allowNull: false, | ||
autoIncrement: true, | ||
primaryKey: true, | ||
type: Sequelize.INTEGER, | ||
}, | ||
activityReportId: { | ||
type: Sequelize.INTEGER, | ||
allowNull: false, | ||
references: { | ||
model: { | ||
tableName: 'ActivityReports', | ||
}, | ||
}, | ||
}, | ||
goalId: { | ||
type: Sequelize.INTEGER, | ||
allowNull: false, | ||
references: { | ||
model: { | ||
tableName: 'Goals', | ||
}, | ||
}, | ||
}, | ||
createdAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE, | ||
defaultValue: Sequelize.fn('NOW'), | ||
}, | ||
updatedAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE, | ||
defaultValue: Sequelize.fn('NOW'), | ||
}, | ||
}); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.