first commit
This commit is contained in:
164
prisma/migrations/20260323202159_test1/migration.sql
Normal file
164
prisma/migrations/20260323202159_test1/migration.sql
Normal file
@@ -0,0 +1,164 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE `user` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`name` TEXT NOT NULL,
|
||||
`email` VARCHAR(191) NOT NULL,
|
||||
`emailVerified` BOOLEAN NOT NULL DEFAULT false,
|
||||
`image` TEXT NULL,
|
||||
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updatedAt` DATETIME(3) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `user_email_key`(`email`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `session` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`expiresAt` DATETIME(3) NOT NULL,
|
||||
`token` VARCHAR(191) NOT NULL,
|
||||
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updatedAt` DATETIME(3) NOT NULL,
|
||||
`ipAddress` TEXT NULL,
|
||||
`userAgent` TEXT NULL,
|
||||
`userId` VARCHAR(191) NOT NULL,
|
||||
|
||||
INDEX `session_userId_idx`(`userId`(191)),
|
||||
UNIQUE INDEX `session_token_key`(`token`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `account` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`accountId` TEXT NOT NULL,
|
||||
`providerId` TEXT NOT NULL,
|
||||
`userId` VARCHAR(191) NOT NULL,
|
||||
`accessToken` TEXT NULL,
|
||||
`refreshToken` TEXT NULL,
|
||||
`idToken` TEXT NULL,
|
||||
`accessTokenExpiresAt` DATETIME(3) NULL,
|
||||
`refreshTokenExpiresAt` DATETIME(3) NULL,
|
||||
`scope` TEXT NULL,
|
||||
`password` TEXT NULL,
|
||||
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updatedAt` DATETIME(3) NOT NULL,
|
||||
|
||||
INDEX `account_userId_idx`(`userId`(191)),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `verification` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`identifier` TEXT NOT NULL,
|
||||
`value` TEXT NOT NULL,
|
||||
`expiresAt` DATETIME(3) NOT NULL,
|
||||
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updatedAt` DATETIME(3) NOT NULL,
|
||||
|
||||
INDEX `verification_identifier_idx`(`identifier`(191)),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `Exercise` (
|
||||
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||
`name` VARCHAR(191) NOT NULL,
|
||||
`muscleGroup` VARCHAR(191) NOT NULL,
|
||||
`SFR` DECIMAL(65, 30) NOT NULL,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `MesoCycle` (
|
||||
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||
`name` VARCHAR(191) NOT NULL,
|
||||
`totalWeeks` INTEGER NOT NULL,
|
||||
`currentWeek` INTEGER NOT NULL,
|
||||
`isAsync` BOOLEAN NOT NULL,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `MesoCycleDay` (
|
||||
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||
`weekday` VARCHAR(191) NULL,
|
||||
`orderIndex` INTEGER NOT NULL,
|
||||
`mesoCycleId` INTEGER NOT NULL,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `MesoCycleExercise` (
|
||||
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||
`startingSets` INTEGER NOT NULL,
|
||||
`orderIndex` INTEGER NOT NULL,
|
||||
`mesoCycleDayId` INTEGER NOT NULL,
|
||||
`exerciseId` INTEGER NOT NULL,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `WorkoutSession` (
|
||||
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||
`weekNumber` INTEGER NOT NULL,
|
||||
`isDeload` BOOLEAN NOT NULL,
|
||||
`completedAt` DATETIME(3) NULL,
|
||||
`mesoCycleDayId` INTEGER NOT NULL,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `ExerciseLog` (
|
||||
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||
`sets` INTEGER NOT NULL,
|
||||
`reps` INTEGER NOT NULL,
|
||||
`weight` DECIMAL(65, 30) NOT NULL,
|
||||
`workoutSessionId` INTEGER NOT NULL,
|
||||
`mesoCycleExerciseId` INTEGER NOT NULL,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `SessionFeedback` (
|
||||
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||
`question` VARCHAR(191) NOT NULL,
|
||||
`answer` VARCHAR(191) NOT NULL,
|
||||
`exerciseLogId` INTEGER 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;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `account` ADD CONSTRAINT `account_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `user`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `MesoCycleDay` ADD CONSTRAINT `MesoCycleDay_mesoCycleId_fkey` FOREIGN KEY (`mesoCycleId`) REFERENCES `MesoCycle`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `MesoCycleExercise` ADD CONSTRAINT `MesoCycleExercise_mesoCycleDayId_fkey` FOREIGN KEY (`mesoCycleDayId`) REFERENCES `MesoCycleDay`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `MesoCycleExercise` ADD CONSTRAINT `MesoCycleExercise_exerciseId_fkey` FOREIGN KEY (`exerciseId`) REFERENCES `Exercise`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `WorkoutSession` ADD CONSTRAINT `WorkoutSession_mesoCycleDayId_fkey` FOREIGN KEY (`mesoCycleDayId`) REFERENCES `MesoCycleDay`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `ExerciseLog` ADD CONSTRAINT `ExerciseLog_workoutSessionId_fkey` FOREIGN KEY (`workoutSessionId`) REFERENCES `WorkoutSession`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `ExerciseLog` ADD CONSTRAINT `ExerciseLog_mesoCycleExerciseId_fkey` FOREIGN KEY (`mesoCycleExerciseId`) REFERENCES `MesoCycleExercise`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `SessionFeedback` ADD CONSTRAINT `SessionFeedback_exerciseLogId_fkey` FOREIGN KEY (`exerciseLogId`) REFERENCES `ExerciseLog`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
3
prisma/migrations/migration_lock.toml
Normal file
3
prisma/migrations/migration_lock.toml
Normal file
@@ -0,0 +1,3 @@
|
||||
# Please do not edit this file manually
|
||||
# It should be added in your version-control system (e.g., Git)
|
||||
provider = "mysql"
|
||||
155
prisma/schema.prisma
Normal file
155
prisma/schema.prisma
Normal file
@@ -0,0 +1,155 @@
|
||||
// This is your Prisma schema file,
|
||||
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
||||
|
||||
// Get a free hosted Postgres database in seconds: `npx create-db`
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client"
|
||||
output = "../generated/prisma"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "mysql"
|
||||
}
|
||||
model User {
|
||||
id String @id
|
||||
name String @db.Text
|
||||
email String
|
||||
emailVerified Boolean @default(false)
|
||||
image String? @db.Text
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
sessions Session[]
|
||||
accounts Account[]
|
||||
|
||||
@@unique([email])
|
||||
@@map("user")
|
||||
}
|
||||
|
||||
model Session {
|
||||
id String @id
|
||||
expiresAt DateTime
|
||||
token String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
ipAddress String? @db.Text
|
||||
userAgent String? @db.Text
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([token])
|
||||
@@index([userId(length: 191)])
|
||||
@@map("session")
|
||||
}
|
||||
|
||||
model Account {
|
||||
id String @id
|
||||
accountId String @db.Text
|
||||
providerId String @db.Text
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
accessToken String? @db.Text
|
||||
refreshToken String? @db.Text
|
||||
idToken String? @db.Text
|
||||
accessTokenExpiresAt DateTime?
|
||||
refreshTokenExpiresAt DateTime?
|
||||
scope String? @db.Text
|
||||
password String? @db.Text
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@index([userId(length: 191)])
|
||||
@@map("account")
|
||||
}
|
||||
|
||||
model Verification {
|
||||
id String @id
|
||||
identifier String @db.Text
|
||||
value String @db.Text
|
||||
expiresAt DateTime
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@index([identifier(length: 191)])
|
||||
@@map("verification")
|
||||
}
|
||||
|
||||
model Exercise {
|
||||
id Int @id @default(autoincrement())
|
||||
name String
|
||||
muscleGroup String
|
||||
SFR Decimal
|
||||
|
||||
mesoCycleExercises MesoCycleExercise[]
|
||||
}
|
||||
|
||||
model MesoCycle {
|
||||
id Int @id @default(autoincrement())
|
||||
name String
|
||||
totalWeeks Int
|
||||
currentWeek Int
|
||||
isAsync Boolean
|
||||
//user User @relation(fields: [userId], references: [id])
|
||||
//userId Int // for
|
||||
mesoCycleDays MesoCycleDay[]
|
||||
}
|
||||
|
||||
model MesoCycleDay {
|
||||
id Int @id @default(autoincrement())
|
||||
weekday String? // If async === NULL
|
||||
orderIndex Int
|
||||
mesoCycle MesoCycle @relation(fields: [mesoCycleId], references: [id])
|
||||
mesoCycleId Int
|
||||
|
||||
mesoCycleExercises MesoCycleExercise[]
|
||||
workOutSessions WorkoutSession[]
|
||||
}
|
||||
|
||||
model MesoCycleExercise {
|
||||
id Int @id @default(autoincrement())
|
||||
startingSets Int
|
||||
orderIndex Int
|
||||
|
||||
mesoCycleDay MesoCycleDay @relation(fields: [mesoCycleDayId], references: [id])
|
||||
mesoCycleDayId Int
|
||||
|
||||
exercise Exercise @relation(fields: [exerciseId], references: [id])
|
||||
exerciseId Int
|
||||
exerciseLogs ExerciseLog[]
|
||||
}
|
||||
|
||||
model WorkoutSession {
|
||||
id Int @id @default(autoincrement())
|
||||
weekNumber Int
|
||||
isDeload Boolean
|
||||
completedAt DateTime? // Null until finished
|
||||
mesoCycleDay MesoCycleDay @relation(fields: [mesoCycleDayId], references: [id])
|
||||
mesoCycleDayId Int
|
||||
//user User @relation(fields: [userId], references: [id])
|
||||
//userId Int
|
||||
|
||||
exerciseLogs ExerciseLog[]
|
||||
}
|
||||
|
||||
model ExerciseLog {
|
||||
id Int @id @default(autoincrement())
|
||||
sets Int
|
||||
reps Int
|
||||
weight Decimal
|
||||
workoutSession WorkoutSession @relation(fields: [workoutSessionId], references: [id])
|
||||
workoutSessionId Int
|
||||
|
||||
mesoCycleExercise MesoCycleExercise @relation(fields: [mesoCycleExerciseId], references: [id])
|
||||
mesoCycleExerciseId Int
|
||||
|
||||
sessionFeedbacks SessionFeedback[]
|
||||
}
|
||||
|
||||
model SessionFeedback {
|
||||
id Int @id @default(autoincrement())
|
||||
question String
|
||||
answer String
|
||||
|
||||
exerciseLog ExerciseLog @relation(fields: [exerciseLogId], references: [id])
|
||||
exerciseLogId Int
|
||||
}
|
||||
Reference in New Issue
Block a user