From 96600e40cf65381d6db478282b647d2871445755 Mon Sep 17 00:00:00 2001 From: Nick Edgar Date: Wed, 9 Aug 2023 11:19:08 -0400 Subject: [PATCH] Remove Note and Post models --- app/models/note.server.ts | 54 --------------- app/models/post.server.ts | 16 ----- app/routes/verification.tsx | 1 - app/session.server.ts | 2 +- .../20220713162558_init/migration.sql | 11 ---- .../migrations/20230328174656_/migration.sql | 8 --- prisma/schema.prisma | 22 ------- prisma/seed.ts | 65 +------------------ 8 files changed, 2 insertions(+), 177 deletions(-) delete mode 100644 app/models/note.server.ts delete mode 100644 app/models/post.server.ts delete mode 100644 prisma/migrations/20230328174656_/migration.sql diff --git a/app/models/note.server.ts b/app/models/note.server.ts deleted file mode 100644 index c266dfc..0000000 --- a/app/models/note.server.ts +++ /dev/null @@ -1,54 +0,0 @@ -import type { User, Note } from "@prisma/client"; - -import { prisma } from "~/db.server"; - -export type { Note } from "@prisma/client"; - -export function getNote({ - id, - userId, -}: Pick & { - userId: User["id"]; -}) { - return prisma.note.findFirst({ - select: { id: true, body: true, title: true }, - where: { id, userId }, - }); -} - -export function getNoteListItems({ userId }: { userId: User["id"] }) { - return prisma.note.findMany({ - where: { userId }, - select: { id: true, title: true }, - orderBy: { updatedAt: "desc" }, - }); -} - -export function createNote({ - body, - title, - userId, -}: Pick & { - userId: User["id"]; -}) { - return prisma.note.create({ - data: { - title, - body, - user: { - connect: { - id: userId, - }, - }, - }, - }); -} - -export function deleteNote({ - id, - userId, -}: Pick & { userId: User["id"] }) { - return prisma.note.deleteMany({ - where: { id, userId }, - }); -} diff --git a/app/models/post.server.ts b/app/models/post.server.ts deleted file mode 100644 index 7c643b7..0000000 --- a/app/models/post.server.ts +++ /dev/null @@ -1,16 +0,0 @@ -import type { Post } from "@prisma/client"; -import { prisma } from "~/db.server"; - -export async function getPosts() { - return prisma.post.findMany(); -} - -export async function getPost(slug: string) { - return prisma.post.findUnique({ where: { slug } }); -} - -export async function createPost( - post: Pick -) { - return prisma.post.create({ data: post }); -} diff --git a/app/routes/verification.tsx b/app/routes/verification.tsx index 3e568b1..4b3bc43 100644 --- a/app/routes/verification.tsx +++ b/app/routes/verification.tsx @@ -77,7 +77,6 @@ export const loader = async ({ const searchParams = new URL(request.url).searchParams; const threadId = searchParams.get("thid"); - console.log("threadId:", threadId); const holderThreadState = threadId ? getHolderThreadState(threadId) : undefined; const verifierThreadState = threadId ? getVerifierThreadState(threadId) : undefined; diff --git a/app/session.server.ts b/app/session.server.ts index f7821be..35286cd 100644 --- a/app/session.server.ts +++ b/app/session.server.ts @@ -10,7 +10,7 @@ const HTTPS_PORTS = [443, 9443]; // const isSecure = process.env.NODE_ENV === "production"; const isSecure = HTTPS_PORTS.includes(Number(process.env.PORT)); -console.log("isSecure:", isSecure); +// console.log("isSecure:", isSecure); export const sessionStorage = createCookieSessionStorage({ cookie: { diff --git a/prisma/migrations/20220713162558_init/migration.sql b/prisma/migrations/20220713162558_init/migration.sql index 121ffe2..9c7adb6 100644 --- a/prisma/migrations/20220713162558_init/migration.sql +++ b/prisma/migrations/20220713162558_init/migration.sql @@ -13,17 +13,6 @@ CREATE TABLE "Password" ( CONSTRAINT "Password_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE ); --- CreateTable -CREATE TABLE "Note" ( - "id" TEXT NOT NULL PRIMARY KEY, - "title" TEXT NOT NULL, - "body" TEXT NOT NULL, - "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" DATETIME NOT NULL, - "userId" TEXT NOT NULL, - CONSTRAINT "Note_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE -); - -- CreateIndex CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); diff --git a/prisma/migrations/20230328174656_/migration.sql b/prisma/migrations/20230328174656_/migration.sql deleted file mode 100644 index 13304af..0000000 --- a/prisma/migrations/20230328174656_/migration.sql +++ /dev/null @@ -1,8 +0,0 @@ --- CreateTable -CREATE TABLE "Post" ( - "slug" TEXT NOT NULL PRIMARY KEY, - "title" TEXT NOT NULL, - "markdown" TEXT NOT NULL, - "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" DATETIME NOT NULL -); diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 83b134e..facb061 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -15,7 +15,6 @@ model User { updatedAt DateTime @updatedAt password Password? - notes Note[] } model Password { @@ -24,24 +23,3 @@ model Password { user User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: Cascade) userId String @unique } - -model Note { - id String @id @default(cuid()) - title String - body String - - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt - - user User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: Cascade) - userId String -} - -model Post { - slug String @id - title String - markdown String - - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt -} diff --git a/prisma/seed.ts b/prisma/seed.ts index 11113d7..8dde1de 100644 --- a/prisma/seed.ts +++ b/prisma/seed.ts @@ -24,71 +24,8 @@ async function seed() { }, }); - await prisma.note.create({ - data: { - title: "My first note", - body: "Hello, world!", - userId: user.id, - }, - }); - - await prisma.note.create({ - data: { - title: "My second note", - body: "Hello, world!", - userId: user.id, - }, - }); - - const posts = [ - { - slug: "my-first-post", - title: "My First Post", - markdown: ` - # This is my first post - - Isn't it great? - `.trim(), - }, - { - slug: "90s-mixtape", - title: "A Mixtape I Made Just For You", - markdown: ` - # 90s Mixtape - - - I wish (Skee-Lo) - - This Is How We Do It (Montell Jordan) - - Everlong (Foo Fighters) - - Ms. Jackson (Outkast) - - Interstate Love Song (Stone Temple Pilots) - - Killing Me Softly With His Song (Fugees, Ms. Lauryn Hill) - - Just a Friend (Biz Markie) - - The Man Who Sold The World (Nirvana) - - Semi-Charmed Life (Third Eye Blind) - - ...Baby One More Time (Britney Spears) - - Better Man (Pearl Jam) - - It's All Coming Back to Me Now (Céline Dion) - - This Kiss (Faith Hill) - - Fly Away (Lenny Kravits) - - Scar Tissue (Red Hot Chili Peppers) - - Santa Monica (Everclear) - - C'mon N' Ride it (Quad City DJ's) - `.trim(), - }, - ]; - - for (const post of posts) { - await prisma.post.upsert({ - where: { slug: post.slug }, - update: post, - create: post, - }); - } - const numUsers = await prisma.user.count(); - const numPosts = await prisma.post.count(); - const numNotes = await prisma.note.count(); - console.log(`Database has been seeded with ${numUsers} users, ${numPosts} posts, and ${numNotes} notes. 🌱`); + console.log(`Database has been seeded with ${numUsers} users. 🌱`); } seed()