diff --git a/prisma/migrations/0_init/migration.sql b/prisma/migrations/0_init/migration.sql index af4f7be..3cfe4f1 100644 --- a/prisma/migrations/0_init/migration.sql +++ b/prisma/migrations/0_init/migration.sql @@ -7,7 +7,7 @@ CREATE TABLE `Album_Animation` ( INDEX `animationId`(`animationId`), PRIMARY KEY (`albumId`, `animationId`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +); -- CreateTable CREATE TABLE `Album_Artist` ( @@ -18,7 +18,7 @@ CREATE TABLE `Album_Artist` ( INDEX `artistSlug`(`artistSlug`), PRIMARY KEY (`albumId`, `artistSlug`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +); -- CreateTable CREATE TABLE `Album_Category` ( @@ -29,7 +29,7 @@ CREATE TABLE `Album_Category` ( INDEX `ostId`(`albumId`), PRIMARY KEY (`categoryName`, `albumId`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +); -- CreateTable CREATE TABLE `Album_Classification` ( @@ -40,7 +40,7 @@ CREATE TABLE `Album_Classification` ( INDEX `categoryName`(`classificationName`), PRIMARY KEY (`albumId`, `classificationName`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +); -- CreateTable CREATE TABLE `Album_Game` ( @@ -51,7 +51,7 @@ CREATE TABLE `Album_Game` ( INDEX `ostId`(`albumId`), PRIMARY KEY (`gameSlug`, `albumId`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +); -- CreateTable CREATE TABLE `Album_Platform` ( @@ -62,7 +62,7 @@ CREATE TABLE `Album_Platform` ( INDEX `platformId`(`platformId`), PRIMARY KEY (`albumId`, `platformId`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +); -- CreateTable CREATE TABLE `Album_Type` ( @@ -73,7 +73,7 @@ CREATE TABLE `Album_Type` ( INDEX `typeId`(`typeId`), PRIMARY KEY (`albumId`, `typeId`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +); -- CreateTable CREATE TABLE `Game_Platform` ( @@ -84,7 +84,7 @@ CREATE TABLE `Game_Platform` ( INDEX `platformId`(`platformId`), PRIMARY KEY (`gameSlug`, `platformId`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +); -- CreateTable CREATE TABLE `Publisher_Game` ( @@ -95,7 +95,7 @@ CREATE TABLE `Publisher_Game` ( INDEX `publisherId`(`publisherId`), PRIMARY KEY (`gameSlug`, `publisherId`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +); -- CreateTable CREATE TABLE `SequelizeMeta` ( @@ -103,7 +103,7 @@ CREATE TABLE `SequelizeMeta` ( UNIQUE INDEX `name`(`name`), PRIMARY KEY (`name`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +); -- CreateTable CREATE TABLE `Series_Game` ( @@ -114,7 +114,7 @@ CREATE TABLE `Series_Game` ( INDEX `seriesSlug`(`seriesSlug`), PRIMARY KEY (`gameSlug`, `seriesSlug`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +); -- CreateTable CREATE TABLE `Studio_Animation` ( @@ -125,7 +125,7 @@ CREATE TABLE `Studio_Animation` ( INDEX `studioSlug`(`studioSlug`), PRIMARY KEY (`animationId`, `studioSlug`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +); -- CreateTable CREATE TABLE `User_Role` ( @@ -136,7 +136,7 @@ CREATE TABLE `User_Role` ( INDEX `roleName`(`roleName`), PRIMARY KEY (`userUsername`, `roleName`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +); -- CreateTable CREATE TABLE `albumHistories` ( @@ -150,7 +150,7 @@ CREATE TABLE `albumHistories` ( INDEX `ostId`(`albumId`), INDEX `username`(`username`), PRIMARY KEY (`id`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +); -- CreateTable CREATE TABLE `albums` ( @@ -169,7 +169,7 @@ CREATE TABLE `albums` ( `headerColor` VARCHAR(255) NULL DEFAULT '#ffffff', PRIMARY KEY (`id`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +); -- CreateTable CREATE TABLE `animation` ( @@ -187,7 +187,7 @@ CREATE TABLE `animation` ( UNIQUE INDEX `subTitle`(`subTitle`), INDEX `studioSlug`(`studioSlug`), PRIMARY KEY (`id`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +); -- CreateTable CREATE TABLE `artist` ( @@ -197,7 +197,7 @@ CREATE TABLE `artist` ( `updatedAt` DATETIME(0) NOT NULL, PRIMARY KEY (`slug`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +); -- CreateTable CREATE TABLE `availables` ( @@ -210,7 +210,7 @@ CREATE TABLE `availables` ( INDEX `ostId`(`albumId`), PRIMARY KEY (`id`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +); -- CreateTable CREATE TABLE `category` ( @@ -219,7 +219,7 @@ CREATE TABLE `category` ( `updatedAt` DATETIME(0) NOT NULL, PRIMARY KEY (`name`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +); -- CreateTable CREATE TABLE `classification` ( @@ -228,7 +228,7 @@ CREATE TABLE `classification` ( `updatedAt` DATETIME(0) NOT NULL, PRIMARY KEY (`name`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +); -- CreateTable CREATE TABLE `comments` ( @@ -243,7 +243,7 @@ CREATE TABLE `comments` ( INDEX `ostId`(`albumId`), INDEX `username`(`username`), PRIMARY KEY (`id`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +); -- CreateTable CREATE TABLE `config` ( @@ -253,7 +253,7 @@ CREATE TABLE `config` ( `updatedAt` DATETIME(0) NOT NULL, PRIMARY KEY (`name`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +); -- CreateTable CREATE TABLE `discs` ( @@ -266,7 +266,7 @@ CREATE TABLE `discs` ( INDEX `ostId`(`albumId`), PRIMARY KEY (`id`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +); -- CreateTable CREATE TABLE `downloads` ( @@ -279,7 +279,7 @@ CREATE TABLE `downloads` ( INDEX `ostId`(`albumId`), PRIMARY KEY (`id`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +); -- CreateTable CREATE TABLE `favorites` ( @@ -292,7 +292,7 @@ CREATE TABLE `favorites` ( INDEX `ostId`(`albumId`), INDEX `username`(`username`), PRIMARY KEY (`id`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +); -- CreateTable CREATE TABLE `forgors` ( @@ -305,7 +305,7 @@ CREATE TABLE `forgors` ( INDEX `username`(`username`), PRIMARY KEY (`id`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +); -- CreateTable CREATE TABLE `game` ( @@ -318,7 +318,7 @@ CREATE TABLE `game` ( `headerColor` VARCHAR(255) NULL DEFAULT '#ffffff', PRIMARY KEY (`slug`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +); -- CreateTable CREATE TABLE `linkCategories` ( @@ -331,7 +331,7 @@ CREATE TABLE `linkCategories` ( INDEX `ostId`(`albumId`), PRIMARY KEY (`id`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +); -- CreateTable CREATE TABLE `links` ( @@ -347,7 +347,7 @@ CREATE TABLE `links` ( INDEX `downloadId`(`downloadId`), PRIMARY KEY (`id`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +); -- CreateTable CREATE TABLE `logs` ( @@ -360,7 +360,7 @@ CREATE TABLE `logs` ( INDEX `username`(`username`), PRIMARY KEY (`id`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +); -- CreateTable CREATE TABLE `pendings` ( @@ -369,7 +369,7 @@ CREATE TABLE `pendings` ( `updatedAt` DATETIME(0) NOT NULL, PRIMARY KEY (`id`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +); -- CreateTable CREATE TABLE `platform` ( @@ -380,7 +380,7 @@ CREATE TABLE `platform` ( `type` VARCHAR(255) NULL DEFAULT 'Game', PRIMARY KEY (`id`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +); -- CreateTable CREATE TABLE `publisher` ( @@ -390,7 +390,7 @@ CREATE TABLE `publisher` ( `updatedAt` DATETIME(0) NOT NULL, PRIMARY KEY (`id`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +); -- CreateTable CREATE TABLE `ratings` ( @@ -404,7 +404,7 @@ CREATE TABLE `ratings` ( INDEX `ostId`(`albumId`), INDEX `username`(`username`), PRIMARY KEY (`id`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +); -- CreateTable CREATE TABLE `related_album` ( @@ -415,7 +415,7 @@ CREATE TABLE `related_album` ( INDEX `relatedId`(`relatedId`), PRIMARY KEY (`albumId`, `relatedId`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +); -- CreateTable CREATE TABLE `requests` ( @@ -433,7 +433,7 @@ CREATE TABLE `requests` ( `updatedAt` DATETIME(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0), PRIMARY KEY (`id`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +); -- CreateTable CREATE TABLE `roles` ( @@ -443,7 +443,7 @@ CREATE TABLE `roles` ( `updatedAt` DATETIME(0) NOT NULL, PRIMARY KEY (`name`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +); -- CreateTable CREATE TABLE `series` ( @@ -455,7 +455,7 @@ CREATE TABLE `series` ( `headerColor` VARCHAR(255) NULL DEFAULT '#ffffff', PRIMARY KEY (`slug`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +); -- CreateTable CREATE TABLE `stores` ( @@ -468,7 +468,7 @@ CREATE TABLE `stores` ( INDEX `ostId`(`albumId`), PRIMARY KEY (`id`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +); -- CreateTable CREATE TABLE `studio` ( @@ -478,7 +478,7 @@ CREATE TABLE `studio` ( `updatedAt` DATETIME(0) NOT NULL, PRIMARY KEY (`slug`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +); -- CreateTable CREATE TABLE `submissions` ( @@ -496,7 +496,7 @@ CREATE TABLE `submissions` ( INDEX `requestId`(`requestId`), INDEX `userUsername`(`userUsername`), PRIMARY KEY (`id`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +); -- CreateTable CREATE TABLE `type` ( @@ -506,7 +506,7 @@ CREATE TABLE `type` ( `updatedAt` DATETIME(0) NOT NULL, PRIMARY KEY (`id`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +); -- CreateTable CREATE TABLE `users` ( @@ -519,7 +519,7 @@ CREATE TABLE `users` ( `imgId` VARCHAR(255) NULL, PRIMARY KEY (`username`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +); -- AddForeignKey ALTER TABLE `Album_Animation` ADD CONSTRAINT `Album_Animation_ibfk_1` FOREIGN KEY (`albumId`) REFERENCES `albums`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/prisma/migrations/20250209234640_account_table/migration.sql b/prisma/migrations/20250209234640_account_table/migration.sql new file mode 100644 index 0000000..17f8c7c --- /dev/null +++ b/prisma/migrations/20250209234640_account_table/migration.sql @@ -0,0 +1,24 @@ +-- CreateTable +CREATE TABLE `account` ( + `id` VARCHAR(191) NOT NULL, + `userId` VARCHAR(191) NOT NULL, + `accountId` VARCHAR(191) NOT NULL, + `providerId` VARCHAR(191) NOT NULL, + `accessToken` VARCHAR(191) NULL, + `refreshToken` VARCHAR(191) NULL, + `accessTokenExpiresAt` DATETIME(3) NULL, + `refreshTokenExpiresAt` DATETIME(3) NULL, + `scope` VARCHAR(191) NULL, + `idToken` VARCHAR(191) NULL, + `password` VARCHAR(191) NULL, + `createdAt` DATETIME(3) NOT NULL, + `updatedAt` DATETIME(3) NOT NULL, + + PRIMARY KEY (`id`) +); + +-- AddForeignKey +ALTER TABLE `account` ADD CONSTRAINT `account_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `users`(`username`) ON DELETE RESTRICT ON UPDATE CASCADE; + +INSERT INTO `account` (id,userId,accountId, providerId,createdAt, updatedAt) +SELECT username,username,username,"username",createdAt,updatedAt FROM `users`; \ No newline at end of file diff --git a/prisma/migrations/20250210024431_modify_users_table/migration.sql b/prisma/migrations/20250210024431_modify_users_table/migration.sql new file mode 100644 index 0000000..ddf71d0 --- /dev/null +++ b/prisma/migrations/20250210024431_modify_users_table/migration.sql @@ -0,0 +1,94 @@ +-- DropForeignKey +ALTER TABLE `User_Role` DROP FOREIGN KEY `User_Role_ibfk_1`; + +-- DropForeignKey +ALTER TABLE `account` DROP FOREIGN KEY `account_userId_fkey`; + +-- DropForeignKey +ALTER TABLE `albumHistories` DROP FOREIGN KEY `albumHistories_ibfk_1`; + +-- DropForeignKey +ALTER TABLE `comments` DROP FOREIGN KEY `comments_ibfk_2`; + +-- DropForeignKey +ALTER TABLE `favorites` DROP FOREIGN KEY `favorites_ibfk_2`; + +-- DropForeignKey +ALTER TABLE `forgors` DROP FOREIGN KEY `forgors_ibfk_1`; + +-- DropForeignKey +ALTER TABLE `logs` DROP FOREIGN KEY `logs_ibfk_1`; + +-- DropForeignKey +ALTER TABLE `ratings` DROP FOREIGN KEY `ratings_ibfk_2`; + +-- DropForeignKey +ALTER TABLE `session` DROP FOREIGN KEY `session_userId_fkey`; + +-- DropForeignKey +ALTER TABLE `submissions` DROP FOREIGN KEY `submissions_ibfk_1`; + +-- DropIndex +DROP INDEX `account_userId_fkey` ON `account`; + +-- DropIndex +DROP INDEX `session_userId_fkey` ON `session`; + +-- AlterTable +ALTER TABLE `users` DROP PRIMARY KEY, + RENAME COLUMN `username` TO `id`, + ADD COLUMN `username` VARCHAR(255) NOT NULL, + DROP COLUMN `password`, + ADD COLUMN `emailVerified` BOOLEAN NOT NULL, + ADD COLUMN `image` VARCHAR(255) NULL, + ADD COLUMN `name` VARCHAR(20) NOT NULL, + ADD PRIMARY KEY (`id`); + +UPDATE `users` SET username=id; +UPDATE `users` SET emailVerified=1; + +DELETE FROM `users` WHERE `email` in ( + SELECT `email` FROM ( + SELECT `email` FROM `users` + GROUP BY `email` + HAVING COUNT(*) > 1 + ) t +); + +-- CreateIndex +CREATE UNIQUE INDEX `users_username_key` ON `users`(`username`); + +-- CreateIndex +CREATE UNIQUE INDEX `users_email_key` ON `users`(`email`); + +SET FOREIGN_KEY_CHECKS=0; +-- AddForeignKey +ALTER TABLE `User_Role` ADD CONSTRAINT `User_Role_ibfk_1` FOREIGN KEY (`userUsername`) REFERENCES `users`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `albumHistories` ADD CONSTRAINT `albumHistories_ibfk_1` FOREIGN KEY (`username`) REFERENCES `users`(`id`) ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `comments` ADD CONSTRAINT `comments_ibfk_2` FOREIGN KEY (`username`) REFERENCES `users`(`id`) ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `favorites` ADD CONSTRAINT `favorites_ibfk_2` FOREIGN KEY (`username`) REFERENCES `users`(`id`) ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `forgors` ADD CONSTRAINT `forgors_ibfk_1` FOREIGN KEY (`username`) REFERENCES `users`(`id`) ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `logs` ADD CONSTRAINT `logs_ibfk_1` FOREIGN KEY (`username`) REFERENCES `users`(`id`) ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `ratings` ADD CONSTRAINT `ratings_ibfk_2` FOREIGN KEY (`username`) REFERENCES `users`(`id`) ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `submissions` ADD CONSTRAINT `submissions_ibfk_1` FOREIGN KEY (`userUsername`) REFERENCES `users`(`id`) ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `session` ADD CONSTRAINT `session_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `users`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `account` ADD CONSTRAINT `account_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `users`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; +SET FOREIGN_KEY_CHECKS=1; \ No newline at end of file diff --git a/prisma/migrations/20250210035856_user_image_info/migration.sql b/prisma/migrations/20250210035856_user_image_info/migration.sql new file mode 100644 index 0000000..fb71754 --- /dev/null +++ b/prisma/migrations/20250210035856_user_image_info/migration.sql @@ -0,0 +1,5 @@ +UPDATE `users` SET `image`=CONCAT(`username`,"_",`imgId`,".png"); + +-- AlterTable +ALTER TABLE `users` DROP COLUMN `imgId`, + DROP COLUMN `placeholder`; diff --git a/prisma/migrations/20250210040210_fix_user_image_url/migration.sql b/prisma/migrations/20250210040210_fix_user_image_url/migration.sql new file mode 100644 index 0000000..5a74158 --- /dev/null +++ b/prisma/migrations/20250210040210_fix_user_image_url/migration.sql @@ -0,0 +1 @@ +UPDATE `users` SET `image`=CONCAT("https://cdn.sittingonclouds.net/user/",`image`); \ No newline at end of file diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 7ece8a3..49f60b2 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -148,7 +148,7 @@ model User_Role { updatedAt DateTime @db.DateTime(0) userUsername String @db.VarChar(255) roleName String @db.VarChar(255) - users users @relation(fields: [userUsername], references: [username], onDelete: Cascade, map: "User_Role_ibfk_1") + users users @relation(fields: [userUsername], references: [id], onDelete: Cascade, map: "User_Role_ibfk_1") roles roles @relation(fields: [roleName], references: [name], onDelete: Cascade, map: "User_Role_ibfk_2") @@id([userUsername, roleName]) @@ -162,7 +162,7 @@ model albumHistories { updatedAt DateTime @db.DateTime(0) username String? @db.VarChar(255) albumId Int? - users users? @relation(fields: [username], references: [username], map: "albumHistories_ibfk_1") + users users? @relation(fields: [username], references: [id], map: "albumHistories_ibfk_1") albums albums? @relation(fields: [albumId], references: [id], map: "albumHistories_ibfk_2") @@index([albumId], map: "ostId") @@ -263,7 +263,7 @@ model comments { albumId Int? username String? @db.VarChar(255) albums albums? @relation(fields: [albumId], references: [id], map: "comments_ibfk_1") - users users? @relation(fields: [username], references: [username], map: "comments_ibfk_2") + users users? @relation(fields: [username], references: [id], map: "comments_ibfk_2") @@index([albumId], map: "ostId") @@index([username], map: "username") @@ -308,7 +308,7 @@ model favorites { albumId Int? username String? @db.VarChar(255) albums albums? @relation(fields: [albumId], references: [id], map: "favorites_ibfk_1") - users users? @relation(fields: [username], references: [username], map: "favorites_ibfk_2") + users users? @relation(fields: [username], references: [id], map: "favorites_ibfk_2") @@index([albumId], map: "ostId") @@index([username], map: "username") @@ -321,7 +321,7 @@ model forgors { createdAt DateTime @db.DateTime(0) updatedAt DateTime @db.DateTime(0) username String? @db.VarChar(255) - users users? @relation(fields: [username], references: [username], map: "forgors_ibfk_1") + users users? @relation(fields: [username], references: [id], map: "forgors_ibfk_1") @@index([username], map: "username") } @@ -374,7 +374,7 @@ model logs { createdAt DateTime @db.DateTime(0) updatedAt DateTime @db.DateTime(0) username String? @db.VarChar(255) - users users? @relation(fields: [username], references: [username], map: "logs_ibfk_1") + users users? @relation(fields: [username], references: [id], map: "logs_ibfk_1") @@index([username], map: "username") } @@ -411,7 +411,7 @@ model ratings { albumId Int? username String? @db.VarChar(255) albums albums? @relation(fields: [albumId], references: [id], map: "ratings_ibfk_1") - users users? @relation(fields: [username], references: [username], map: "ratings_ibfk_2") + users users? @relation(fields: [username], references: [id], map: "ratings_ibfk_2") @@index([albumId], map: "ostId") @@index([username], map: "username") @@ -495,7 +495,7 @@ model submissions { updatedAt DateTime @db.DateTime(0) userUsername String? @db.VarChar(255) requestId Int? - users users? @relation(fields: [userUsername], references: [username], map: "submissions_ibfk_1") + users users? @relation(fields: [userUsername], references: [id], map: "submissions_ibfk_1") requests requests? @relation(fields: [requestId], references: [id], map: "submissions_ibfk_2") @@index([requestId], map: "requestId") @@ -511,14 +511,16 @@ model type { } model users { - username String @id @db.VarChar(255) - email String? @db.VarChar(255) - password String? @db.VarChar(255) - createdAt DateTime @db.DateTime(0) - updatedAt DateTime @db.DateTime(0) - placeholder String? @db.Text - imgId String? @db.VarChar(255) - User_Role User_Role[] + id String @id @db.VarChar(255) + name String @db.VarChar(20) + username String @unique @db.VarChar(255) + email String? @unique @db.VarChar(255) + emailVerified Boolean + createdAt DateTime @db.DateTime(0) + updatedAt DateTime @db.DateTime(0) + image String? @db.VarChar(255) + + roles User_Role[] albumHistories albumHistories[] comments comments[] favorites favorites[] @@ -527,6 +529,7 @@ model users { ratings ratings[] submissions submissions[] sessions session[] + accounts account[] } model session { @@ -539,7 +542,7 @@ model session { createdAt DateTime updatedAt DateTime - user users @relation(fields: [userId], references: [username]) + user users @relation(fields: [userId], references: [id]) } model verification { @@ -550,3 +553,21 @@ model verification { createdAt DateTime updatedAt DateTime } + +model account { + id String @id + userId String + accountId String + providerId String + accessToken String? + refreshToken String? + accessTokenExpiresAt DateTime? + refreshTokenExpiresAt DateTime? + scope String? + idToken String? + password String? + createdAt DateTime + updatedAt DateTime + + user users @relation(fields: [userId], references: [id]) +}