Skip to content

Commit

Permalink
Enhanced Organization and Skill models with new attributes; also adde…
Browse files Browse the repository at this point in the history
…d more metadata and relations to support these changes. Updated migration scripts to reflect new database schema modifications.

Took 1 minute
  • Loading branch information
mikepsinn committed Nov 18, 2024
1 parent decc99d commit b49dd82
Show file tree
Hide file tree
Showing 16 changed files with 1,144 additions and 42 deletions.
53 changes: 53 additions & 0 deletions prisma/migrations/20241019000344_grant_stuff/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
-- CreateTable
CREATE TABLE "Grant" (
"id" TEXT NOT NULL,
"title" TEXT NOT NULL,
"description" TEXT NOT NULL,
"funder" TEXT NOT NULL,
"eligibility" TEXT NOT NULL,
"amount" TEXT NOT NULL,
"deadline" TIMESTAMP(3) NOT NULL,
"focusAreas" TEXT[],
"applicationProcess" TEXT NOT NULL,
"requirements" TEXT[],
"url" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"deletedAt" TIMESTAMP(3),

CONSTRAINT "Grant_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "GrantProposal" (
"id" TEXT NOT NULL,
"title" TEXT NOT NULL,
"executiveSummary" TEXT NOT NULL,
"organizationBackground" TEXT NOT NULL,
"projectDescription" TEXT NOT NULL,
"goals" TEXT[],
"methodology" TEXT NOT NULL,
"timeline" TEXT NOT NULL,
"budget" TEXT NOT NULL,
"evaluation" TEXT NOT NULL,
"sustainability" TEXT NOT NULL,
"conclusion" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"organizationId" TEXT NOT NULL,
"grantId" TEXT,

CONSTRAINT "GrantProposal_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE INDEX "GrantProposal_organizationId_idx" ON "GrantProposal"("organizationId");

-- CreateIndex
CREATE INDEX "GrantProposal_grantId_idx" ON "GrantProposal"("grantId");

-- AddForeignKey
ALTER TABLE "GrantProposal" ADD CONSTRAINT "GrantProposal_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "GrantProposal" ADD CONSTRAINT "GrantProposal_grantId_fkey" FOREIGN KEY ("grantId") REFERENCES "Grant"("id") ON DELETE SET NULL ON UPDATE CASCADE;
17 changes: 17 additions & 0 deletions prisma/migrations/20241019190808_organization_skills/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
-- CreateTable
CREATE TABLE "OrganizationSkill" (
"id" TEXT NOT NULL,
"organizationId" TEXT NOT NULL,
"skillId" TEXT NOT NULL,

CONSTRAINT "OrganizationSkill_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "OrganizationSkill_organizationId_skillId_key" ON "OrganizationSkill"("organizationId", "skillId");

-- AddForeignKey
ALTER TABLE "OrganizationSkill" ADD CONSTRAINT "OrganizationSkill_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "OrganizationSkill" ADD CONSTRAINT "OrganizationSkill_skillId_fkey" FOREIGN KEY ("skillId") REFERENCES "Skill"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
27 changes: 27 additions & 0 deletions prisma/migrations/20241019201838_grant_skills/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
-- AlterTable
ALTER TABLE "Grant" ALTER COLUMN "description" DROP NOT NULL,
ALTER COLUMN "eligibility" DROP NOT NULL,
ALTER COLUMN "amount" DROP NOT NULL,
ALTER COLUMN "deadline" DROP NOT NULL,
ALTER COLUMN "applicationProcess" DROP NOT NULL,
ALTER COLUMN "url" DROP NOT NULL;

-- CreateTable
CREATE TABLE "GrantSkill" (
"id" TEXT NOT NULL,
"grantId" TEXT NOT NULL,
"skillId" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,

CONSTRAINT "GrantSkill_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "GrantSkill_grantId_skillId_key" ON "GrantSkill"("grantId", "skillId");

-- AddForeignKey
ALTER TABLE "GrantSkill" ADD CONSTRAINT "GrantSkill_grantId_fkey" FOREIGN KEY ("grantId") REFERENCES "Grant"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "GrantSkill" ADD CONSTRAINT "GrantSkill_skillId_fkey" FOREIGN KEY ("skillId") REFERENCES "Skill"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
12 changes: 12 additions & 0 deletions prisma/migrations/20241019212213_unique_grants/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
Warnings:
- A unique constraint covering the columns `[title]` on the table `Grant` will be added. If there are existing duplicate values, this will fail.
- A unique constraint covering the columns `[url]` on the table `Grant` will be added. If there are existing duplicate values, this will fail.
*/
-- CreateIndex
CREATE UNIQUE INDEX "Grant_title_key" ON "Grant"("title");

-- CreateIndex
CREATE UNIQUE INDEX "Grant_url_key" ON "Grant"("url");
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
Warnings:
- A unique constraint covering the columns `[name]` on the table `Organization` will be added. If there are existing duplicate values, this will fail.
- A unique constraint covering the columns `[url]` on the table `Organization` will be added. If there are existing duplicate values, this will fail.
*/
-- CreateIndex
CREATE UNIQUE INDEX "Organization_name_key" ON "Organization"("name");

-- CreateIndex
CREATE UNIQUE INDEX "Organization_url_key" ON "Organization"("url");
9 changes: 9 additions & 0 deletions prisma/migrations/20241019233905_org_urls/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
Warnings:
- Made the column `url` on table `Organization` required. This step will fail if there are existing NULL values in that column.
*/
-- AlterTable
ALTER TABLE "Organization" ADD COLUMN "alternateUrls" TEXT[],
ALTER COLUMN "url" SET NOT NULL;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- DropForeignKey
ALTER TABLE "OrganizationSkill" DROP CONSTRAINT "OrganizationSkill_organizationId_fkey";

-- AddForeignKey
ALTER TABLE "OrganizationSkill" ADD CONSTRAINT "OrganizationSkill_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE CASCADE ON UPDATE CASCADE;
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
Warnings:
- A unique constraint covering the columns `[grantId,organizationId]` on the table `GrantProposal` will be added. If there are existing duplicate values, this will fail.
*/
-- AlterTable
ALTER TABLE "Grant" ADD COLUMN "contactEmail" TEXT;

-- CreateIndex
CREATE UNIQUE INDEX "GrantProposal_grantId_organizationId_key" ON "GrantProposal"("grantId", "organizationId");
11 changes: 11 additions & 0 deletions prisma/migrations/20241021221101_organization_owner/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-- CreateEnum
CREATE TYPE "ProposalStatus" AS ENUM ('DRAFT', 'SUBMITTED', 'UNDER_REVIEW', 'APPROVED', 'REJECTED');

-- AlterTable
ALTER TABLE "GrantProposal" ADD COLUMN "status" "ProposalStatus" NOT NULL DEFAULT 'DRAFT';

-- AlterTable
ALTER TABLE "Organization" ADD COLUMN "ownerId" TEXT;

-- AddForeignKey
ALTER TABLE "Organization" ADD CONSTRAINT "Organization_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
188 changes: 188 additions & 0 deletions prisma/migrations/20241022001746_organization_stuff/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
/*
Warnings:
- A unique constraint covering the columns `[slug]` on the table `Organization` will be added. If there are existing duplicate values, this will fail.
- A unique constraint covering the columns `[email]` on the table `Organization` will be added. If there are existing duplicate values, this will fail.
- A unique constraint covering the columns `[telephone]` on the table `Organization` will be added. If there are existing duplicate values, this will fail.
- A unique constraint covering the columns `[linkedinUrl]` on the table `Organization` will be added. If there are existing duplicate values, this will fail.
- A unique constraint covering the columns `[twitterHandle]` on the table `Organization` will be added. If there are existing duplicate values, this will fail.
- A unique constraint covering the columns `[facebookPage]` on the table `Organization` will be added. If there are existing duplicate values, this will fail.
- A unique constraint covering the columns `[instagramHandle]` on the table `Organization` will be added. If there are existing duplicate values, this will fail.
- A unique constraint covering the columns `[youtubeChannel]` on the table `Organization` will be added. If there are existing duplicate values, this will fail.
- A unique constraint covering the columns `[stockSymbol]` on the table `Organization` will be added. If there are existing duplicate values, this will fail.
- A unique constraint covering the columns `[name,foundedYear]` on the table `Organization` will be added. If there are existing duplicate values, this will fail.
*/
-- CreateEnum
CREATE TYPE "CompanySize" AS ENUM ('STARTUP', 'SMALL', 'MEDIUM', 'LARGE', 'ENTERPRISE');

-- CreateEnum
CREATE TYPE "CompanyType" AS ENUM ('PUBLIC', 'PRIVATE', 'NONPROFIT', 'GOVERNMENT', 'EDUCATIONAL');

-- AlterTable
ALTER TABLE "Organization" ADD COLUMN "companySize" "CompanySize",
ADD COLUMN "companyType" "CompanyType",
ADD COLUMN "employeeCount" INTEGER,
ADD COLUMN "facebookPage" TEXT,
ADD COLUMN "foundedYear" INTEGER,
ADD COLUMN "headquartersLocation" TEXT,
ADD COLUMN "industry" TEXT,
ADD COLUMN "instagramHandle" TEXT,
ADD COLUMN "linkedinUrl" TEXT,
ADD COLUMN "mission" TEXT,
ADD COLUMN "publiclyTraded" BOOLEAN DEFAULT false,
ADD COLUMN "revenue" TEXT,
ADD COLUMN "slug" TEXT,
ADD COLUMN "specialties" TEXT[],
ADD COLUMN "stockSymbol" TEXT,
ADD COLUMN "tagline" TEXT,
ADD COLUMN "twitterHandle" TEXT,
ADD COLUMN "youtubeChannel" TEXT,
ALTER COLUMN "url" DROP NOT NULL;

-- CreateTable
CREATE TABLE "OrganizationLocation" (
"id" TEXT NOT NULL,
"organizationId" TEXT NOT NULL,
"address" TEXT NOT NULL,
"city" TEXT NOT NULL,
"state" TEXT,
"country" TEXT NOT NULL,
"isHeadquarters" BOOLEAN NOT NULL DEFAULT false,

CONSTRAINT "OrganizationLocation_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "OrganizationFollower" (
"id" TEXT NOT NULL,
"organizationId" TEXT NOT NULL,
"userId" TEXT NOT NULL,
"followedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

CONSTRAINT "OrganizationFollower_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Product" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL,
"description" TEXT,
"price" DOUBLE PRECISION NOT NULL,
"currency" TEXT NOT NULL,
"available" BOOLEAN NOT NULL DEFAULT true,
"referralUrl" TEXT,
"organizationId" TEXT NOT NULL,

CONSTRAINT "Product_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Service" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL,
"description" TEXT,
"price" DOUBLE PRECISION NOT NULL,
"currency" TEXT NOT NULL,
"available" BOOLEAN NOT NULL DEFAULT true,
"referralUrl" TEXT,
"organizationId" TEXT NOT NULL,

CONSTRAINT "Service_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Event" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL,
"description" TEXT,
"startDate" TIMESTAMP(3) NOT NULL,
"endDate" TIMESTAMP(3),
"location" TEXT,
"organizationId" TEXT NOT NULL,
"url" TEXT,
"isOnline" BOOLEAN NOT NULL DEFAULT false,
"maxParticipants" INTEGER,
"registrationRequired" BOOLEAN NOT NULL DEFAULT false,
"registrationUrl" TEXT,

CONSTRAINT "Event_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Partnership" (
"id" TEXT NOT NULL,
"partnerName" TEXT NOT NULL,
"description" TEXT,
"startDate" TIMESTAMP(3) NOT NULL,
"endDate" TIMESTAMP(3),
"organizationId" TEXT NOT NULL,

CONSTRAINT "Partnership_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "OrganizationFollower_organizationId_userId_key" ON "OrganizationFollower"("organizationId", "userId");

-- CreateIndex
CREATE UNIQUE INDEX "Product_name_organizationId_key" ON "Product"("name", "organizationId");

-- CreateIndex
CREATE UNIQUE INDEX "Service_name_organizationId_key" ON "Service"("name", "organizationId");

-- CreateIndex
CREATE UNIQUE INDEX "Event_name_organizationId_startDate_key" ON "Event"("name", "organizationId", "startDate");

-- CreateIndex
CREATE UNIQUE INDEX "Partnership_partnerName_organizationId_startDate_key" ON "Partnership"("partnerName", "organizationId", "startDate");

-- CreateIndex
CREATE UNIQUE INDEX "Organization_slug_key" ON "Organization"("slug");

-- CreateIndex
CREATE UNIQUE INDEX "Organization_email_key" ON "Organization"("email");

-- CreateIndex
CREATE UNIQUE INDEX "Organization_telephone_key" ON "Organization"("telephone");

-- CreateIndex
CREATE UNIQUE INDEX "Organization_linkedinUrl_key" ON "Organization"("linkedinUrl");

-- CreateIndex
CREATE UNIQUE INDEX "Organization_twitterHandle_key" ON "Organization"("twitterHandle");

-- CreateIndex
CREATE UNIQUE INDEX "Organization_facebookPage_key" ON "Organization"("facebookPage");

-- CreateIndex
CREATE UNIQUE INDEX "Organization_instagramHandle_key" ON "Organization"("instagramHandle");

-- CreateIndex
CREATE UNIQUE INDEX "Organization_youtubeChannel_key" ON "Organization"("youtubeChannel");

-- CreateIndex
CREATE UNIQUE INDEX "Organization_stockSymbol_key" ON "Organization"("stockSymbol");

-- CreateIndex
CREATE UNIQUE INDEX "Organization_name_foundedYear_key" ON "Organization"("name", "foundedYear");

-- AddForeignKey
ALTER TABLE "OrganizationLocation" ADD CONSTRAINT "OrganizationLocation_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "OrganizationFollower" ADD CONSTRAINT "OrganizationFollower_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "OrganizationFollower" ADD CONSTRAINT "OrganizationFollower_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Product" ADD CONSTRAINT "Product_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Service" ADD CONSTRAINT "Service_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Event" ADD CONSTRAINT "Event_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Partnership" ADD CONSTRAINT "Partnership_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
8 changes: 8 additions & 0 deletions prisma/migrations/20241022043930_org_slug/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
Warnings:
- Made the column `slug` on table `Organization` required. This step will fail if there are existing NULL values in that column.
*/
-- AlterTable
ALTER TABLE "Organization" ALTER COLUMN "slug" SET NOT NULL;
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
-- AlterTable
ALTER TABLE "ArticleGenerationOptions" ADD COLUMN "citationStyle" TEXT,
ADD COLUMN "dateRangeEnd" TIMESTAMP(3),
ADD COLUMN "dateRangeStart" TIMESTAMP(3),
ADD COLUMN "estimatedCost" DOUBLE PRECISION,
ADD COLUMN "frequencyPenalty" DOUBLE PRECISION,
ADD COLUMN "generationTimeMs" INTEGER,
ADD COLUMN "includeSummary" BOOLEAN,
ADD COLUMN "languageLevel" TEXT,
ADD COLUMN "maxTokens" INTEGER,
ADD COLUMN "minSourceRank" INTEGER,
ADD COLUMN "modelName" TEXT,
ADD COLUMN "presencePenalty" DOUBLE PRECISION,
ADD COLUMN "qualityScore" DOUBLE PRECISION,
ADD COLUMN "searchStrategy" TEXT,
ADD COLUMN "temperature" DOUBLE PRECISION,
ADD COLUMN "tokenCount" INTEGER,
ADD COLUMN "topP" DOUBLE PRECISION,
ADD COLUMN "wordLimit" INTEGER;
Loading

0 comments on commit b49dd82

Please sign in to comment.