-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add custom fields feature to project issues This adds the ability to track additional custom fields for project issues. These custom fields can be of various types (text, number, date, boolean), and are identified by a custom field id. Along with this, CRUD operations for these custom fields have also been implemented, including newly defined GraphQL mutations for creating and deleting project custom fields. To store these custom field values at the database level, additional columns have been added to the 'issues' table in a new migration file, and these values can be updated using the existing 'updateIssue' mutation under resolvers. * Refactor custom fields handling in backend This commit revolves around updating the naming conventions for custom field values. The term 'customFieldValues' has been replaced with 'customFields' across various files. This has also impacted the logic managing these fields, with adapted models, migrations, and resolvers to instantly reflect the changes. The 'customFieldValues' method within the Issue resolver has been completely removed as it is no longer necessary, given the new naming convention.
- Loading branch information
1 parent
a3b74d5
commit a19e592
Showing
9 changed files
with
249 additions
and
13 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
backend/src/db/migrations/20231228152900-add-custom-fields.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,52 @@ | ||
'use strict'; | ||
|
||
const TABLE_NAME = 'project_custom_fields'; | ||
|
||
/** @type {import('sequelize-cli').Migration} */ | ||
export default { | ||
async up(queryInterface, Sequelize) { | ||
await queryInterface.createTable(TABLE_NAME, { | ||
id: { | ||
allowNull: false, | ||
autoIncrement: true, | ||
primaryKey: true, | ||
type: Sequelize.INTEGER, | ||
}, | ||
projectId: { | ||
type: Sequelize.INTEGER, | ||
field: 'project_id', | ||
references: { | ||
model: { | ||
tableName: 'projects', | ||
schema: 'public', | ||
}, | ||
key: 'id', | ||
}, | ||
}, | ||
fieldName: { | ||
type: Sequelize.STRING, | ||
field: 'field_name', | ||
}, | ||
fieldType: { | ||
type: Sequelize.STRING, | ||
field: 'field_type', | ||
}, | ||
createdAt: { | ||
field: 'created_at', | ||
type: Sequelize.DATE, | ||
}, | ||
updatedAt: { | ||
field: 'updated_at', | ||
type: Sequelize.DATE, | ||
}, | ||
}); | ||
|
||
await queryInterface.addIndex(TABLE_NAME, { | ||
fields: ['project_id'], | ||
unique: false, | ||
}); | ||
}, | ||
async down(queryInterface, Sequelize) { | ||
await queryInterface.dropTable(TABLE_NAME); | ||
}, | ||
}; |
16 changes: 16 additions & 0 deletions
16
backend/src/db/migrations/20231228153315-add-issue-custom-field-values.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,16 @@ | ||
'use strict'; | ||
|
||
const TABLE_NAME = 'issues'; | ||
const COLUMN_NAME = 'custom_fields'; | ||
|
||
/** @type {import('sequelize-cli').Migration} */ | ||
export default { | ||
async up(queryInterface, Sequelize) { | ||
await queryInterface.addColumn(TABLE_NAME, COLUMN_NAME, { | ||
type: Sequelize.JSONB, | ||
}); | ||
}, | ||
async down(queryInterface, Sequelize) { | ||
await queryInterface.removeColumn(TABLE_NAME, COLUMN_NAME); | ||
}, | ||
}; |
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,51 @@ | ||
'use strict'; | ||
|
||
export default (sequelize, DataTypes) => { | ||
const ProjectCustomField = sequelize.define( | ||
'ProjectCustomField', | ||
{ | ||
id: { | ||
allowNull: false, | ||
autoIncrement: true, | ||
primaryKey: true, | ||
type: DataTypes.INTEGER, | ||
}, | ||
projectId: { | ||
type: DataTypes.INTEGER, | ||
field: 'project_id', | ||
references: { | ||
model: 'projects', | ||
key: 'id', | ||
}, | ||
}, | ||
fieldName: { | ||
type: DataTypes.STRING, | ||
field: 'field_name', | ||
}, | ||
fieldType: { | ||
type: DataTypes.STRING, | ||
field: 'field_type', | ||
}, | ||
createdAt: { | ||
field: 'created_at', | ||
type: DataTypes.DATE, | ||
}, | ||
updatedAt: { | ||
field: 'updated_at', | ||
type: DataTypes.DATE, | ||
}, | ||
}, | ||
{ | ||
sequelize, | ||
tableName: 'project_custom_fields', | ||
timestamps: false, | ||
indexes: [{ unique: false, fields: ['project_id'] }], | ||
} | ||
); | ||
|
||
ProjectCustomField.associate = ({ Project }) => { | ||
ProjectCustomField.belongsTo(Project, { foreignKey: 'project_id' }); | ||
}; | ||
|
||
return ProjectCustomField; | ||
}; |
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