1+
2+ -- CreateTable
3+ CREATE TABLE "LinkType " (
4+ " name" TEXT NOT NULL ,
5+ " dateCreated" TIMESTAMP (3 ) NOT NULL DEFAULT CURRENT_TIMESTAMP ,
6+ " creatorId" INTEGER NOT NULL ,
7+ " iconName" TEXT NOT NULL ,
8+ " required" BOOLEAN NOT NULL ,
9+
10+ CONSTRAINT " LinkType_pkey" PRIMARY KEY (" name" )
11+ );
12+
13+ -- CreateTable
14+ CREATE TABLE "Link " (
15+ " linkId" TEXT NOT NULL ,
16+ " url" TEXT NOT NULL ,
17+ " creatorId" INTEGER NOT NULL ,
18+ " dateCreated" TIMESTAMP (3 ) NOT NULL DEFAULT CURRENT_TIMESTAMP ,
19+ " dateDeleted" TIMESTAMP (3 ),
20+ " linkTypeName" TEXT NOT NULL ,
21+ " wbsElementId" INTEGER NOT NULL ,
22+
23+ CONSTRAINT " Link_pkey" PRIMARY KEY (" linkId" )
24+ );
25+
26+ -- CreateIndex
27+ CREATE UNIQUE INDEX "LinkType_name_key " ON " LinkType" (" name" );
28+
29+ -- AddForeignKey
30+ ALTER TABLE " LinkType" ADD CONSTRAINT " LinkType_creatorId_fkey" FOREIGN KEY (" creatorId" ) REFERENCES " User" (" userId" ) ON DELETE RESTRICT ON UPDATE CASCADE;
31+
32+ -- AddForeignKey
33+ ALTER TABLE " Link" ADD CONSTRAINT " Link_creatorId_fkey" FOREIGN KEY (" creatorId" ) REFERENCES " User" (" userId" ) ON DELETE RESTRICT ON UPDATE CASCADE;
34+
35+ -- AddForeignKey
36+ ALTER TABLE " Link" ADD CONSTRAINT " Link_linkTypeName_fkey" FOREIGN KEY (" linkTypeName" ) REFERENCES " LinkType" (" name" ) ON DELETE RESTRICT ON UPDATE CASCADE;
37+
38+ -- AddForeignKey
39+ ALTER TABLE " Link" ADD CONSTRAINT " Link_wbsElementId_fkey" FOREIGN KEY (" wbsElementId" ) REFERENCES " WBS_Element" (" wbsElementId" ) ON DELETE RESTRICT ON UPDATE CASCADE;
40+
41+ /*
42+ Adds a no-op user to the database
43+ */
44+ -- Insert
45+ INSERT INTO " User" (" userId" , " firstName" , " lastName" , " googleAuthId" , " email" ) VALUES (0 , ' Admin' , ' User' , ' admin' , ' admin@gmail.com' );
46+
47+ /*
48+ Adds Confluence, Google Drive and BOM Link Types to the database
49+ */
50+ -- Insert
51+ INSERT INTO " LinkType" (" name" , " creatorId" , " required" , " iconName" ) VALUES (' Confluence' , 0 , ' true' , ' description' );
52+ INSERT INTO " LinkType" (" name" , " creatorId" , " required" , " iconName" ) VALUES (' Google Drive' , 0 , ' true' , ' folder' );
53+ INSERT INTO " LinkType" (" name" , " creatorId" , " required" , " iconName" ) VALUES (' Bill of Materials' , 0 , ' true' , ' attach_money' );
54+
55+ /*
56+ Transfer over all the slide deck links to conflunce links
57+ */
58+ -- Insert
59+ INSERT INTO " Link" (" linkId" , " url" , " creatorId" , " linkTypeName" , " wbsElementId" ) SELECT gen_random_uuid(), " slideDeckLink" , 0 , ' Confluence' , " wbsElementId" FROM " Project" WHERE " slideDeckLink" IS NOT NULL ;
60+ /*
61+ Transfer over all the Google Drive Folder links to Google Drive links
62+ */
63+ -- Insert
64+ INSERT INTO " Link" (" linkId" , " url" , " creatorId" , " linkTypeName" , " wbsElementId" ) SELECT gen_random_uuid()," googleDriveFolderLink" , 0 , ' Google Drive' , " wbsElementId" FROM " Project" WHERE " googleDriveFolderLink" IS NOT NULL ;
65+ /*
66+ Transfer over all the BOM links to BOM links
67+ */
68+ -- Insert
69+ INSERT INTO " Link" (" linkId" , " url" , " creatorId" , " linkTypeName" , " wbsElementId" ) SELECT gen_random_uuid(), " bomLink" , 0 , ' Bill of Materials' , " wbsElementId" FROM " Project" WHERE " bomLink" IS NOT NULL ;
70+
71+ /*
72+ Warnings:
73+ - You are about to drop the column `bomLink` on the `Project` table. All the data in the column will be lost.
74+ - You are about to drop the column `googleDriveFolderLink` on the `Project` table. All the data in the column will be lost.
75+ - You are about to drop the column `slideDeckLink` on the `Project` table. All the data in the column will be lost.
76+ - You are about to drop the column `taskListLink` on the `Project` table. All the data in the column will be lost.
77+ */
78+ -- AlterTable
79+ ALTER TABLE " Project" DROP COLUMN " bomLink" ,
80+ DROP COLUMN " googleDriveFolderLink" ,
81+ DROP COLUMN " slideDeckLink" ,
82+ DROP COLUMN " taskListLink" ;
0 commit comments