-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Fabio Brasileiro
authored and
Fabio Brasileiro
committed
Sep 24, 2024
1 parent
6c5bc56
commit dbc8f19
Showing
14 changed files
with
330 additions
and
56 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,26 @@ | ||
-- CreateEnum | ||
CREATE TYPE "ProposalStatus" AS ENUM ('PENDING', 'APPROVED', 'REJECTED'); | ||
|
||
-- AlterEnum | ||
ALTER TYPE "UserRole" ADD VALUE 'PENDING'; | ||
|
||
-- AlterTable | ||
ALTER TABLE "User" ALTER COLUMN "role" SET DEFAULT 'PENDING'; | ||
|
||
-- CreateTable | ||
CREATE TABLE "Proposal" ( | ||
"id" SERIAL NOT NULL, | ||
"companyName" TEXT NOT NULL, | ||
"companyDocument" TEXT NOT NULL, | ||
"userId" INTEGER NOT NULL, | ||
"status" "ProposalStatus" NOT NULL DEFAULT 'PENDING', | ||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
|
||
CONSTRAINT "Proposal_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Proposal_userId_key" ON "Proposal"("userId"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Proposal" ADD CONSTRAINT "Proposal_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Please do not edit this file manually | ||
# It should be added in your version-control system (i.e. Git) | ||
provider = "postgresql" |
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,83 @@ | ||
-- CreateEnum | ||
CREATE TYPE "ProposalStatus" AS ENUM ('PENDING', 'APPROVED', 'REJECTED'); | ||
|
||
-- CreateEnum | ||
CREATE TYPE "UserRole" AS ENUM ('PENDING', 'USER', 'ADMIN'); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Product" ( | ||
"id" SERIAL NOT NULL, | ||
"name" TEXT NOT NULL, | ||
"price" DOUBLE PRECISION NOT NULL, | ||
"description" TEXT, | ||
"imageUrl" TEXT, | ||
"companyId" INTEGER NOT NULL, | ||
|
||
CONSTRAINT "Product_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Company" ( | ||
"id" SERIAL NOT NULL, | ||
"name" TEXT NOT NULL, | ||
"document" TEXT NOT NULL, | ||
|
||
CONSTRAINT "Company_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Unit" ( | ||
"id" SERIAL NOT NULL, | ||
"name" TEXT NOT NULL, | ||
"companyId" INTEGER NOT NULL, | ||
|
||
CONSTRAINT "Unit_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Proposal" ( | ||
"id" SERIAL NOT NULL, | ||
"companyName" TEXT NOT NULL, | ||
"companyDocument" TEXT NOT NULL, | ||
"userId" INTEGER NOT NULL, | ||
"status" "ProposalStatus" NOT NULL DEFAULT 'PENDING', | ||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
|
||
CONSTRAINT "Proposal_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "User" ( | ||
"id" SERIAL NOT NULL, | ||
"email" TEXT NOT NULL, | ||
"name" TEXT NOT NULL, | ||
"password" TEXT NOT NULL, | ||
"role" "UserRole" NOT NULL DEFAULT 'PENDING', | ||
"companyId" INTEGER, | ||
|
||
CONSTRAINT "User_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Company_name_key" ON "Company"("name"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Company_document_key" ON "Company"("document"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Proposal_userId_key" ON "Proposal"("userId"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Product" ADD CONSTRAINT "Product_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "Company"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Unit" ADD CONSTRAINT "Unit_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "Company"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Proposal" ADD CONSTRAINT "Proposal_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "User" ADD CONSTRAINT "User_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "Company"("id") ON DELETE SET NULL ON UPDATE CASCADE; |
12 changes: 12 additions & 0 deletions
12
prisma/migrations/20240924025207_update_register/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,12 @@ | ||
/* | ||
Warnings: | ||
- Added the required column `proposalValue` to the `Proposal` table without a default value. This is not possible if the table is not empty. | ||
*/ | ||
-- AlterTable | ||
ALTER TABLE "Proposal" ADD COLUMN "proposalValue" DOUBLE PRECISION NOT NULL, | ||
ADD COLUMN "unitId" INTEGER; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Proposal" ADD CONSTRAINT "Proposal_unitId_fkey" FOREIGN KEY ("unitId") REFERENCES "Unit"("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
Oops, something went wrong.