ok screw it not doing automatic migration

This commit is contained in:
Michael Zhang 2023-09-05 21:29:55 -05:00
parent bbdb03e377
commit b5b154747d
5 changed files with 376 additions and 317 deletions

2
.gitignore vendored
View file

@ -37,4 +37,4 @@ next-env.d.ts
dev.db
docker-data
/data.sql
/data*.sql

View file

@ -1,205 +0,0 @@
-- CreateTable
CREATE TABLE `apikeys` (
`ApiID` INTEGER NOT NULL AUTO_INCREMENT,
`Name` TEXT NULL,
`ApiKey` TEXT NULL,
`UserID` INTEGER NULL,
UNIQUE INDEX `ApiKey`(`ApiKey`(255)),
PRIMARY KEY (`ApiID`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `beatmap_creators` (
`BeatmapID` INTEGER NOT NULL,
`CreatorID` INTEGER NOT NULL,
INDEX `idx_BeatmapID`(`BeatmapID`),
PRIMARY KEY (`BeatmapID`, `CreatorID`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `beatmap_edit_requests` (
`EditID` INTEGER NOT NULL AUTO_INCREMENT,
`BeatmapID` INTEGER NULL,
`SetID` INTEGER NULL,
`UserID` INTEGER NOT NULL,
`EditData` JSON NOT NULL,
`Timestamp` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
`Status` ENUM('Pending', 'Denied', 'Approved') NULL DEFAULT 'Pending',
`EditorID` INTEGER NULL,
PRIMARY KEY (`EditID`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `beatmaps` (
`BeatmapID` MEDIUMINT UNSIGNED NOT NULL,
`SetID` MEDIUMINT UNSIGNED NULL,
`SetCreatorID` INTEGER NULL,
`DifficultyName` VARCHAR(255) NULL,
`Mode` TINYINT UNSIGNED NOT NULL DEFAULT 0,
`Status` TINYINT NOT NULL DEFAULT 0,
`SR` FLOAT NOT NULL DEFAULT 0,
`Rating` VARCHAR(45) NULL,
`ChartRank` INTEGER NULL,
`ChartYearRank` INTEGER NULL,
`Timestamp` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
`RatingCount` INTEGER NULL,
`WeightedAvg` FLOAT NULL,
`Genre` INTEGER NULL,
`Lang` INTEGER NULL,
`Artist` VARCHAR(255) NULL,
`Title` VARCHAR(255) NULL,
`DateRanked` TIMESTAMP(0) NULL,
`Blacklisted` BOOLEAN NOT NULL DEFAULT false,
`BlacklistReason` TEXT NULL,
`controversy` DECIMAL(10, 8) NULL,
INDEX `Artist`(`DifficultyName`, `Artist`, `Title`),
INDEX `beatmapset_id`(`SetID`),
PRIMARY KEY (`BeatmapID`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `beatmapset_nominators` (
`SetID` INTEGER NULL,
`NominatorID` INTEGER NULL,
`Mode` INTEGER NULL,
INDEX `beatmapset_nominators_SetID_index`(`SetID`),
UNIQUE INDEX `beatmapset_nominators_pk`(`SetID`, `NominatorID`, `Mode`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `blacklist` (
`UserID` INTEGER NOT NULL,
PRIMARY KEY (`UserID`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `comments` (
`CommentID` INTEGER NOT NULL AUTO_INCREMENT,
`UserID` INTEGER NOT NULL,
`SetID` INTEGER NOT NULL,
`Comment` TEXT NULL,
`date` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
PRIMARY KEY (`CommentID`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `descriptor_votes` (
`VoteID` INTEGER NOT NULL AUTO_INCREMENT,
`BeatmapID` INTEGER NOT NULL,
`UserID` INTEGER NOT NULL,
`Vote` BOOLEAN NOT NULL,
`DescriptorID` INTEGER NOT NULL,
INDEX `descriptor_votes_BeatmapID_index`(`BeatmapID`),
UNIQUE INDEX `descriptor_votes_pk2`(`BeatmapID`, `UserID`, `DescriptorID`),
PRIMARY KEY (`VoteID`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `descriptors` (
`DescriptorID` INTEGER NOT NULL AUTO_INCREMENT,
`Name` VARCHAR(40) NOT NULL,
`ShortDescription` TEXT NULL,
`ParentID` INTEGER NULL,
`Usable` BOOLEAN NOT NULL DEFAULT true,
UNIQUE INDEX `descriptors_pk2`(`Name`),
PRIMARY KEY (`DescriptorID`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `logs` (
`LogID` INTEGER NOT NULL AUTO_INCREMENT,
`UserID` INTEGER NOT NULL,
`LogData` JSON NULL,
PRIMARY KEY (`LogID`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `mappernames` (
`UserID` INTEGER NOT NULL,
`Username` VARCHAR(255) NULL,
PRIMARY KEY (`UserID`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `rating_tags` (
`UserID` INTEGER NULL,
`BeatmapID` INTEGER NULL,
`Tag` VARCHAR(150) NULL,
`TagID` INTEGER NOT NULL AUTO_INCREMENT,
UNIQUE INDEX `rating_tags_pk`(`BeatmapID`, `UserID`, `Tag`),
PRIMARY KEY (`TagID`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `ratings` (
`RatingID` INTEGER NOT NULL AUTO_INCREMENT,
`BeatmapID` INTEGER NOT NULL,
`UserID` INTEGER NOT NULL,
`Score` DECIMAL(2, 1) NULL,
`date` DATETIME(0) NOT NULL,
INDEX `idx_beatmapID`(`BeatmapID`),
PRIMARY KEY (`RatingID`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `setretrieveinfo` (
`LastRetrieval` DATETIME(0) NULL,
`LastDate` DATE NULL
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `user_correlations` (
`user1_id` INTEGER NULL,
`user2_id` INTEGER NULL,
`correlation` FLOAT NULL,
UNIQUE INDEX `user_correlations_pk`(`user1_id`, `user2_id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `user_relations` (
`UserIDFrom` INTEGER NULL,
`UserIDTo` INTEGER NULL,
`type` INTEGER NULL,
UNIQUE INDEX `user_relations_pk`(`UserIDTo`, `UserIDFrom`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `users` (
`UserID` INTEGER NOT NULL,
`Username` VARCHAR(255) NULL,
`AccessToken` VARCHAR(2000) NULL,
`RefreshToken` VARCHAR(2000) NULL,
`banned` BOOLEAN NULL DEFAULT false,
`Weight` DECIMAL(6, 4) NULL,
`DoTrueRandom` BOOLEAN NOT NULL DEFAULT false,
`Custom00Rating` VARCHAR(60) NOT NULL DEFAULT '',
`Custom05Rating` VARCHAR(60) NOT NULL DEFAULT '',
`Custom10Rating` VARCHAR(60) NOT NULL DEFAULT '',
`Custom15Rating` VARCHAR(60) NOT NULL DEFAULT '',
`Custom20Rating` VARCHAR(60) NOT NULL DEFAULT '',
`Custom25Rating` VARCHAR(60) NOT NULL DEFAULT '',
`Custom30Rating` VARCHAR(60) NOT NULL DEFAULT '',
`Custom35Rating` VARCHAR(60) NOT NULL DEFAULT '',
`Custom40Rating` VARCHAR(60) NOT NULL DEFAULT '',
`Custom45Rating` VARCHAR(60) NOT NULL DEFAULT '',
`Custom50Rating` VARCHAR(60) NOT NULL DEFAULT '',
`LastAccessedSite` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
`HideRatings` BOOLEAN NULL DEFAULT false,
PRIMARY KEY (`UserID`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

View file

@ -0,0 +1,246 @@
-- CreateTable
CREATE TABLE `ApiKey` (
`ApiKey` VARCHAR(191) NOT NULL,
`Name` VARCHAR(191) NOT NULL,
`UserID` INTEGER NOT NULL,
PRIMARY KEY (`ApiKey`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `BeatmapCreator` (
`BeatmapID` INTEGER NOT NULL,
`CreatorID` INTEGER NOT NULL,
INDEX `idx_BeatmapID`(`BeatmapID`),
PRIMARY KEY (`BeatmapID`, `CreatorID`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `BeatmapEditRequest` (
`EditID` INTEGER NOT NULL AUTO_INCREMENT,
`BeatmapID` INTEGER NOT NULL,
`UserID` INTEGER NOT NULL,
`EditData` JSON NOT NULL,
`Timestamp` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
`Status` ENUM('Pending', 'Denied', 'Approved') NOT NULL DEFAULT 'Pending',
`EditorID` INTEGER NULL,
PRIMARY KEY (`EditID`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `Beatmap` (
`BeatmapID` INTEGER NOT NULL,
`SetID` INTEGER NOT NULL,
`DifficultyName` VARCHAR(191) NOT NULL,
`Mode` INTEGER NOT NULL,
`Status` INTEGER NOT NULL,
`SR` DOUBLE NOT NULL,
`Rating` VARCHAR(45) NULL,
`ChartRank` INTEGER NULL,
`ChartYearRank` INTEGER NULL,
`Timestamp` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
`RatingCount` INTEGER NULL,
`WeightedAvg` FLOAT NULL,
`Blacklisted` BOOLEAN NOT NULL DEFAULT false,
`BlacklistReason` TEXT NULL,
`controversy` DECIMAL(10, 8) NULL,
PRIMARY KEY (`BeatmapID`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `BeatmapSet` (
`SetID` INTEGER NOT NULL,
`HostID` INTEGER NOT NULL,
`Genre` INTEGER NOT NULL,
`Lang` INTEGER NOT NULL,
`Artist` VARCHAR(191) NOT NULL,
`ArtistUnicode` VARCHAR(191) NOT NULL,
`Title` VARCHAR(191) NOT NULL,
`TitleUnicode` VARCHAR(191) NOT NULL,
`DateRanked` TIMESTAMP(0) NOT NULL,
FULLTEXT INDEX `BeatmapSet_Title_Artist_idx`(`Title`, `Artist`),
PRIMARY KEY (`SetID`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `BeatmapSetNominator` (
`SetID` INTEGER NULL,
`NominatorID` INTEGER NULL,
`Mode` INTEGER NULL,
INDEX `beatmapset_nominators_SetID_index`(`SetID`),
UNIQUE INDEX `beatmapset_nominators_pk`(`SetID`, `NominatorID`, `Mode`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `Comment` (
`CommentID` INTEGER NOT NULL AUTO_INCREMENT,
`UserID` INTEGER NOT NULL,
`SetID` INTEGER NOT NULL,
`Content` VARCHAR(191) NOT NULL,
`DatePosted` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
PRIMARY KEY (`CommentID`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `DescriptorVote` (
`VoteID` INTEGER NOT NULL AUTO_INCREMENT,
`BeatmapID` INTEGER NOT NULL,
`UserID` INTEGER NOT NULL,
`Vote` BOOLEAN NOT NULL,
`DescriptorID` INTEGER NOT NULL,
UNIQUE INDEX `descriptor_votes_pk2`(`BeatmapID`, `UserID`, `DescriptorID`),
PRIMARY KEY (`VoteID`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `Descriptor` (
`DescriptorID` INTEGER NOT NULL AUTO_INCREMENT,
`Name` VARCHAR(40) NOT NULL,
`ShortDescription` TEXT NULL,
`ParentID` INTEGER NULL,
`Usable` BOOLEAN NOT NULL DEFAULT true,
UNIQUE INDEX `descriptors_pk2`(`Name`),
PRIMARY KEY (`DescriptorID`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `Log` (
`LogID` INTEGER NOT NULL AUTO_INCREMENT,
`UserID` INTEGER NOT NULL,
`LogData` JSON NOT NULL,
PRIMARY KEY (`LogID`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `RatingTag` (
`TagID` INTEGER NOT NULL AUTO_INCREMENT,
`UserID` INTEGER NOT NULL,
`BeatmapID` INTEGER NOT NULL,
`Tag` VARCHAR(191) NOT NULL,
UNIQUE INDEX `RatingTag_BeatmapID_UserID_Tag_key`(`BeatmapID`, `UserID`, `Tag`),
PRIMARY KEY (`TagID`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `Rating` (
`RatingID` INTEGER NOT NULL AUTO_INCREMENT,
`BeatmapID` INTEGER NOT NULL,
`UserID` INTEGER NOT NULL,
`Score` DECIMAL(2, 1) NOT NULL,
`DateRated` DATETIME(3) NOT NULL,
PRIMARY KEY (`RatingID`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `SetRetrieveInfo` (
`Id` INTEGER NOT NULL,
`LastRetrieval` DATETIME(3) NOT NULL,
`LastDate` DATETIME(3) NOT NULL,
PRIMARY KEY (`Id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `UserCorrelation` (
`User1ID` INTEGER NOT NULL,
`User2ID` INTEGER NOT NULL,
`Correlation` DOUBLE NOT NULL,
`Data` JSON NOT NULL,
UNIQUE INDEX `user_correlations_pk`(`User1ID`, `User2ID`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `user_relations` (
`UserIDFrom` INTEGER NULL,
`UserIDTo` INTEGER NULL,
`type` INTEGER NULL,
UNIQUE INDEX `user_relations_pk`(`UserIDTo`, `UserIDFrom`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `OmdbUser` (
`UserID` INTEGER NOT NULL,
`AccessToken` VARCHAR(191) NOT NULL,
`RefreshToken` VARCHAR(191) NOT NULL,
`Weight` DECIMAL(6, 4) NOT NULL,
`DoTrueRandom` BOOLEAN NOT NULL DEFAULT false,
`CustomRatings` JSON NOT NULL,
`LastAccessedSite` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
`HideRatings` BOOLEAN NOT NULL DEFAULT false,
`IsBlacklisted` BOOLEAN NOT NULL DEFAULT false,
PRIMARY KEY (`UserID`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `OsuUser` (
`UserID` INTEGER NOT NULL,
`Username` VARCHAR(255) NOT NULL,
`Banned` BOOLEAN NOT NULL DEFAULT false,
PRIMARY KEY (`UserID`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- AddForeignKey
ALTER TABLE `ApiKey` ADD CONSTRAINT `ApiKey_UserID_fkey` FOREIGN KEY (`UserID`) REFERENCES `OmdbUser`(`UserID`) ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `BeatmapEditRequest` ADD CONSTRAINT `BeatmapEditRequest_UserID_fkey` FOREIGN KEY (`UserID`) REFERENCES `OmdbUser`(`UserID`) ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `Beatmap` ADD CONSTRAINT `Beatmap_SetID_fkey` FOREIGN KEY (`SetID`) REFERENCES `BeatmapSet`(`SetID`) ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `BeatmapSet` ADD CONSTRAINT `BeatmapSet_HostID_fkey` FOREIGN KEY (`HostID`) REFERENCES `OsuUser`(`UserID`) ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `Comment` ADD CONSTRAINT `Comment_UserID_fkey` FOREIGN KEY (`UserID`) REFERENCES `OmdbUser`(`UserID`) ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `Comment` ADD CONSTRAINT `Comment_SetID_fkey` FOREIGN KEY (`SetID`) REFERENCES `BeatmapSet`(`SetID`) ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `DescriptorVote` ADD CONSTRAINT `DescriptorVote_BeatmapID_fkey` FOREIGN KEY (`BeatmapID`) REFERENCES `Beatmap`(`BeatmapID`) ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `DescriptorVote` ADD CONSTRAINT `DescriptorVote_UserID_fkey` FOREIGN KEY (`UserID`) REFERENCES `OmdbUser`(`UserID`) ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `DescriptorVote` ADD CONSTRAINT `DescriptorVote_DescriptorID_fkey` FOREIGN KEY (`DescriptorID`) REFERENCES `Descriptor`(`DescriptorID`) ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `Log` ADD CONSTRAINT `Log_UserID_fkey` FOREIGN KEY (`UserID`) REFERENCES `OmdbUser`(`UserID`) ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `RatingTag` ADD CONSTRAINT `RatingTag_UserID_fkey` FOREIGN KEY (`UserID`) REFERENCES `OmdbUser`(`UserID`) ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `RatingTag` ADD CONSTRAINT `RatingTag_BeatmapID_fkey` FOREIGN KEY (`BeatmapID`) REFERENCES `Beatmap`(`BeatmapID`) ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `Rating` ADD CONSTRAINT `Rating_BeatmapID_fkey` FOREIGN KEY (`BeatmapID`) REFERENCES `Beatmap`(`BeatmapID`) ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `Rating` ADD CONSTRAINT `Rating_UserID_fkey` FOREIGN KEY (`UserID`) REFERENCES `OmdbUser`(`UserID`) ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `UserCorrelation` ADD CONSTRAINT `UserCorrelation_User1ID_fkey` FOREIGN KEY (`User1ID`) REFERENCES `OmdbUser`(`UserID`) ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `UserCorrelation` ADD CONSTRAINT `UserCorrelation_User2ID_fkey` FOREIGN KEY (`User2ID`) REFERENCES `OmdbUser`(`UserID`) ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `OmdbUser` ADD CONSTRAINT `OmdbUser_UserID_fkey` FOREIGN KEY (`UserID`) REFERENCES `OsuUser`(`UserID`) ON DELETE RESTRICT ON UPDATE CASCADE;

View file

@ -1,5 +1,6 @@
generator client {
provider = "prisma-client-js"
provider = "prisma-client-js"
previewFeatures = ["fullTextIndex"]
}
datasource db {
@ -8,12 +9,11 @@ datasource db {
}
model ApiKey {
ApiID Int @id @default(autoincrement())
Name String? @db.Text
ApiKey String? @unique(map: "ApiKey", length: 255) @db.Text
UserID Int?
ApiKey String @id
Name String
UserID Int
@@map("apikeys")
User OmdbUser @relation(fields: [UserID], references: [UserID])
}
model BeatmapCreator {
@ -22,48 +22,62 @@ model BeatmapCreator {
@@id([BeatmapID, CreatorID])
@@index([BeatmapID], map: "idx_BeatmapID")
@@map("beatmap_creators")
}
model BeatmapEditRequest {
EditID Int @id @default(autoincrement())
BeatmapID Int?
SetID Int?
EditID Int @id @default(autoincrement())
BeatmapID Int
UserID Int
EditData Json
Timestamp DateTime @default(now()) @db.Timestamp(0)
Status BeatmapEditRequestStatus? @default(Pending)
Timestamp DateTime @default(now())
Status BeatmapEditRequestStatus @default(Pending)
EditorID Int?
@@map("beatmap_edit_requests")
User OmdbUser @relation(fields: [UserID], references: [UserID])
}
model Beatmap {
BeatmapID Int @id @db.UnsignedMediumInt
SetID Int? @db.UnsignedMediumInt
SetCreatorID Int?
DifficultyName String? @db.VarChar(255)
Mode Int @default(0) @db.UnsignedTinyInt
Status Int @default(0) @db.TinyInt
SR Float @default(0) @db.Float
BeatmapID Int @id
SetID Int
DifficultyName String
Mode Int
Status Int
SR Float
Rating String? @db.VarChar(45)
ChartRank Int?
ChartYearRank Int?
Timestamp DateTime? @default(now()) @db.Timestamp(0)
RatingCount Int?
WeightedAvg Float? @db.Float
Genre Int?
Lang Int?
Artist String? @db.VarChar(255)
Title String? @db.VarChar(255)
DateRanked DateTime? @db.Timestamp(0)
Blacklisted Boolean @default(false)
BlacklistReason String? @db.Text
controversy Decimal? @db.Decimal(10, 8)
@@index([DifficultyName, Artist, Title], map: "Artist")
@@index([SetID], map: "beatmapset_id")
@@map("beatmaps")
BeatmapSet BeatmapSet @relation(fields: [SetID], references: [SetID])
RatingTags RatingTag[]
DescriptorVotes DescriptorVote[]
Ratings Rating[]
}
model BeatmapSet {
SetID Int @id
HostID Int
Genre Int
Lang Int
Artist String
ArtistUnicode String
Title String
TitleUnicode String
DateRanked DateTime @db.Timestamp(0)
Host OsuUser @relation(fields: [HostID], references: [UserID])
Beatmaps Beatmap[]
Comments Comment[]
@@fulltext([Title, Artist])
}
/// The underlying table does not contain a valid unique identifier and can therefore currently not be handled by Prisma Client.
@ -74,24 +88,18 @@ model BeatmapSetNominator {
@@unique([SetID, NominatorID, Mode], map: "beatmapset_nominators_pk")
@@index([SetID], map: "beatmapset_nominators_SetID_index")
@@map("beatmapset_nominators")
@@ignore
}
model Blacklist {
UserID Int @id
@@map("blacklist")
}
model Comment {
CommentID Int @id @default(autoincrement())
UserID Int
SetID Int
Comment String? @db.Text
date DateTime? @default(now()) @db.Timestamp(0)
CommentID Int @id @default(autoincrement())
UserID Int
SetID Int
Content String
DatePosted DateTime @default(now())
@@map("comments")
User OmdbUser @relation(fields: [UserID], references: [UserID])
BeatmapSet BeatmapSet @relation(fields: [SetID], references: [SetID])
}
model DescriptorVote {
@ -101,9 +109,11 @@ model DescriptorVote {
Vote Boolean
DescriptorID Int
Beatmap Beatmap @relation(fields: [BeatmapID], references: [BeatmapID])
User OmdbUser @relation(fields: [UserID], references: [UserID])
Descriptor Descriptor @relation(fields: [DescriptorID], references: [DescriptorID])
@@unique([BeatmapID, UserID, DescriptorID], map: "descriptor_votes_pk2")
@@index([BeatmapID], map: "descriptor_votes_BeatmapID_index")
@@map("descriptor_votes")
}
model Descriptor {
@ -113,63 +123,59 @@ model Descriptor {
ParentID Int?
Usable Boolean @default(true)
@@map("descriptors")
DescriptorVote DescriptorVote[]
}
model Log {
LogID Int @id @default(autoincrement())
LogID Int @id @default(autoincrement())
UserID Int
LogData Json?
LogData Json
@@map("logs")
}
model MapperName {
UserID Int @id
Username String? @db.VarChar(255)
@@map("mappernames")
User OmdbUser @relation(fields: [UserID], references: [UserID])
}
model RatingTag {
UserID Int?
BeatmapID Int?
Tag String? @db.VarChar(150)
TagID Int @id @default(autoincrement())
TagID Int @id @default(autoincrement())
UserID Int
BeatmapID Int
Tag String
@@unique([BeatmapID, UserID, Tag], map: "rating_tags_pk")
@@map("rating_tags")
User OmdbUser @relation(fields: [UserID], references: [UserID])
Beatmap Beatmap @relation(fields: [BeatmapID], references: [BeatmapID])
@@unique([BeatmapID, UserID, Tag])
}
model Rating {
RatingID Int @id @default(autoincrement())
BeatmapID Int
UserID Int
Score Decimal? @db.Decimal(2, 1)
date DateTime @db.DateTime(0)
Score Decimal @db.Decimal(2, 1)
DateRated DateTime
@@index([BeatmapID], map: "idx_beatmapID")
@@map("ratings")
Beatmap Beatmap @relation(fields: [BeatmapID], references: [BeatmapID])
User OmdbUser @relation(fields: [UserID], references: [UserID])
}
/// The underlying table does not contain a valid unique identifier and can therefore currently not be handled by Prisma Client.
model SetRetrieveInfo {
LastRetrieval DateTime? @db.DateTime(0)
LastDate DateTime? @db.Date
@@map("setretrieveinfo")
@@ignore
Id Int @id
LastRetrieval DateTime
LastDate DateTime
}
/// The underlying table does not contain a valid unique identifier and can therefore currently not be handled by Prisma Client.
model UserCorrelation {
user1_id Int?
user2_id Int?
correlation Float? @db.Float
User1ID Int
User2ID Int
@@unique([user1_id, user2_id], map: "user_correlations_pk")
@@map("user_correlations")
@@ignore
Correlation Float
Data Json
User1 OmdbUser @relation(name: "user1", fields: [User1ID], references: [UserID])
User2 OmdbUser @relation(name: "user2", fields: [User2ID], references: [UserID])
@@unique([User1ID, User2ID], map: "user_correlations_pk")
}
/// The underlying table does not contain a valid unique identifier and can therefore currently not be handled by Prisma Client.
@ -183,35 +189,43 @@ model UserRelation {
@@ignore
}
model User {
UserID Int @id
Username String? @db.VarChar(255)
AccessToken String? @db.VarChar(2000)
RefreshToken String? @db.VarChar(2000)
banned Boolean? @default(false)
Weight Decimal? @db.Decimal(6, 4)
DoTrueRandom Boolean @default(false)
Custom00Rating String @default("") @db.VarChar(60)
Custom05Rating String @default("") @db.VarChar(60)
Custom10Rating String @default("") @db.VarChar(60)
Custom15Rating String @default("") @db.VarChar(60)
Custom20Rating String @default("") @db.VarChar(60)
Custom25Rating String @default("") @db.VarChar(60)
Custom30Rating String @default("") @db.VarChar(60)
Custom35Rating String @default("") @db.VarChar(60)
Custom40Rating String @default("") @db.VarChar(60)
Custom45Rating String @default("") @db.VarChar(60)
Custom50Rating String @default("") @db.VarChar(60)
LastAccessedSite DateTime @default(now()) @db.Timestamp(0)
HideRatings Boolean? @default(false)
model OmdbUser {
UserID Int @id
@@map("users")
AccessToken String
RefreshToken String
Weight Decimal @db.Decimal(6, 4)
DoTrueRandom Boolean @default(false)
CustomRatings Json @default("{}")
LastAccessedSite DateTime @default(now())
HideRatings Boolean @default(false)
IsBlacklisted Boolean @default(false)
ApiKeys ApiKey[]
OsuUser OsuUser @relation(fields: [UserID], references: [UserID])
RatingTags RatingTag[]
BeatmapEditRequests BeatmapEditRequest[]
Comments Comment[]
DescriptorVotes DescriptorVote[]
Ratings Rating[]
Log Log[]
User1Correlation UserCorrelation[] @relation("user1")
User2Correlation UserCorrelation[] @relation("user2")
}
model OsuUser {
UserID Int @id
Username String @db.VarChar(255)
Banned Boolean @default(false)
OmdbUser OmdbUser?
HostedBeatmapSets BeatmapSet[]
}
enum BeatmapEditRequestStatus {
Pending
Denied
Approved
@@map("beatmap_edit_requests_Status")
}

View file

@ -6,14 +6,17 @@ import StarRatingDisplay from "./StarRatingDisplay";
export async function getData() {
const prisma = new PrismaClient();
const ratings = await prisma.ratings.findMany({ take: 20 });
const comments = await prisma.comments.findMany({ take: 20 });
const ratings = await prisma.rating.findMany({
take: 20,
include: { Beatmap: { select: { SetID: true } } },
});
const comments = await prisma.comment.findMany({ take: 20 });
return { ratings, comments };
}
export default async function RatingTable() {
const { ratings} = await getData();
const { ratings } = await getData();
return (
<div
@ -23,9 +26,9 @@ export default async function RatingTable() {
return (
<div className={classNames(styles.ratingContainer)}>
<div className={styles.setImage}>
<a href={`/mapset/${rating.SetID}`}>
<a href={`/mapset/${rating.Beatmap.SetID}`}>
<img
src={`https://b.ppy.sh/thumb/${rating.SetID}l.jpg`}
src={`https://b.ppy.sh/thumb/${rating.Beatmap.SetID}l.jpg`}
className={styles.diffThumb}
// onerror="this.onerror=null; this.src='/charts/INF.png';"
/>
@ -40,15 +43,16 @@ export default async function RatingTable() {
/>
</a>
</div>
<div className="flex-child" style={{flex:"0 0 66%"}}>
{/* <a style="display:flex;" href="/profile/<?php echo $row["UserID"]; ?>">
<div className="flex-child" style={{ flex: "0 0 66%" }}>
{/* <a style="display:flex;" href="/profile/<?php echo $row["UserID"]; ?>">
<?php echo GetUserNameFromId($row["UserID"], $conn); ?>
</a> */}
<StarRatingDisplay rating={rating.Score} /> on
<a href={`/mapset/${rating.SetID}`}>" . mb_strimwidth(htmlspecialchars($row["DifficultyName"]), 0, 35, "...") . "</a>";
?>
</div>
<StarRatingDisplay rating={rating.Score} /> on
<a href={`/mapset/${rating.Beatmap.SetID}`}>
{/* mb_strimwidth(htmlspecialchars($row["DifficultyName"]), 0, 35, "...") . "</a>"; */}
</a>
</div>
</div>
);
})}