-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added type field to userChallenge entity (#32)
* Added type field to userChallenge entity * Eslint fix * Change the case of the enum`s values * Moved the ChallengeTypeValues variable in to a separate file * Reuse the ChallengeTypeValues in the validation model --------- Co-authored-by: Viktor Riabkov <vitya.ryabkov@gmail.com>
- Loading branch information
1 parent
4ea961c
commit 254cc24
Showing
6 changed files
with
43 additions
and
0 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
17 changes: 17 additions & 0 deletions
17
src/database/migrations/20241127102737-add-type-to-userChallenge.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,17 @@ | ||
'use strict'; | ||
|
||
/** @type {import('sequelize-cli').Migration} */ | ||
module.exports = { | ||
async up(queryInterface, Sequelize) { | ||
await queryInterface.addColumn('userChallenge', 'type', { | ||
type: Sequelize.TEXT, | ||
allowNull: true, | ||
unique: false, | ||
defaultValue: null, | ||
}); | ||
}, | ||
|
||
async down(queryInterface, Sequelize) { | ||
await queryInterface.removeColumn('userChallenge', 'type'); | ||
}, | ||
}; |
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,3 @@ | ||
import { ChallengeType } from './types'; | ||
|
||
export const ChallengeTypeValues = Object.values(ChallengeType); |
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,2 @@ | ||
export * from './types'; | ||
export * from './constants'; |
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,8 @@ | ||
export enum ChallengeType { | ||
Sport = 'SPORT', | ||
Language = 'LANGUAGE', | ||
Sugar = 'SUGAR', | ||
Water = 'WATER', | ||
Sleep = 'SLEEP', | ||
Other = 'OTHER', | ||
} |