-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(prisma): Add CampaignApplication model (#643)
- issue 1843 - start with adding the required tables in the db model - why separate object - the campaign application will contain sensitive and personal documents that should not be made public - the lifecycle of the CampaignApplication is dictated by a process of ensuring the potential campaign is transparent and legitimate
- Loading branch information
Showing
16 changed files
with
315 additions
and
8 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
apps/api/src/domain/generated/campaignApplication/dto/connect-campaignApplication.dto.ts
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,4 @@ | ||
export class ConnectCampaignApplicationDto { | ||
id?: string | ||
organizerEmail?: string | ||
} |
22 changes: 22 additions & 0 deletions
22
apps/api/src/domain/generated/campaignApplication/dto/create-campaignApplication.dto.ts
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,22 @@ | ||
import { CampaignTypeCategory } from '@prisma/client' | ||
import { ApiProperty } from '@nestjs/swagger' | ||
|
||
export class CreateCampaignApplicationDto { | ||
organizerName: string | ||
organizerEmail?: string | ||
organizerPhone?: string | ||
beneficiary: string | ||
organizerBeneficiaryRel: string | ||
campaignName: string | ||
goal: string | ||
history?: string | ||
amount: string | ||
description?: string | ||
campaignGuarantee?: string | ||
otherFinanceSources?: string | ||
otherNotes?: string | ||
@ApiProperty({ enum: CampaignTypeCategory }) | ||
category?: CampaignTypeCategory | ||
ticketURL?: string | ||
archived?: boolean | ||
} |
3 changes: 3 additions & 0 deletions
3
apps/api/src/domain/generated/campaignApplication/dto/index.ts
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 @@ | ||
export * from './connect-campaignApplication.dto' | ||
export * from './create-campaignApplication.dto' | ||
export * from './update-campaignApplication.dto' |
22 changes: 22 additions & 0 deletions
22
apps/api/src/domain/generated/campaignApplication/dto/update-campaignApplication.dto.ts
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,22 @@ | ||
import { CampaignTypeCategory } from '@prisma/client' | ||
import { ApiProperty } from '@nestjs/swagger' | ||
|
||
export class UpdateCampaignApplicationDto { | ||
organizerName?: string | ||
organizerEmail?: string | ||
organizerPhone?: string | ||
beneficiary?: string | ||
organizerBeneficiaryRel?: string | ||
campaignName?: string | ||
goal?: string | ||
history?: string | ||
amount?: string | ||
description?: string | ||
campaignGuarantee?: string | ||
otherFinanceSources?: string | ||
otherNotes?: string | ||
@ApiProperty({ enum: CampaignTypeCategory }) | ||
category?: CampaignTypeCategory | ||
ticketURL?: string | ||
archived?: boolean | ||
} |
29 changes: 29 additions & 0 deletions
29
apps/api/src/domain/generated/campaignApplication/entities/campaignApplication.entity.ts
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,29 @@ | ||
import { CampaignApplicationState, CampaignTypeCategory } from '@prisma/client' | ||
import { Organizer } from '../../organizer/entities/organizer.entity' | ||
import { CampaignApplicationFile } from '../../campaignApplicationFile/entities/campaignApplicationFile.entity' | ||
|
||
export class CampaignApplication { | ||
id: string | ||
createdAt: Date | ||
updatedAt: Date | null | ||
organizerId: string | null | ||
organizer?: Organizer | null | ||
organizerName: string | ||
organizerEmail: string | null | ||
organizerPhone: string | null | ||
beneficiary: string | ||
organizerBeneficiaryRel: string | ||
campaignName: string | ||
goal: string | ||
history: string | null | ||
amount: string | ||
description: string | null | ||
documents?: CampaignApplicationFile[] | ||
campaignGuarantee: string | null | ||
otherFinanceSources: string | null | ||
otherNotes: string | null | ||
state: CampaignApplicationState | ||
category: CampaignTypeCategory | null | ||
ticketURL: string | null | ||
archived: boolean | null | ||
} |
1 change: 1 addition & 0 deletions
1
apps/api/src/domain/generated/campaignApplication/entities/index.ts
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 @@ | ||
export * from './campaignApplication.entity' |
3 changes: 3 additions & 0 deletions
3
...i/src/domain/generated/campaignApplicationFile/dto/connect-campaignApplicationFile.dto.ts
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 @@ | ||
export class ConnectCampaignApplicationFileDto { | ||
id: string | ||
} |
11 changes: 11 additions & 0 deletions
11
...pi/src/domain/generated/campaignApplicationFile/dto/create-campaignApplicationFile.dto.ts
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,11 @@ | ||
import { CampaignApplicationFileRole } from '@prisma/client' | ||
import { ApiProperty } from '@nestjs/swagger' | ||
|
||
export class CreateCampaignApplicationFileDto { | ||
filename: string | ||
campaignApplicationId: string | ||
personId: string | ||
mimetype: string | ||
@ApiProperty({ enum: CampaignApplicationFileRole }) | ||
role: CampaignApplicationFileRole | ||
} |
3 changes: 3 additions & 0 deletions
3
apps/api/src/domain/generated/campaignApplicationFile/dto/index.ts
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 @@ | ||
export * from './connect-campaignApplicationFile.dto' | ||
export * from './create-campaignApplicationFile.dto' | ||
export * from './update-campaignApplicationFile.dto' |
11 changes: 11 additions & 0 deletions
11
...pi/src/domain/generated/campaignApplicationFile/dto/update-campaignApplicationFile.dto.ts
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,11 @@ | ||
import { CampaignApplicationFileRole } from '@prisma/client' | ||
import { ApiProperty } from '@nestjs/swagger' | ||
|
||
export class UpdateCampaignApplicationFileDto { | ||
filename?: string | ||
campaignApplicationId?: string | ||
personId?: string | ||
mimetype?: string | ||
@ApiProperty({ enum: CampaignApplicationFileRole }) | ||
role?: CampaignApplicationFileRole | ||
} |
12 changes: 12 additions & 0 deletions
12
...i/src/domain/generated/campaignApplicationFile/entities/campaignApplicationFile.entity.ts
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,12 @@ | ||
import { CampaignApplicationFileRole } from '@prisma/client' | ||
import { CampaignApplication } from '../../campaignApplication/entities/campaignApplication.entity' | ||
|
||
export class CampaignApplicationFile { | ||
id: string | ||
filename: string | ||
campaignApplicationId: string | ||
personId: string | ||
mimetype: string | ||
role: CampaignApplicationFileRole | ||
campaignApplication?: CampaignApplication[] | ||
} |
1 change: 1 addition & 0 deletions
1
apps/api/src/domain/generated/campaignApplicationFile/entities/index.ts
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 @@ | ||
export * from './campaignApplicationFile.entity' |
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
68 changes: 68 additions & 0 deletions
68
migrations/20240615135940_add_campaign_application/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,68 @@ | ||
-- CreateEnum | ||
CREATE TYPE "CampaignApplicationState" AS ENUM ('review', 'requestInfo', 'forCommitteeReview', 'approved', 'denied', 'abandoned'); | ||
|
||
-- CreateEnum | ||
CREATE TYPE "CampaignApplicationFileRole" AS ENUM ('document', 'image'); | ||
|
||
-- CreateTable | ||
CREATE TABLE "campaign_applications" ( | ||
"id" UUID NOT NULL DEFAULT gen_random_uuid(), | ||
"created_at" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updated_at" TIMESTAMPTZ(6), | ||
"organizer_id" UUID NOT NULL, | ||
"organizer_name" VARCHAR(200) NOT NULL, | ||
"organizer_email" CITEXT, | ||
"organizer_phone" VARCHAR(50), | ||
"beneficiary" VARCHAR(1500) NOT NULL, | ||
"organizer_beneficiary_relationship" TEXT NOT NULL, | ||
"campaign_name" VARCHAR(200) NOT NULL, | ||
"goal" TEXT NOT NULL, | ||
"history" TEXT, | ||
"amount" VARCHAR(200) NOT NULL, | ||
"description" TEXT, | ||
"campaignGuarantee" VARCHAR(500), | ||
"otherFinanceSources" TEXT, | ||
"otherNotes" TEXT, | ||
"state" "CampaignApplicationState" NOT NULL DEFAULT 'review', | ||
"category" "campaign_type_category" DEFAULT 'others', | ||
"ticketURL" VARCHAR(500), | ||
"archived" BOOLEAN DEFAULT false, | ||
|
||
CONSTRAINT "campaign_applications_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "campaign_application_files" ( | ||
"id" UUID NOT NULL DEFAULT gen_random_uuid(), | ||
"filename" VARCHAR(200) NOT NULL, | ||
"campaign_application_id" UUID NOT NULL, | ||
"person_id" UUID NOT NULL, | ||
"mimetype" VARCHAR(100) NOT NULL, | ||
"role" "CampaignApplicationFileRole" NOT NULL, | ||
|
||
CONSTRAINT "campaign_application_files_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "_CampaignApplicationToCampaignApplicationFile" ( | ||
"A" UUID NOT NULL, | ||
"B" UUID NOT NULL | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "campaign_applications_organizer_email_key" ON "campaign_applications"("organizer_email"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "_CampaignApplicationToCampaignApplicationFile_AB_unique" ON "_CampaignApplicationToCampaignApplicationFile"("A", "B"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "_CampaignApplicationToCampaignApplicationFile_B_index" ON "_CampaignApplicationToCampaignApplicationFile"("B"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "campaign_applications" ADD CONSTRAINT "campaign_applications_organizer_id_fkey" FOREIGN KEY ("organizer_id") REFERENCES "organizers"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "_CampaignApplicationToCampaignApplicationFile" ADD CONSTRAINT "_CampaignApplicationToCampaignApplicationFile_A_fkey" FOREIGN KEY ("A") REFERENCES "campaign_applications"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "_CampaignApplicationToCampaignApplicationFile" ADD CONSTRAINT "_CampaignApplicationToCampaignApplicationFile_B_fkey" FOREIGN KEY ("B") REFERENCES "campaign_application_files"("id") ON DELETE CASCADE 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