-
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.
- Loading branch information
Showing
1 changed file
with
108 additions
and
0 deletions.
There are no files selected for viewing
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,108 @@ | ||
-- CreateTable | ||
CREATE TABLE `Account` ( | ||
`id` VARCHAR(191) NOT NULL, | ||
`userId` VARCHAR(191) NOT NULL, | ||
`type` VARCHAR(191) NOT NULL, | ||
`provider` VARCHAR(191) NOT NULL, | ||
`providerAccountId` VARCHAR(191) NOT NULL, | ||
`refresh_token` TEXT NULL, | ||
`access_token` TEXT NULL, | ||
`expires_at` INTEGER NULL, | ||
`token_type` VARCHAR(191) NULL, | ||
`scope` VARCHAR(191) NULL, | ||
`id_token` TEXT NULL, | ||
`session_state` VARCHAR(191) NULL, | ||
|
||
UNIQUE INDEX `Account_provider_providerAccountId_key`(`provider`, `providerAccountId`), | ||
PRIMARY KEY (`id`) | ||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; | ||
|
||
-- CreateTable | ||
CREATE TABLE `Session` ( | ||
`id` VARCHAR(191) NOT NULL, | ||
`sessionToken` VARCHAR(191) NOT NULL, | ||
`userId` VARCHAR(191) NOT NULL, | ||
`expires` DATETIME(3) NOT NULL, | ||
|
||
UNIQUE INDEX `Session_sessionToken_key`(`sessionToken`), | ||
PRIMARY KEY (`id`) | ||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; | ||
|
||
-- CreateTable | ||
CREATE TABLE `User` ( | ||
`id` VARCHAR(191) NOT NULL, | ||
`name` VARCHAR(191) NULL, | ||
`email` VARCHAR(191) NULL, | ||
`emailVerified` DATETIME(3) NULL, | ||
`image` VARCHAR(191) NULL, | ||
|
||
UNIQUE INDEX `User_email_key`(`email`), | ||
PRIMARY KEY (`id`) | ||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; | ||
|
||
-- CreateTable | ||
CREATE TABLE `VerificationToken` ( | ||
`identifier` VARCHAR(191) NOT NULL, | ||
`token` VARCHAR(191) NOT NULL, | ||
`expires` DATETIME(3) NOT NULL, | ||
|
||
UNIQUE INDEX `VerificationToken_token_key`(`token`), | ||
UNIQUE INDEX `VerificationToken_identifier_token_key`(`identifier`, `token`) | ||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; | ||
|
||
-- CreateTable | ||
CREATE TABLE `Attendee` ( | ||
`id` INTEGER NOT NULL AUTO_INCREMENT, | ||
`userId` VARCHAR(191) NOT NULL, | ||
`firstname` VARCHAR(20) NOT NULL, | ||
`lastname` VARCHAR(30) NOT NULL, | ||
`rating` INTEGER NULL, | ||
`isActive` BOOLEAN NOT NULL DEFAULT true, | ||
`createdAt` DATETIME(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0), | ||
`updatedAt` DATETIME(0) NULL, | ||
|
||
UNIQUE INDEX `Attendee_userId_firstname_lastname_key`(`userId`, `firstname`, `lastname`), | ||
PRIMARY KEY (`id`) | ||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; | ||
|
||
-- CreateTable | ||
CREATE TABLE `Tournament` ( | ||
`id` INTEGER NOT NULL AUTO_INCREMENT, | ||
`userId` VARCHAR(191) NOT NULL, | ||
`name` VARCHAR(45) NOT NULL, | ||
`createdAt` DATETIME(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0), | ||
`updatedAt` VARCHAR(45) NULL, | ||
|
||
UNIQUE INDEX `Tournament_userId_name_key`(`userId`, `name`), | ||
PRIMARY KEY (`id`) | ||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; | ||
|
||
-- CreateTable | ||
CREATE TABLE `TournamentAttendees` ( | ||
`id` INTEGER NOT NULL AUTO_INCREMENT, | ||
`tournamentId` INTEGER NOT NULL, | ||
`attendeeId` INTEGER NOT NULL, | ||
|
||
INDEX `attendee_id_fkey_idx`(`attendeeId`), | ||
INDEX `tournament_id_fkey`(`tournamentId`), | ||
PRIMARY KEY (`id`) | ||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE `Account` ADD CONSTRAINT `Account_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `User`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE `Session` ADD CONSTRAINT `Session_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `User`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE `Attendee` ADD CONSTRAINT `Attendee_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `User`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE `Tournament` ADD CONSTRAINT `Tournament_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `User`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE `TournamentAttendees` ADD CONSTRAINT `attendee_id_fkey` FOREIGN KEY (`attendeeId`) REFERENCES `Attendee`(`id`) ON DELETE NO ACTION ON UPDATE NO ACTION; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE `TournamentAttendees` ADD CONSTRAINT `tournament_id_fkey` FOREIGN KEY (`tournamentId`) REFERENCES `Tournament`(`id`) ON DELETE NO ACTION ON UPDATE NO ACTION; | ||
|