Skip to content

Commit b49dd82

Browse files
committed
Enhanced Organization and Skill models with new attributes; also added more metadata and relations to support these changes. Updated migration scripts to reflect new database schema modifications.
Took 1 minute
1 parent decc99d commit b49dd82

File tree

16 files changed

+1144
-42
lines changed

16 files changed

+1144
-42
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
-- CreateTable
2+
CREATE TABLE "Grant" (
3+
"id" TEXT NOT NULL,
4+
"title" TEXT NOT NULL,
5+
"description" TEXT NOT NULL,
6+
"funder" TEXT NOT NULL,
7+
"eligibility" TEXT NOT NULL,
8+
"amount" TEXT NOT NULL,
9+
"deadline" TIMESTAMP(3) NOT NULL,
10+
"focusAreas" TEXT[],
11+
"applicationProcess" TEXT NOT NULL,
12+
"requirements" TEXT[],
13+
"url" TEXT NOT NULL,
14+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
15+
"updatedAt" TIMESTAMP(3) NOT NULL,
16+
"deletedAt" TIMESTAMP(3),
17+
18+
CONSTRAINT "Grant_pkey" PRIMARY KEY ("id")
19+
);
20+
21+
-- CreateTable
22+
CREATE TABLE "GrantProposal" (
23+
"id" TEXT NOT NULL,
24+
"title" TEXT NOT NULL,
25+
"executiveSummary" TEXT NOT NULL,
26+
"organizationBackground" TEXT NOT NULL,
27+
"projectDescription" TEXT NOT NULL,
28+
"goals" TEXT[],
29+
"methodology" TEXT NOT NULL,
30+
"timeline" TEXT NOT NULL,
31+
"budget" TEXT NOT NULL,
32+
"evaluation" TEXT NOT NULL,
33+
"sustainability" TEXT NOT NULL,
34+
"conclusion" TEXT NOT NULL,
35+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
36+
"updatedAt" TIMESTAMP(3) NOT NULL,
37+
"organizationId" TEXT NOT NULL,
38+
"grantId" TEXT,
39+
40+
CONSTRAINT "GrantProposal_pkey" PRIMARY KEY ("id")
41+
);
42+
43+
-- CreateIndex
44+
CREATE INDEX "GrantProposal_organizationId_idx" ON "GrantProposal"("organizationId");
45+
46+
-- CreateIndex
47+
CREATE INDEX "GrantProposal_grantId_idx" ON "GrantProposal"("grantId");
48+
49+
-- AddForeignKey
50+
ALTER TABLE "GrantProposal" ADD CONSTRAINT "GrantProposal_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
51+
52+
-- AddForeignKey
53+
ALTER TABLE "GrantProposal" ADD CONSTRAINT "GrantProposal_grantId_fkey" FOREIGN KEY ("grantId") REFERENCES "Grant"("id") ON DELETE SET NULL ON UPDATE CASCADE;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
-- CreateTable
2+
CREATE TABLE "OrganizationSkill" (
3+
"id" TEXT NOT NULL,
4+
"organizationId" TEXT NOT NULL,
5+
"skillId" TEXT NOT NULL,
6+
7+
CONSTRAINT "OrganizationSkill_pkey" PRIMARY KEY ("id")
8+
);
9+
10+
-- CreateIndex
11+
CREATE UNIQUE INDEX "OrganizationSkill_organizationId_skillId_key" ON "OrganizationSkill"("organizationId", "skillId");
12+
13+
-- AddForeignKey
14+
ALTER TABLE "OrganizationSkill" ADD CONSTRAINT "OrganizationSkill_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
15+
16+
-- AddForeignKey
17+
ALTER TABLE "OrganizationSkill" ADD CONSTRAINT "OrganizationSkill_skillId_fkey" FOREIGN KEY ("skillId") REFERENCES "Skill"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
-- AlterTable
2+
ALTER TABLE "Grant" ALTER COLUMN "description" DROP NOT NULL,
3+
ALTER COLUMN "eligibility" DROP NOT NULL,
4+
ALTER COLUMN "amount" DROP NOT NULL,
5+
ALTER COLUMN "deadline" DROP NOT NULL,
6+
ALTER COLUMN "applicationProcess" DROP NOT NULL,
7+
ALTER COLUMN "url" DROP NOT NULL;
8+
9+
-- CreateTable
10+
CREATE TABLE "GrantSkill" (
11+
"id" TEXT NOT NULL,
12+
"grantId" TEXT NOT NULL,
13+
"skillId" TEXT NOT NULL,
14+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
15+
"updatedAt" TIMESTAMP(3) NOT NULL,
16+
17+
CONSTRAINT "GrantSkill_pkey" PRIMARY KEY ("id")
18+
);
19+
20+
-- CreateIndex
21+
CREATE UNIQUE INDEX "GrantSkill_grantId_skillId_key" ON "GrantSkill"("grantId", "skillId");
22+
23+
-- AddForeignKey
24+
ALTER TABLE "GrantSkill" ADD CONSTRAINT "GrantSkill_grantId_fkey" FOREIGN KEY ("grantId") REFERENCES "Grant"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
25+
26+
-- AddForeignKey
27+
ALTER TABLE "GrantSkill" ADD CONSTRAINT "GrantSkill_skillId_fkey" FOREIGN KEY ("skillId") REFERENCES "Skill"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
Warnings:
3+
4+
- A unique constraint covering the columns `[title]` on the table `Grant` will be added. If there are existing duplicate values, this will fail.
5+
- A unique constraint covering the columns `[url]` on the table `Grant` will be added. If there are existing duplicate values, this will fail.
6+
7+
*/
8+
-- CreateIndex
9+
CREATE UNIQUE INDEX "Grant_title_key" ON "Grant"("title");
10+
11+
-- CreateIndex
12+
CREATE UNIQUE INDEX "Grant_url_key" ON "Grant"("url");
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
Warnings:
3+
4+
- A unique constraint covering the columns `[name]` on the table `Organization` will be added. If there are existing duplicate values, this will fail.
5+
- A unique constraint covering the columns `[url]` on the table `Organization` will be added. If there are existing duplicate values, this will fail.
6+
7+
*/
8+
-- CreateIndex
9+
CREATE UNIQUE INDEX "Organization_name_key" ON "Organization"("name");
10+
11+
-- CreateIndex
12+
CREATE UNIQUE INDEX "Organization_url_key" ON "Organization"("url");
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/*
2+
Warnings:
3+
4+
- Made the column `url` on table `Organization` required. This step will fail if there are existing NULL values in that column.
5+
6+
*/
7+
-- AlterTable
8+
ALTER TABLE "Organization" ADD COLUMN "alternateUrls" TEXT[],
9+
ALTER COLUMN "url" SET NOT NULL;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-- DropForeignKey
2+
ALTER TABLE "OrganizationSkill" DROP CONSTRAINT "OrganizationSkill_organizationId_fkey";
3+
4+
-- AddForeignKey
5+
ALTER TABLE "OrganizationSkill" ADD CONSTRAINT "OrganizationSkill_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE CASCADE ON UPDATE CASCADE;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
Warnings:
3+
4+
- A unique constraint covering the columns `[grantId,organizationId]` on the table `GrantProposal` will be added. If there are existing duplicate values, this will fail.
5+
6+
*/
7+
-- AlterTable
8+
ALTER TABLE "Grant" ADD COLUMN "contactEmail" TEXT;
9+
10+
-- CreateIndex
11+
CREATE UNIQUE INDEX "GrantProposal_grantId_organizationId_key" ON "GrantProposal"("grantId", "organizationId");
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
-- CreateEnum
2+
CREATE TYPE "ProposalStatus" AS ENUM ('DRAFT', 'SUBMITTED', 'UNDER_REVIEW', 'APPROVED', 'REJECTED');
3+
4+
-- AlterTable
5+
ALTER TABLE "GrantProposal" ADD COLUMN "status" "ProposalStatus" NOT NULL DEFAULT 'DRAFT';
6+
7+
-- AlterTable
8+
ALTER TABLE "Organization" ADD COLUMN "ownerId" TEXT;
9+
10+
-- AddForeignKey
11+
ALTER TABLE "Organization" ADD CONSTRAINT "Organization_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
/*
2+
Warnings:
3+
4+
- A unique constraint covering the columns `[slug]` on the table `Organization` will be added. If there are existing duplicate values, this will fail.
5+
- A unique constraint covering the columns `[email]` on the table `Organization` will be added. If there are existing duplicate values, this will fail.
6+
- A unique constraint covering the columns `[telephone]` on the table `Organization` will be added. If there are existing duplicate values, this will fail.
7+
- A unique constraint covering the columns `[linkedinUrl]` on the table `Organization` will be added. If there are existing duplicate values, this will fail.
8+
- A unique constraint covering the columns `[twitterHandle]` on the table `Organization` will be added. If there are existing duplicate values, this will fail.
9+
- A unique constraint covering the columns `[facebookPage]` on the table `Organization` will be added. If there are existing duplicate values, this will fail.
10+
- A unique constraint covering the columns `[instagramHandle]` on the table `Organization` will be added. If there are existing duplicate values, this will fail.
11+
- A unique constraint covering the columns `[youtubeChannel]` on the table `Organization` will be added. If there are existing duplicate values, this will fail.
12+
- A unique constraint covering the columns `[stockSymbol]` on the table `Organization` will be added. If there are existing duplicate values, this will fail.
13+
- A unique constraint covering the columns `[name,foundedYear]` on the table `Organization` will be added. If there are existing duplicate values, this will fail.
14+
15+
*/
16+
-- CreateEnum
17+
CREATE TYPE "CompanySize" AS ENUM ('STARTUP', 'SMALL', 'MEDIUM', 'LARGE', 'ENTERPRISE');
18+
19+
-- CreateEnum
20+
CREATE TYPE "CompanyType" AS ENUM ('PUBLIC', 'PRIVATE', 'NONPROFIT', 'GOVERNMENT', 'EDUCATIONAL');
21+
22+
-- AlterTable
23+
ALTER TABLE "Organization" ADD COLUMN "companySize" "CompanySize",
24+
ADD COLUMN "companyType" "CompanyType",
25+
ADD COLUMN "employeeCount" INTEGER,
26+
ADD COLUMN "facebookPage" TEXT,
27+
ADD COLUMN "foundedYear" INTEGER,
28+
ADD COLUMN "headquartersLocation" TEXT,
29+
ADD COLUMN "industry" TEXT,
30+
ADD COLUMN "instagramHandle" TEXT,
31+
ADD COLUMN "linkedinUrl" TEXT,
32+
ADD COLUMN "mission" TEXT,
33+
ADD COLUMN "publiclyTraded" BOOLEAN DEFAULT false,
34+
ADD COLUMN "revenue" TEXT,
35+
ADD COLUMN "slug" TEXT,
36+
ADD COLUMN "specialties" TEXT[],
37+
ADD COLUMN "stockSymbol" TEXT,
38+
ADD COLUMN "tagline" TEXT,
39+
ADD COLUMN "twitterHandle" TEXT,
40+
ADD COLUMN "youtubeChannel" TEXT,
41+
ALTER COLUMN "url" DROP NOT NULL;
42+
43+
-- CreateTable
44+
CREATE TABLE "OrganizationLocation" (
45+
"id" TEXT NOT NULL,
46+
"organizationId" TEXT NOT NULL,
47+
"address" TEXT NOT NULL,
48+
"city" TEXT NOT NULL,
49+
"state" TEXT,
50+
"country" TEXT NOT NULL,
51+
"isHeadquarters" BOOLEAN NOT NULL DEFAULT false,
52+
53+
CONSTRAINT "OrganizationLocation_pkey" PRIMARY KEY ("id")
54+
);
55+
56+
-- CreateTable
57+
CREATE TABLE "OrganizationFollower" (
58+
"id" TEXT NOT NULL,
59+
"organizationId" TEXT NOT NULL,
60+
"userId" TEXT NOT NULL,
61+
"followedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
62+
63+
CONSTRAINT "OrganizationFollower_pkey" PRIMARY KEY ("id")
64+
);
65+
66+
-- CreateTable
67+
CREATE TABLE "Product" (
68+
"id" TEXT NOT NULL,
69+
"name" TEXT NOT NULL,
70+
"description" TEXT,
71+
"price" DOUBLE PRECISION NOT NULL,
72+
"currency" TEXT NOT NULL,
73+
"available" BOOLEAN NOT NULL DEFAULT true,
74+
"referralUrl" TEXT,
75+
"organizationId" TEXT NOT NULL,
76+
77+
CONSTRAINT "Product_pkey" PRIMARY KEY ("id")
78+
);
79+
80+
-- CreateTable
81+
CREATE TABLE "Service" (
82+
"id" TEXT NOT NULL,
83+
"name" TEXT NOT NULL,
84+
"description" TEXT,
85+
"price" DOUBLE PRECISION NOT NULL,
86+
"currency" TEXT NOT NULL,
87+
"available" BOOLEAN NOT NULL DEFAULT true,
88+
"referralUrl" TEXT,
89+
"organizationId" TEXT NOT NULL,
90+
91+
CONSTRAINT "Service_pkey" PRIMARY KEY ("id")
92+
);
93+
94+
-- CreateTable
95+
CREATE TABLE "Event" (
96+
"id" TEXT NOT NULL,
97+
"name" TEXT NOT NULL,
98+
"description" TEXT,
99+
"startDate" TIMESTAMP(3) NOT NULL,
100+
"endDate" TIMESTAMP(3),
101+
"location" TEXT,
102+
"organizationId" TEXT NOT NULL,
103+
"url" TEXT,
104+
"isOnline" BOOLEAN NOT NULL DEFAULT false,
105+
"maxParticipants" INTEGER,
106+
"registrationRequired" BOOLEAN NOT NULL DEFAULT false,
107+
"registrationUrl" TEXT,
108+
109+
CONSTRAINT "Event_pkey" PRIMARY KEY ("id")
110+
);
111+
112+
-- CreateTable
113+
CREATE TABLE "Partnership" (
114+
"id" TEXT NOT NULL,
115+
"partnerName" TEXT NOT NULL,
116+
"description" TEXT,
117+
"startDate" TIMESTAMP(3) NOT NULL,
118+
"endDate" TIMESTAMP(3),
119+
"organizationId" TEXT NOT NULL,
120+
121+
CONSTRAINT "Partnership_pkey" PRIMARY KEY ("id")
122+
);
123+
124+
-- CreateIndex
125+
CREATE UNIQUE INDEX "OrganizationFollower_organizationId_userId_key" ON "OrganizationFollower"("organizationId", "userId");
126+
127+
-- CreateIndex
128+
CREATE UNIQUE INDEX "Product_name_organizationId_key" ON "Product"("name", "organizationId");
129+
130+
-- CreateIndex
131+
CREATE UNIQUE INDEX "Service_name_organizationId_key" ON "Service"("name", "organizationId");
132+
133+
-- CreateIndex
134+
CREATE UNIQUE INDEX "Event_name_organizationId_startDate_key" ON "Event"("name", "organizationId", "startDate");
135+
136+
-- CreateIndex
137+
CREATE UNIQUE INDEX "Partnership_partnerName_organizationId_startDate_key" ON "Partnership"("partnerName", "organizationId", "startDate");
138+
139+
-- CreateIndex
140+
CREATE UNIQUE INDEX "Organization_slug_key" ON "Organization"("slug");
141+
142+
-- CreateIndex
143+
CREATE UNIQUE INDEX "Organization_email_key" ON "Organization"("email");
144+
145+
-- CreateIndex
146+
CREATE UNIQUE INDEX "Organization_telephone_key" ON "Organization"("telephone");
147+
148+
-- CreateIndex
149+
CREATE UNIQUE INDEX "Organization_linkedinUrl_key" ON "Organization"("linkedinUrl");
150+
151+
-- CreateIndex
152+
CREATE UNIQUE INDEX "Organization_twitterHandle_key" ON "Organization"("twitterHandle");
153+
154+
-- CreateIndex
155+
CREATE UNIQUE INDEX "Organization_facebookPage_key" ON "Organization"("facebookPage");
156+
157+
-- CreateIndex
158+
CREATE UNIQUE INDEX "Organization_instagramHandle_key" ON "Organization"("instagramHandle");
159+
160+
-- CreateIndex
161+
CREATE UNIQUE INDEX "Organization_youtubeChannel_key" ON "Organization"("youtubeChannel");
162+
163+
-- CreateIndex
164+
CREATE UNIQUE INDEX "Organization_stockSymbol_key" ON "Organization"("stockSymbol");
165+
166+
-- CreateIndex
167+
CREATE UNIQUE INDEX "Organization_name_foundedYear_key" ON "Organization"("name", "foundedYear");
168+
169+
-- AddForeignKey
170+
ALTER TABLE "OrganizationLocation" ADD CONSTRAINT "OrganizationLocation_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
171+
172+
-- AddForeignKey
173+
ALTER TABLE "OrganizationFollower" ADD CONSTRAINT "OrganizationFollower_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
174+
175+
-- AddForeignKey
176+
ALTER TABLE "OrganizationFollower" ADD CONSTRAINT "OrganizationFollower_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
177+
178+
-- AddForeignKey
179+
ALTER TABLE "Product" ADD CONSTRAINT "Product_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
180+
181+
-- AddForeignKey
182+
ALTER TABLE "Service" ADD CONSTRAINT "Service_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
183+
184+
-- AddForeignKey
185+
ALTER TABLE "Event" ADD CONSTRAINT "Event_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
186+
187+
-- AddForeignKey
188+
ALTER TABLE "Partnership" ADD CONSTRAINT "Partnership_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

0 commit comments

Comments
 (0)