-
Notifications
You must be signed in to change notification settings - Fork 423
Improved Vendor Table #153
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
239 changes: 239 additions & 0 deletions
239
packages/db/prisma/migrations/20250319160739_added_vendor_table/migration.sql
This file contains hidden or 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,239 @@ | ||
| /* | ||
| Warnings: | ||
|
|
||
| - A unique constraint covering the columns `[taskId,employeeId]` on the table `VendorTaskAssignment` will be added. If there are existing duplicate values, this will fail. | ||
| - Added the required column `fileUrl` to the `VendorAttachment` table without a default value. This is not possible if the table is not empty. | ||
| - Added the required column `name` to the `VendorAttachment` table without a default value. This is not possible if the table is not empty. | ||
| - Added the required column `ownerId` to the `VendorComment` table without a default value. This is not possible if the table is not empty. | ||
| - Added the required column `updatedAt` to the `VendorComment` table without a default value. This is not possible if the table is not empty. | ||
| - Added the required column `updatedAt` to the `VendorContact` table without a default value. This is not possible if the table is not empty. | ||
| - Added the required column `description` to the `VendorTask` table without a default value. This is not possible if the table is not empty. | ||
| - Added the required column `title` to the `VendorTask` table without a default value. This is not possible if the table is not empty. | ||
| - Added the required column `updatedAt` to the `VendorTask` table without a default value. This is not possible if the table is not empty. | ||
| - Added the required column `employeeId` to the `VendorTaskAssignment` table without a default value. This is not possible if the table is not empty. | ||
| - Added the required column `taskId` to the `VendorTaskAssignment` table without a default value. This is not possible if the table is not empty. | ||
| - Added the required column `fileUrl` to the `VendorTaskAttachment` table without a default value. This is not possible if the table is not empty. | ||
| - Added the required column `name` to the `VendorTaskAttachment` table without a default value. This is not possible if the table is not empty. | ||
| - Added the required column `taskId` to the `VendorTaskAttachment` table without a default value. This is not possible if the table is not empty. | ||
| - Added the required column `content` to the `VendorTaskComment` table without a default value. This is not possible if the table is not empty. | ||
| - Added the required column `ownerId` to the `VendorTaskComment` table without a default value. This is not possible if the table is not empty. | ||
| - Added the required column `taskId` to the `VendorTaskComment` table without a default value. This is not possible if the table is not empty. | ||
| - Added the required column `updatedAt` to the `VendorTaskComment` table without a default value. This is not possible if the table is not empty. | ||
|
|
||
| */ | ||
| -- CreateEnum | ||
| CREATE TYPE "RiskLikelihood" AS ENUM ('very_low', 'low', 'medium', 'high', 'very_high'); | ||
|
|
||
| -- CreateEnum | ||
| CREATE TYPE "RiskImpact" AS ENUM ('very_low', 'low', 'medium', 'high', 'very_high'); | ||
|
|
||
| -- CreateEnum | ||
| CREATE TYPE "VendorTaskStatus" AS ENUM ('open', 'in_progress', 'completed', 'cancelled'); | ||
|
|
||
| -- CreateEnum | ||
| CREATE TYPE "VendorAttachmentType" AS ENUM ('file', 'image', 'document', 'other'); | ||
|
|
||
| -- DropForeignKey | ||
| ALTER TABLE "Vendor" DROP CONSTRAINT "Vendor_organizationId_fkey"; | ||
|
|
||
| -- DropForeignKey | ||
| ALTER TABLE "VendorAttachment" DROP CONSTRAINT "VendorAttachment_organizationId_fkey"; | ||
|
|
||
| -- DropForeignKey | ||
| ALTER TABLE "VendorAttachment" DROP CONSTRAINT "VendorAttachment_vendorId_fkey"; | ||
|
|
||
| -- DropForeignKey | ||
| ALTER TABLE "VendorComment" DROP CONSTRAINT "VendorComment_organizationId_fkey"; | ||
|
|
||
| -- DropForeignKey | ||
| ALTER TABLE "VendorComment" DROP CONSTRAINT "VendorComment_vendorId_fkey"; | ||
|
|
||
| -- DropForeignKey | ||
| ALTER TABLE "VendorContact" DROP CONSTRAINT "VendorContact_organizationId_fkey"; | ||
|
|
||
| -- DropForeignKey | ||
| ALTER TABLE "VendorContact" DROP CONSTRAINT "VendorContact_vendorId_fkey"; | ||
|
|
||
| -- DropForeignKey | ||
| ALTER TABLE "VendorTask" DROP CONSTRAINT "VendorTask_organizationId_fkey"; | ||
|
|
||
| -- DropForeignKey | ||
| ALTER TABLE "VendorTask" DROP CONSTRAINT "VendorTask_vendorId_fkey"; | ||
|
|
||
| -- DropForeignKey | ||
| ALTER TABLE "VendorTaskAssignment" DROP CONSTRAINT "VendorTaskAssignment_organizationId_fkey"; | ||
|
|
||
| -- DropForeignKey | ||
| ALTER TABLE "VendorTaskAssignment" DROP CONSTRAINT "VendorTaskAssignment_vendorId_fkey"; | ||
|
|
||
| -- DropForeignKey | ||
| ALTER TABLE "VendorTaskAttachment" DROP CONSTRAINT "VendorTaskAttachment_organizationId_fkey"; | ||
|
|
||
| -- DropForeignKey | ||
| ALTER TABLE "VendorTaskAttachment" DROP CONSTRAINT "VendorTaskAttachment_vendorId_fkey"; | ||
|
|
||
| -- DropForeignKey | ||
| ALTER TABLE "VendorTaskComment" DROP CONSTRAINT "VendorTaskComment_organizationId_fkey"; | ||
|
|
||
| -- DropForeignKey | ||
| ALTER TABLE "VendorTaskComment" DROP CONSTRAINT "VendorTaskComment_vendorId_fkey"; | ||
|
|
||
| -- AlterTable | ||
| ALTER TABLE "Vendor" ADD COLUMN "ownerId" TEXT; | ||
|
|
||
| -- AlterTable | ||
| ALTER TABLE "VendorAttachment" ADD COLUMN "fileKey" TEXT, | ||
| ADD COLUMN "fileUrl" TEXT NOT NULL, | ||
| ADD COLUMN "name" TEXT NOT NULL, | ||
| ADD COLUMN "ownerId" TEXT, | ||
| ADD COLUMN "type" "VendorAttachmentType" NOT NULL DEFAULT 'file', | ||
| ADD COLUMN "uploadedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP; | ||
|
|
||
| -- AlterTable | ||
| ALTER TABLE "VendorComment" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| ADD COLUMN "ownerId" TEXT NOT NULL, | ||
| ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL; | ||
|
|
||
| -- AlterTable | ||
| ALTER TABLE "VendorContact" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL; | ||
|
|
||
| -- AlterTable | ||
| ALTER TABLE "VendorTask" ADD COLUMN "completedAt" TIMESTAMP(3), | ||
| ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| ADD COLUMN "description" TEXT NOT NULL, | ||
| ADD COLUMN "dueDate" TIMESTAMP(3), | ||
| ADD COLUMN "notifiedAt" TIMESTAMP(3), | ||
| ADD COLUMN "ownerId" TEXT, | ||
| ADD COLUMN "status" "VendorTaskStatus" NOT NULL DEFAULT 'open', | ||
| ADD COLUMN "title" TEXT NOT NULL, | ||
| ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL; | ||
|
|
||
| -- AlterTable | ||
| ALTER TABLE "VendorTaskAssignment" ADD COLUMN "assignedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| ADD COLUMN "employeeId" TEXT NOT NULL, | ||
| ADD COLUMN "taskId" TEXT NOT NULL; | ||
|
|
||
| -- AlterTable | ||
| ALTER TABLE "VendorTaskAttachment" ADD COLUMN "fileKey" TEXT, | ||
| ADD COLUMN "fileUrl" TEXT NOT NULL, | ||
| ADD COLUMN "name" TEXT NOT NULL, | ||
| ADD COLUMN "ownerId" TEXT, | ||
| ADD COLUMN "taskId" TEXT NOT NULL, | ||
| ADD COLUMN "type" "VendorAttachmentType" NOT NULL DEFAULT 'file', | ||
| ADD COLUMN "uploadedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP; | ||
|
|
||
| -- AlterTable | ||
| ALTER TABLE "VendorTaskComment" ADD COLUMN "content" TEXT NOT NULL, | ||
| ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| ADD COLUMN "ownerId" TEXT NOT NULL, | ||
| ADD COLUMN "taskId" TEXT NOT NULL, | ||
| ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL; | ||
|
|
||
| -- CreateIndex | ||
| CREATE INDEX "Vendor_ownerId_idx" ON "Vendor"("ownerId"); | ||
|
|
||
| -- CreateIndex | ||
| CREATE INDEX "VendorAttachment_ownerId_idx" ON "VendorAttachment"("ownerId"); | ||
|
|
||
| -- CreateIndex | ||
| CREATE INDEX "VendorComment_ownerId_idx" ON "VendorComment"("ownerId"); | ||
|
|
||
| -- CreateIndex | ||
| CREATE INDEX "VendorTask_ownerId_idx" ON "VendorTask"("ownerId"); | ||
|
|
||
| -- CreateIndex | ||
| CREATE INDEX "VendorTaskAssignment_taskId_idx" ON "VendorTaskAssignment"("taskId"); | ||
|
|
||
| -- CreateIndex | ||
| CREATE INDEX "VendorTaskAssignment_employeeId_idx" ON "VendorTaskAssignment"("employeeId"); | ||
|
|
||
| -- CreateIndex | ||
| CREATE UNIQUE INDEX "VendorTaskAssignment_taskId_employeeId_key" ON "VendorTaskAssignment"("taskId", "employeeId"); | ||
|
|
||
| -- CreateIndex | ||
| CREATE INDEX "VendorTaskAttachment_taskId_idx" ON "VendorTaskAttachment"("taskId"); | ||
|
|
||
| -- CreateIndex | ||
| CREATE INDEX "VendorTaskAttachment_ownerId_idx" ON "VendorTaskAttachment"("ownerId"); | ||
|
|
||
| -- CreateIndex | ||
| CREATE INDEX "VendorTaskComment_taskId_idx" ON "VendorTaskComment"("taskId"); | ||
|
|
||
| -- CreateIndex | ||
| CREATE INDEX "VendorTaskComment_ownerId_idx" ON "VendorTaskComment"("ownerId"); | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "Vendor" ADD CONSTRAINT "Vendor_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "Vendor" ADD CONSTRAINT "Vendor_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "VendorContact" ADD CONSTRAINT "VendorContact_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "VendorContact" ADD CONSTRAINT "VendorContact_vendorId_fkey" FOREIGN KEY ("vendorId") REFERENCES "Vendor"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "VendorComment" ADD CONSTRAINT "VendorComment_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "VendorComment" ADD CONSTRAINT "VendorComment_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "VendorComment" ADD CONSTRAINT "VendorComment_vendorId_fkey" FOREIGN KEY ("vendorId") REFERENCES "Vendor"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "VendorAttachment" ADD CONSTRAINT "VendorAttachment_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "VendorAttachment" ADD CONSTRAINT "VendorAttachment_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "VendorAttachment" ADD CONSTRAINT "VendorAttachment_vendorId_fkey" FOREIGN KEY ("vendorId") REFERENCES "Vendor"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "VendorTask" ADD CONSTRAINT "VendorTask_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "VendorTask" ADD CONSTRAINT "VendorTask_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "VendorTask" ADD CONSTRAINT "VendorTask_vendorId_fkey" FOREIGN KEY ("vendorId") REFERENCES "Vendor"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "VendorTaskAttachment" ADD CONSTRAINT "VendorTaskAttachment_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "VendorTaskAttachment" ADD CONSTRAINT "VendorTaskAttachment_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "VendorTaskAttachment" ADD CONSTRAINT "VendorTaskAttachment_taskId_fkey" FOREIGN KEY ("taskId") REFERENCES "VendorTask"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "VendorTaskAttachment" ADD CONSTRAINT "VendorTaskAttachment_vendorId_fkey" FOREIGN KEY ("vendorId") REFERENCES "Vendor"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "VendorTaskComment" ADD CONSTRAINT "VendorTaskComment_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "VendorTaskComment" ADD CONSTRAINT "VendorTaskComment_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "VendorTaskComment" ADD CONSTRAINT "VendorTaskComment_taskId_fkey" FOREIGN KEY ("taskId") REFERENCES "VendorTask"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "VendorTaskComment" ADD CONSTRAINT "VendorTaskComment_vendorId_fkey" FOREIGN KEY ("vendorId") REFERENCES "Vendor"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "VendorTaskAssignment" ADD CONSTRAINT "VendorTaskAssignment_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "VendorTaskAssignment" ADD CONSTRAINT "VendorTaskAssignment_employeeId_fkey" FOREIGN KEY ("employeeId") REFERENCES "Employee"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "VendorTaskAssignment" ADD CONSTRAINT "VendorTaskAssignment_taskId_fkey" FOREIGN KEY ("taskId") REFERENCES "VendorTask"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "VendorTaskAssignment" ADD CONSTRAINT "VendorTaskAssignment_vendorId_fkey" FOREIGN KEY ("vendorId") REFERENCES "Vendor"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
This file contains hidden or 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 hidden or 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.
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.
💡 Verification agent
❓ Verification inconclusive
Critical: Migration Warnings & NOT NULL Columns Without Defaults
The initial comment block lists several warnings about adding required (NOT NULL) columns without default values. This may lead to migration failures on non-empty tables. Ensure you either migrate on an empty table, supply default values, or adopt a two-step migration (first add nullable columns, populate data, then alter to NOT NULL) to avoid runtime issues in production.
Action Required: Resolve Migration Warnings for Non-Empty Tables
The migration script currently adds several NOT NULL columns without providing default values and introduces a unique constraint on
[taskId, employeeId]for theVendorTaskAssignmenttable. If any of these tables already contain data, these changes may lead to migration failures. Please ensure that you either:Additionally, verify that there are no existing duplicate values in
VendorTaskAssignmentthat could violate the unique constraint.