-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a script to create new organizations, agencies, and users (#279)
* fix: ensures db initializes when script is run * feat: add ability to onboard new organizations * feat: add helper functions to create orgs, agencies, users * chore: add comments * feat: add test coverage to agency creation * feat: adds test coverage to get or create org * feat: adds test coverage for user get or create * fix: ensure upload form is not reliant on organization foreign key to reporting period * feat: add ability to create reporting periods and tie to orgs * fix: linting * chore: make reportingPeriod.organizationId optional in order to phase it out * feat: adds support for creating reporting period and templates * fix: linting * chore: add logging
- Loading branch information
Showing
25 changed files
with
737 additions
and
42 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
api/db/migrations/20240522032556_make_org_id_optional/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,8 @@ | ||
-- DropForeignKey | ||
ALTER TABLE "ReportingPeriod" DROP CONSTRAINT "ReportingPeriod_organizationId_fkey"; | ||
|
||
-- AlterTable | ||
ALTER TABLE "ReportingPeriod" ALTER COLUMN "organizationId" DROP NOT NULL; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "ReportingPeriod" ADD CONSTRAINT "ReportingPeriod_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE SET NULL 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,44 @@ | ||
import type { Prisma, agency } from '@prisma/client' | ||
import type { Prisma } from '@prisma/client' | ||
|
||
import type { ScenarioData } from '@redwoodjs/testing/api' | ||
|
||
export const standard = defineScenario<Prisma.agencyCreateArgs>({ | ||
export const standard = defineScenario< | ||
Prisma.OrganizationCreateArgs | Prisma.AgencyCreateArgs | ||
>({ | ||
organization: { | ||
one: { | ||
data: { | ||
name: 'USDR', | ||
}, | ||
}, | ||
two: { | ||
data: { | ||
name: 'Example Organization', | ||
}, | ||
}, | ||
}, | ||
agency: { | ||
one: { data: { name: 'String', code: 'String' } }, | ||
two: { data: { name: 'String', code: 'String' } }, | ||
one: (scenario) => ({ | ||
data: { | ||
name: 'Agency1', | ||
organizationId: scenario.organization.one.id, | ||
code: 'A1', | ||
}, | ||
include: { | ||
organization: true, | ||
}, | ||
}), | ||
two: (scenario) => ({ | ||
data: { | ||
name: 'Agency2', | ||
organizationId: scenario.organization.two.id, | ||
code: 'A2', | ||
}, | ||
include: { | ||
organization: true, | ||
}, | ||
}), | ||
}, | ||
}) | ||
|
||
export type StandardScenario = ScenarioData<agency, 'agency'> | ||
export type StandardScenario = ScenarioData<Organization, 'organization'> & | ||
ScenarioData<Agency, 'agency'> |
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
Oops, something went wrong.