-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from unovil/mysql-addition
MySQL addition, Prisma and Lucia Integration
- Loading branch information
Showing
26 changed files
with
3,926 additions
and
1,732 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
-- CreateTable | ||
CREATE TABLE `User` ( | ||
`id` VARCHAR(191) NOT NULL, | ||
`email` VARCHAR(191) NULL, | ||
`firstName` VARCHAR(191) NOT NULL, | ||
`middleName` VARCHAR(191) NULL, | ||
`lastName` VARCHAR(191) NOT NULL, | ||
`password` VARCHAR(191) NOT NULL, | ||
`role` ENUM('STUDENT', 'ADMIN') NOT NULL DEFAULT 'STUDENT', | ||
`schoolId` INTEGER NULL, | ||
|
||
UNIQUE INDEX `User_email_key`(`email`), | ||
PRIMARY KEY (`id`) | ||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; | ||
|
||
-- CreateTable | ||
CREATE TABLE `School` ( | ||
`id` INTEGER NOT NULL AUTO_INCREMENT, | ||
`name` VARCHAR(191) NOT NULL, | ||
|
||
PRIMARY KEY (`id`) | ||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; | ||
|
||
-- CreateTable | ||
CREATE TABLE `Section` ( | ||
`id` INTEGER NOT NULL AUTO_INCREMENT, | ||
`grade` INTEGER NOT NULL, | ||
`name` VARCHAR(191) NOT NULL, | ||
`schoolId` INTEGER NOT NULL, | ||
|
||
UNIQUE INDEX `Section_name_key`(`name`), | ||
PRIMARY KEY (`id`) | ||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; | ||
|
||
-- CreateTable | ||
CREATE TABLE `Admin` ( | ||
`id` INTEGER NOT NULL AUTO_INCREMENT, | ||
`userId` VARCHAR(191) NOT NULL, | ||
`departments` JSON NOT NULL, | ||
|
||
UNIQUE INDEX `Admin_userId_key`(`userId`), | ||
PRIMARY KEY (`id`) | ||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; | ||
|
||
-- CreateTable | ||
CREATE TABLE `Student` ( | ||
`id` INTEGER NOT NULL AUTO_INCREMENT, | ||
`lrn` CHAR(12) NOT NULL, | ||
`sectionId` INTEGER NOT NULL, | ||
`userId` VARCHAR(191) NOT NULL, | ||
|
||
UNIQUE INDEX `Student_lrn_key`(`lrn`), | ||
UNIQUE INDEX `Student_userId_key`(`userId`), | ||
PRIMARY KEY (`id`) | ||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; | ||
|
||
-- CreateTable | ||
CREATE TABLE `Facility` ( | ||
`id` INTEGER NOT NULL AUTO_INCREMENT, | ||
`schoolId` INTEGER NOT NULL, | ||
`name` VARCHAR(191) NOT NULL, | ||
`department` ENUM('SCIENCE', 'MATH', 'MAPEH', 'MISC', 'LANGUAGE') NOT NULL DEFAULT 'MISC', | ||
`blockedDates` JSON NOT NULL, | ||
|
||
PRIMARY KEY (`id`) | ||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; | ||
|
||
-- CreateTable | ||
CREATE TABLE `Equipment` ( | ||
`id` INTEGER NOT NULL AUTO_INCREMENT, | ||
`schoolId` INTEGER NOT NULL, | ||
`name` VARCHAR(191) NOT NULL, | ||
`department` ENUM('SCIENCE', 'MATH', 'MAPEH', 'MISC', 'LANGUAGE') NOT NULL DEFAULT 'MISC', | ||
`blockedDates` JSON NOT NULL, | ||
|
||
PRIMARY KEY (`id`) | ||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; | ||
|
||
-- CreateTable | ||
CREATE TABLE `Request` ( | ||
`id` INTEGER NOT NULL AUTO_INCREMENT, | ||
`description` VARCHAR(191) NOT NULL, | ||
`isAllowed` BOOLEAN NOT NULL DEFAULT false, | ||
`requestDates` JSON NOT NULL, | ||
|
||
PRIMARY KEY (`id`) | ||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; | ||
|
||
-- CreateTable | ||
CREATE TABLE `_FacilityToAdmin` ( | ||
`A` INTEGER NOT NULL, | ||
`B` INTEGER NOT NULL, | ||
|
||
UNIQUE INDEX `_FacilityToAdmin_AB_unique`(`A`, `B`), | ||
INDEX `_FacilityToAdmin_B_index`(`B`) | ||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; | ||
|
||
-- CreateTable | ||
CREATE TABLE `_AdminToRequest` ( | ||
`A` INTEGER NOT NULL, | ||
`B` INTEGER NOT NULL, | ||
|
||
UNIQUE INDEX `_AdminToRequest_AB_unique`(`A`, `B`), | ||
INDEX `_AdminToRequest_B_index`(`B`) | ||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; | ||
|
||
-- CreateTable | ||
CREATE TABLE `_FacilityToRequest` ( | ||
`A` INTEGER NOT NULL, | ||
`B` INTEGER NOT NULL, | ||
|
||
UNIQUE INDEX `_FacilityToRequest_AB_unique`(`A`, `B`), | ||
INDEX `_FacilityToRequest_B_index`(`B`) | ||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; | ||
|
||
-- CreateTable | ||
CREATE TABLE `_EquipmentToRequest` ( | ||
`A` INTEGER NOT NULL, | ||
`B` INTEGER NOT NULL, | ||
|
||
UNIQUE INDEX `_EquipmentToRequest_AB_unique`(`A`, `B`), | ||
INDEX `_EquipmentToRequest_B_index`(`B`) | ||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; | ||
|
||
-- CreateTable | ||
CREATE TABLE `_StudentToRequest` ( | ||
`A` INTEGER NOT NULL, | ||
`B` INTEGER NOT NULL, | ||
|
||
UNIQUE INDEX `_StudentToRequest_AB_unique`(`A`, `B`), | ||
INDEX `_StudentToRequest_B_index`(`B`) | ||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE `User` ADD CONSTRAINT `User_schoolId_fkey` FOREIGN KEY (`schoolId`) REFERENCES `School`(`id`) ON DELETE SET NULL ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE `Section` ADD CONSTRAINT `Section_schoolId_fkey` FOREIGN KEY (`schoolId`) REFERENCES `School`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE `Admin` ADD CONSTRAINT `Admin_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `User`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE `Student` ADD CONSTRAINT `Student_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `User`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE `Student` ADD CONSTRAINT `Student_sectionId_fkey` FOREIGN KEY (`sectionId`) REFERENCES `Section`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE `Facility` ADD CONSTRAINT `Facility_schoolId_fkey` FOREIGN KEY (`schoolId`) REFERENCES `School`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE `Equipment` ADD CONSTRAINT `Equipment_schoolId_fkey` FOREIGN KEY (`schoolId`) REFERENCES `School`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE `_FacilityToAdmin` ADD CONSTRAINT `_FacilityToAdmin_A_fkey` FOREIGN KEY (`A`) REFERENCES `Admin`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE `_FacilityToAdmin` ADD CONSTRAINT `_FacilityToAdmin_B_fkey` FOREIGN KEY (`B`) REFERENCES `Facility`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE `_AdminToRequest` ADD CONSTRAINT `_AdminToRequest_A_fkey` FOREIGN KEY (`A`) REFERENCES `Admin`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE `_AdminToRequest` ADD CONSTRAINT `_AdminToRequest_B_fkey` FOREIGN KEY (`B`) REFERENCES `Request`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE `_FacilityToRequest` ADD CONSTRAINT `_FacilityToRequest_A_fkey` FOREIGN KEY (`A`) REFERENCES `Facility`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE `_FacilityToRequest` ADD CONSTRAINT `_FacilityToRequest_B_fkey` FOREIGN KEY (`B`) REFERENCES `Request`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE `_EquipmentToRequest` ADD CONSTRAINT `_EquipmentToRequest_A_fkey` FOREIGN KEY (`A`) REFERENCES `Equipment`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE `_EquipmentToRequest` ADD CONSTRAINT `_EquipmentToRequest_B_fkey` FOREIGN KEY (`B`) REFERENCES `Request`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE `_StudentToRequest` ADD CONSTRAINT `_StudentToRequest_A_fkey` FOREIGN KEY (`A`) REFERENCES `Request`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE `_StudentToRequest` ADD CONSTRAINT `_StudentToRequest_B_fkey` FOREIGN KEY (`B`) REFERENCES `Student`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; |
11 changes: 11 additions & 0 deletions
11
prisma/migrations/20240304144205_added_session_table/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,11 @@ | ||
-- CreateTable | ||
CREATE TABLE `Session` ( | ||
`id` VARCHAR(191) NOT NULL, | ||
`userId` VARCHAR(191) NOT NULL, | ||
`expiresAt` DATETIME(3) NOT NULL, | ||
|
||
PRIMARY KEY (`id`) | ||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE `Session` ADD CONSTRAINT `Session_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `User`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; |
11 changes: 11 additions & 0 deletions
11
prisma/migrations/20240304144523_added_email_password_table/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,11 @@ | ||
-- CreateTable | ||
CREATE TABLE `Password` ( | ||
`id` INTEGER NOT NULL AUTO_INCREMENT, | ||
`hashedPassword` VARCHAR(191) NOT NULL, | ||
`userId` VARCHAR(191) NOT NULL, | ||
|
||
PRIMARY KEY (`id`) | ||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE `Password` ADD CONSTRAINT `Password_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `User`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; |
10 changes: 10 additions & 0 deletions
10
prisma/migrations/20240304224551_fixed_redundant_fields/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,10 @@ | ||
/* | ||
Warnings: | ||
- You are about to drop the column `middleName` on the `user` table. All the data in the column will be lost. | ||
- You are about to drop the column `password` on the `user` table. All the data in the column will be lost. | ||
*/ | ||
-- AlterTable | ||
ALTER TABLE `user` DROP COLUMN `middleName`, | ||
DROP COLUMN `password`; |
8 changes: 8 additions & 0 deletions
8
prisma/migrations/20240304225921_made_email_mandatory/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,8 @@ | ||
/* | ||
Warnings: | ||
- Made the column `email` on table `user` required. This step will fail if there are existing NULL values in that column. | ||
*/ | ||
-- AlterTable | ||
ALTER TABLE `user` MODIFY `email` VARCHAR(191) NOT NULL; |
15 changes: 15 additions & 0 deletions
15
prisma/migrations/20240304233048_simplified_password/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,15 @@ | ||
/* | ||
Warnings: | ||
- You are about to drop the `password` table. If the table is not empty, all the data it contains will be lost. | ||
- Added the required column `hashedPassword` to the `User` table without a default value. This is not possible if the table is not empty. | ||
*/ | ||
-- DropForeignKey | ||
ALTER TABLE `password` DROP FOREIGN KEY `Password_userId_fkey`; | ||
|
||
-- AlterTable | ||
ALTER TABLE `user` ADD COLUMN `hashedPassword` VARCHAR(191) NOT NULL; | ||
|
||
-- DropTable | ||
DROP TABLE `password`; |
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 = "mysql" |
Oops, something went wrong.