-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CPF-103 Update User model #111
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0985d8f
CPF-103 remove validated, invalidated and subrecipients relations fro…
Vikariusu 76f6d57
CPF-103 update seed script to include 1 test organization, 1 agency a…
Vikariusu a39b3d0
CPF-103 remove organizationId from api inputs
Vikariusu 132a77e
CPF-103 fix tests to include required fields for User model
Vikariusu 20be4e6
CPF-103 add 'unique' field attribute to user email
Vikariusu 31dfe0d
CPF-103 use unique emails for testing
Vikariusu 51da664
Merge branch 'main' into feature/CPF-103-update-user-model
as1729 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
...db/migrations/20240214193745_remove_user_validation_subrecipients_relations/migration.sql
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 @@ | ||
/* | ||
Warnings: | ||
|
||
- You are about to drop the column `certifiedById` on the `Subrecipient` table. All the data in the column will be lost. | ||
- You are about to drop the column `invalidatedById` on the `UploadValidation` table. All the data in the column will be lost. | ||
- You are about to drop the column `validatedById` on the `UploadValidation` table. All the data in the column will be lost. | ||
- You are about to drop the column `organizationId` on the `User` table. All the data in the column will be lost. | ||
- Made the column `name` on table `User` required. This step will fail if there are existing NULL values in that column. | ||
- Made the column `agencyId` on table `User` required. This step will fail if there are existing NULL values in that column. | ||
- Made the column `role` on table `User` required. This step will fail if there are existing NULL values in that column. | ||
|
||
*/ | ||
-- DropForeignKey | ||
ALTER TABLE "Subrecipient" DROP CONSTRAINT "Subrecipient_certifiedById_fkey"; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "UploadValidation" DROP CONSTRAINT "UploadValidation_invalidatedById_fkey"; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "UploadValidation" DROP CONSTRAINT "UploadValidation_validatedById_fkey"; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "User" DROP CONSTRAINT "User_agencyId_fkey"; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "User" DROP CONSTRAINT "User_organizationId_fkey"; | ||
|
||
-- AlterTable | ||
ALTER TABLE "Subrecipient" DROP COLUMN "certifiedById"; | ||
|
||
-- AlterTable | ||
ALTER TABLE "UploadValidation" DROP COLUMN "invalidatedById", | ||
DROP COLUMN "validatedById"; | ||
|
||
-- AlterTable | ||
ALTER TABLE "User" DROP COLUMN "organizationId", | ||
ADD COLUMN "isActive" BOOLEAN NOT NULL DEFAULT true, | ||
ALTER COLUMN "name" SET NOT NULL, | ||
ALTER COLUMN "agencyId" SET NOT NULL, | ||
ALTER COLUMN "role" SET NOT NULL; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "User" ADD CONSTRAINT "User_agencyId_fkey" FOREIGN KEY ("agencyId") REFERENCES "Agency"("id") ON DELETE RESTRICT ON UPDATE CASCADE; |
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
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 |
---|---|---|
|
@@ -25,7 +25,6 @@ describe('users', () => { | |
scenario('creates a user', async (scenario: StandardScenario) => { | ||
mockCurrentUser({ | ||
id: scenario.user.one.id, | ||
organizationId: scenario.user.one.organizationId, | ||
email: '[email protected]', | ||
roles: ['USDR_ADMIN'], | ||
}) | ||
|
@@ -40,7 +39,6 @@ describe('users', () => { | |
}) | ||
|
||
expect(result.email).toEqual(scenario.user.one.email) | ||
expect(result.organizationId).toEqual(scenario.organization.one.id) | ||
}) | ||
|
||
scenario('updates a user', async (scenario: StandardScenario) => { | ||
|
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 |
---|---|---|
|
@@ -8,6 +8,46 @@ export default async () => { | |
// Seeds automatically with `yarn rw prisma migrate dev` and `yarn rw prisma migrate reset` | ||
// | ||
|
||
const organization: Prisma.OrganizationCreateArgs['data'] = | ||
await db.organization.create({ | ||
data: { | ||
name: 'Example Organization', | ||
}, | ||
}) | ||
|
||
const agency: Prisma.AgencyCreateArgs['data'] = await db.agency.create({ | ||
data: { | ||
name: 'Example Agency', | ||
code: 'EA', | ||
organizationId: organization.id, | ||
}, | ||
}) | ||
|
||
const users: Prisma.UserCreateManyInput[] = [ | ||
{ | ||
email: '[email protected]', | ||
name: 'Organization Staff', | ||
role: 'ORGANIZATION_STAFF', | ||
agencyId: agency.id, | ||
}, | ||
{ | ||
email: '[email protected]', | ||
name: 'Organization Admin', | ||
role: 'ORGANIZATION_ADMIN', | ||
agencyId: agency.id, | ||
}, | ||
{ | ||
email: '[email protected]', | ||
name: 'USDR Admin', | ||
role: 'USDR_ADMIN', | ||
agencyId: agency.id, | ||
}, | ||
] | ||
|
||
await db.user.createMany({ | ||
data: users, | ||
}) | ||
|
||
const inputTemplates: Prisma.InputTemplateCreateArgs['data'][] = [ | ||
{ | ||
name: 'Input Template 1', | ||
|
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 |
---|---|---|
|
@@ -11,7 +11,6 @@ export const QUERY = gql` | |
name | ||
agencyId | ||
organizationId | ||
role | ||
createdAt | ||
updatedAt | ||
|
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 |
---|---|---|
|
@@ -14,7 +14,6 @@ export const QUERY = gql` | |
agency { | ||
name | ||
} | ||
organizationId | ||
role | ||
createdAt | ||
updatedAt | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: Do we want to implement email validation when calling create/update user or is there a way to enforce it here? Also, do we want to use
unique
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, we would like to use unique here as well 👍 =1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done ✅