From 8c8f387516ed4ab6d63dfb0b00ff35c04741d3dd Mon Sep 17 00:00:00 2001 From: Brandon Egger Date: Wed, 15 Mar 2023 00:01:40 -0500 Subject: [PATCH] switch db to mongodb, add new model for resources --- .../migration.sql | 56 ------------------- prisma/migrations/migration_lock.toml | 3 - prisma/schema.prisma | 54 ++++++++++++++++-- 3 files changed, 48 insertions(+), 65 deletions(-) delete mode 100644 prisma/migrations/20230315042650_first_migration/migration.sql delete mode 100644 prisma/migrations/migration_lock.toml diff --git a/prisma/migrations/20230315042650_first_migration/migration.sql b/prisma/migrations/20230315042650_first_migration/migration.sql deleted file mode 100644 index cbf4707..0000000 --- a/prisma/migrations/20230315042650_first_migration/migration.sql +++ /dev/null @@ -1,56 +0,0 @@ --- CreateTable -CREATE TABLE "Account" ( - "id" TEXT NOT NULL PRIMARY KEY, - "userId" TEXT NOT NULL, - "type" TEXT NOT NULL, - "provider" TEXT NOT NULL, - "providerAccountId" TEXT NOT NULL, - "refresh_token" TEXT, - "access_token" TEXT, - "expires_at" INTEGER, - "token_type" TEXT, - "scope" TEXT, - "id_token" TEXT, - "session_state" TEXT, - CONSTRAINT "Account_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE -); - --- CreateTable -CREATE TABLE "Session" ( - "id" TEXT NOT NULL PRIMARY KEY, - "sessionToken" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "expires" DATETIME NOT NULL, - CONSTRAINT "Session_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE -); - --- CreateTable -CREATE TABLE "User" ( - "id" TEXT NOT NULL PRIMARY KEY, - "name" TEXT, - "email" TEXT, - "emailVerified" DATETIME, - "image" TEXT -); - --- CreateTable -CREATE TABLE "VerificationToken" ( - "identifier" TEXT NOT NULL, - "token" TEXT NOT NULL, - "expires" DATETIME NOT NULL -); - --- CreateIndex -CREATE UNIQUE INDEX "Account_provider_providerAccountId_key" ON "Account"("provider", "providerAccountId"); - --- CreateIndex -CREATE UNIQUE INDEX "Session_sessionToken_key" ON "Session"("sessionToken"); - --- CreateIndex -CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); - --- CreateIndex -CREATE UNIQUE INDEX "VerificationToken_token_key" ON "VerificationToken"("token"); - --- CreateIndex -CREATE UNIQUE INDEX "VerificationToken_identifier_token_key" ON "VerificationToken"("identifier", "token"); diff --git a/prisma/migrations/migration_lock.toml b/prisma/migrations/migration_lock.toml deleted file mode 100644 index e5e5c47..0000000 --- a/prisma/migrations/migration_lock.toml +++ /dev/null @@ -1,3 +0,0 @@ -# Please do not edit this file manually -# It should be added in your version-control system (i.e. Git) -provider = "sqlite" \ No newline at end of file diff --git a/prisma/schema.prisma b/prisma/schema.prisma index a1de28d..bddecc7 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -6,7 +6,7 @@ generator client { } datasource db { - provider = "sqlite" + provider = "mongodb" // NOTE: When using postgresql, mysql or sqlserver, uncomment the @db.Text annotations in model Account below // Further reading: // https://next-auth.js.org/adapters/prisma#create-the-prisma-schema @@ -14,10 +14,51 @@ datasource db { url = env("DATABASE_URL") } +enum Platform { + APP_IOS + APP_ANDROID + WEBSITE + PDF +} + +enum Skill { + ENVIRONMENT + PHONEMES + WORDS + SENTENCES + DISCOURSE + MUSIC + BACKGROUND +} + +enum SkillLevel { + BEGINNER + INTERMEDIATE + ADVANCED +} + +type RangeInput { + min Int + max Int +} + +model AuditoryResource { + id String @id @default(auto()) @map("_id") @db.ObjectId + icon String + name String + description String + manufacturer String + format Platform + ages RangeInput + skills Skill[] + skill_level SkillLevel + cost Float +} + // Necessary for Next auth model Account { - id String @id @default(cuid()) - userId String + id String @id @default(auto()) @map("_id") @db.ObjectId + userId String @db.ObjectId type String provider String providerAccountId String @@ -34,15 +75,15 @@ model Account { } model Session { - id String @id @default(cuid()) + id String @id @default(auto()) @map("_id") @db.ObjectId sessionToken String @unique - userId String + userId String @db.ObjectId expires DateTime user User @relation(fields: [userId], references: [id], onDelete: Cascade) } model User { - id String @id @default(cuid()) + id String @id @default(auto()) @map("_id") @db.ObjectId name String? email String? @unique emailVerified DateTime? @@ -52,6 +93,7 @@ model User { } model VerificationToken { + id String @id @default(auto()) @map("_id") @db.ObjectId identifier String token String @unique expires DateTime