Compare commits
No commits in common. "dd07c259ac2d203c95574270c14fb4df6e61c7a3" and "2375a1fd58f99946f2ec0aaa6ca155304ae7fff0" have entirely different histories.
dd07c259ac
...
2375a1fd58
7
.env
7
.env
|
@ -1,7 +0,0 @@
|
|||
# Environment variables declared in this file are automatically made available to Prisma.
|
||||
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema
|
||||
|
||||
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
|
||||
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
|
||||
|
||||
DATABASE_URL="file:./dev.db"
|
11
package.json
11
package.json
|
@ -1,6 +1,5 @@
|
|||
{
|
||||
"name": "subman-nextjs",
|
||||
"type":"module",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
|
@ -10,18 +9,16 @@
|
|||
"lint": "next lint"
|
||||
},
|
||||
"dependencies": {
|
||||
"@prisma/client": "^5.15.0",
|
||||
"next": "14.2.3",
|
||||
"react": "^18",
|
||||
"react-dom": "^18"
|
||||
"react-dom": "^18",
|
||||
"next": "14.2.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5",
|
||||
"@types/node": "^20",
|
||||
"@types/react": "^18",
|
||||
"@types/react-dom": "^18",
|
||||
"eslint": "^8",
|
||||
"eslint-config-next": "14.2.3",
|
||||
"prisma": "^5.15.0",
|
||||
"typescript": "^5"
|
||||
"eslint-config-next": "14.2.3"
|
||||
}
|
||||
}
|
||||
|
|
BIN
prisma/dev.db
BIN
prisma/dev.db
Binary file not shown.
|
@ -1,28 +0,0 @@
|
|||
-- CreateTable
|
||||
CREATE TABLE "Story" (
|
||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"word_count" INTEGER NOT NULL,
|
||||
"title" TEXT NOT NULL,
|
||||
"deleted" INTEGER NOT NULL
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Pub" (
|
||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"title" TEXT NOT NULL,
|
||||
"link" TEXT NOT NULL,
|
||||
"query_after_days" INTEGER NOT NULL,
|
||||
"deleted" INTEGER NOT NULL
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Genre" (
|
||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"name" TEXT NOT NULL
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Response" (
|
||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"response" TEXT NOT NULL
|
||||
);
|
|
@ -1,30 +0,0 @@
|
|||
-- CreateTable
|
||||
CREATE TABLE "Sub" (
|
||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"storyId" INTEGER NOT NULL,
|
||||
"pubId" INTEGER NOT NULL,
|
||||
"submitted" TEXT NOT NULL,
|
||||
"responded" TEXT NOT NULL,
|
||||
"responseId" INTEGER NOT NULL,
|
||||
CONSTRAINT "Sub_storyId_fkey" FOREIGN KEY ("storyId") REFERENCES "Story" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
|
||||
CONSTRAINT "Sub_pubId_fkey" FOREIGN KEY ("pubId") REFERENCES "Pub" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
|
||||
CONSTRAINT "Sub_responseId_fkey" FOREIGN KEY ("responseId") REFERENCES "Response" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "PubsGenres" (
|
||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"pubId" INTEGER NOT NULL,
|
||||
"genreId" INTEGER NOT NULL,
|
||||
CONSTRAINT "PubsGenres_pubId_fkey" FOREIGN KEY ("pubId") REFERENCES "Pub" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
|
||||
CONSTRAINT "PubsGenres_genreId_fkey" FOREIGN KEY ("genreId") REFERENCES "Genre" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "StoriesGenres" (
|
||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"storyId" INTEGER NOT NULL,
|
||||
"genreId" INTEGER NOT NULL,
|
||||
CONSTRAINT "StoriesGenres_storyId_fkey" FOREIGN KEY ("storyId") REFERENCES "Story" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
|
||||
CONSTRAINT "StoriesGenres_genreId_fkey" FOREIGN KEY ("genreId") REFERENCES "Genre" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
||||
);
|
|
@ -1,16 +0,0 @@
|
|||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the `PubsGenres` table. If the table is not empty, all the data it contains will be lost.
|
||||
- You are about to drop the `StoriesGenres` table. If the table is not empty, all the data it contains will be lost.
|
||||
|
||||
*/
|
||||
-- DropTable
|
||||
PRAGMA foreign_keys=off;
|
||||
DROP TABLE "PubsGenres";
|
||||
PRAGMA foreign_keys=on;
|
||||
|
||||
-- DropTable
|
||||
PRAGMA foreign_keys=off;
|
||||
DROP TABLE "StoriesGenres";
|
||||
PRAGMA foreign_keys=on;
|
|
@ -1,16 +0,0 @@
|
|||
-- RedefineTables
|
||||
PRAGMA defer_foreign_keys=ON;
|
||||
PRAGMA foreign_keys=OFF;
|
||||
CREATE TABLE "new_Genre" (
|
||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"name" TEXT NOT NULL,
|
||||
"storyId" INTEGER,
|
||||
"pubId" INTEGER,
|
||||
CONSTRAINT "Genre_storyId_fkey" FOREIGN KEY ("storyId") REFERENCES "Story" ("id") ON DELETE SET NULL ON UPDATE CASCADE,
|
||||
CONSTRAINT "Genre_pubId_fkey" FOREIGN KEY ("pubId") REFERENCES "Pub" ("id") ON DELETE SET NULL ON UPDATE CASCADE
|
||||
);
|
||||
INSERT INTO "new_Genre" ("id", "name") SELECT "id", "name" FROM "Genre";
|
||||
DROP TABLE "Genre";
|
||||
ALTER TABLE "new_Genre" RENAME TO "Genre";
|
||||
PRAGMA foreign_keys=ON;
|
||||
PRAGMA defer_foreign_keys=OFF;
|
|
@ -1,8 +0,0 @@
|
|||
/*
|
||||
Warnings:
|
||||
|
||||
- A unique constraint covering the columns `[name]` on the table `Genre` will be added. If there are existing duplicate values, this will fail.
|
||||
|
||||
*/
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Genre_name_key" ON "Genre"("name");
|
|
@ -1,48 +0,0 @@
|
|||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `pubId` on the `Genre` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `storyId` on the `Genre` table. All the data in the column will be lost.
|
||||
|
||||
*/
|
||||
-- CreateTable
|
||||
CREATE TABLE "_GenreToStory" (
|
||||
"A" INTEGER NOT NULL,
|
||||
"B" INTEGER NOT NULL,
|
||||
CONSTRAINT "_GenreToStory_A_fkey" FOREIGN KEY ("A") REFERENCES "Genre" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT "_GenreToStory_B_fkey" FOREIGN KEY ("B") REFERENCES "Story" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "_GenreToPub" (
|
||||
"A" INTEGER NOT NULL,
|
||||
"B" INTEGER NOT NULL,
|
||||
CONSTRAINT "_GenreToPub_A_fkey" FOREIGN KEY ("A") REFERENCES "Genre" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT "_GenreToPub_B_fkey" FOREIGN KEY ("B") REFERENCES "Pub" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
-- RedefineTables
|
||||
PRAGMA defer_foreign_keys=ON;
|
||||
PRAGMA foreign_keys=OFF;
|
||||
CREATE TABLE "new_Genre" (
|
||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"name" TEXT NOT NULL
|
||||
);
|
||||
INSERT INTO "new_Genre" ("id", "name") SELECT "id", "name" FROM "Genre";
|
||||
DROP TABLE "Genre";
|
||||
ALTER TABLE "new_Genre" RENAME TO "Genre";
|
||||
CREATE UNIQUE INDEX "Genre_name_key" ON "Genre"("name");
|
||||
PRAGMA foreign_keys=ON;
|
||||
PRAGMA defer_foreign_keys=OFF;
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "_GenreToStory_AB_unique" ON "_GenreToStory"("A", "B");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "_GenreToStory_B_index" ON "_GenreToStory"("B");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "_GenreToPub_AB_unique" ON "_GenreToPub"("A", "B");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "_GenreToPub_B_index" ON "_GenreToPub"("B");
|
|
@ -1,24 +0,0 @@
|
|||
-- RedefineTables
|
||||
PRAGMA defer_foreign_keys=ON;
|
||||
PRAGMA foreign_keys=OFF;
|
||||
CREATE TABLE "new_Pub" (
|
||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"title" TEXT NOT NULL,
|
||||
"link" TEXT NOT NULL,
|
||||
"query_after_days" INTEGER NOT NULL,
|
||||
"deleted" INTEGER NOT NULL DEFAULT 0
|
||||
);
|
||||
INSERT INTO "new_Pub" ("deleted", "id", "link", "query_after_days", "title") SELECT "deleted", "id", "link", "query_after_days", "title" FROM "Pub";
|
||||
DROP TABLE "Pub";
|
||||
ALTER TABLE "new_Pub" RENAME TO "Pub";
|
||||
CREATE TABLE "new_Story" (
|
||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"word_count" INTEGER NOT NULL,
|
||||
"title" TEXT NOT NULL,
|
||||
"deleted" INTEGER NOT NULL DEFAULT 0
|
||||
);
|
||||
INSERT INTO "new_Story" ("deleted", "id", "title", "word_count") SELECT "deleted", "id", "title", "word_count" FROM "Story";
|
||||
DROP TABLE "Story";
|
||||
ALTER TABLE "new_Story" RENAME TO "Story";
|
||||
PRAGMA foreign_keys=ON;
|
||||
PRAGMA defer_foreign_keys=OFF;
|
|
@ -1,15 +0,0 @@
|
|||
-- RedefineTables
|
||||
PRAGMA defer_foreign_keys=ON;
|
||||
PRAGMA foreign_keys=OFF;
|
||||
CREATE TABLE "new_Pub" (
|
||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"title" TEXT NOT NULL,
|
||||
"link" TEXT NOT NULL DEFAULT '',
|
||||
"query_after_days" INTEGER NOT NULL,
|
||||
"deleted" INTEGER NOT NULL DEFAULT 0
|
||||
);
|
||||
INSERT INTO "new_Pub" ("deleted", "id", "link", "query_after_days", "title") SELECT "deleted", "id", "link", "query_after_days", "title" FROM "Pub";
|
||||
DROP TABLE "Pub";
|
||||
ALTER TABLE "new_Pub" RENAME TO "Pub";
|
||||
PRAGMA foreign_keys=ON;
|
||||
PRAGMA defer_foreign_keys=OFF;
|
|
@ -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"
|
|
@ -1,55 +0,0 @@
|
|||
// This is your Prisma schema file,
|
||||
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "sqlite"
|
||||
url = "file:./dev.db"
|
||||
}
|
||||
|
||||
model Story {
|
||||
id Int @id @default(autoincrement())
|
||||
word_count Int
|
||||
title String
|
||||
deleted Int @default(0)
|
||||
subs Sub[]
|
||||
genres Genre[]
|
||||
}
|
||||
|
||||
model Pub {
|
||||
id Int @id @default(autoincrement())
|
||||
title String
|
||||
link String @default("")
|
||||
query_after_days Int
|
||||
deleted Int @default(0)
|
||||
subs Sub[]
|
||||
genres Genre[]
|
||||
}
|
||||
|
||||
model Genre {
|
||||
id Int @id @default(autoincrement())
|
||||
name String @unique
|
||||
stories Story[]
|
||||
pubs Pub[]
|
||||
}
|
||||
|
||||
model Response {
|
||||
id Int @id @default(autoincrement())
|
||||
response String
|
||||
subs Sub[]
|
||||
}
|
||||
|
||||
model Sub {
|
||||
id Int @id @default(autoincrement())
|
||||
story Story @relation(fields: [storyId], references: [id])
|
||||
storyId Int
|
||||
pub Pub @relation(fields: [pubId], references: [id])
|
||||
pubId Int
|
||||
submitted String
|
||||
responded String
|
||||
response Response @relation(fields: [responseId], references: [id])
|
||||
responseId Int
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
import { PrismaClient } from '@prisma/client'
|
||||
|
||||
const prisma = new PrismaClient()
|
||||
|
||||
async function main() {
|
||||
// ... you will write your Prisma Client queries here
|
||||
const story = await prisma.story.update({
|
||||
where: { id: 1 },
|
||||
data: {
|
||||
title: "Ghost Aliens of Mars",
|
||||
genres: { set: [{ id: 1 }, { id: 2 }], create: { name: "alien-punk" } }
|
||||
}
|
||||
|
||||
})
|
||||
console.log(story)
|
||||
|
||||
}
|
||||
|
||||
main()
|
||||
.then(async () => {
|
||||
await prisma.$disconnect()
|
||||
})
|
||||
.catch(async (e) => {
|
||||
console.error(e)
|
||||
await prisma.$disconnect()
|
||||
process.exit(1)
|
||||
})
|
|
@ -16,11 +16,7 @@ export default function RootLayout({
|
|||
}>) {
|
||||
return (
|
||||
<html lang="en">
|
||||
<body className={inter.className}>
|
||||
<div id="sidebar">
|
||||
SIDEBAR
|
||||
</div>
|
||||
{children}</body>
|
||||
<body className={inter.className}>{children}</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
import { PrismaClient } from '@prisma/client'
|
||||
|
||||
const prismaClientSingleton = () => {
|
||||
return new PrismaClient()
|
||||
}
|
||||
|
||||
declare const globalThis: {
|
||||
prismaGlobal: ReturnType<typeof prismaClientSingleton>;
|
||||
} & typeof global;
|
||||
|
||||
const prisma = globalThis.prismaGlobal ?? prismaClientSingleton()
|
||||
|
||||
export default prisma
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') globalThis.prismaGlobal = prisma
|
|
@ -4,8 +4,92 @@ import styles from "./page.module.css";
|
|||
export default function Home() {
|
||||
return (
|
||||
<main className={styles.main}>
|
||||
Hello
|
||||
<div className={styles.description}>
|
||||
<p>
|
||||
Get started by editing
|
||||
<code className={styles.code}>src/app/page.tsx</code>
|
||||
</p>
|
||||
<div>
|
||||
<a
|
||||
href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
By{" "}
|
||||
<Image
|
||||
src="/vercel.svg"
|
||||
alt="Vercel Logo"
|
||||
className={styles.vercelLogo}
|
||||
width={100}
|
||||
height={24}
|
||||
priority
|
||||
/>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className={styles.center}>
|
||||
<Image
|
||||
className={styles.logo}
|
||||
src="/next.svg"
|
||||
alt="Next.js Logo"
|
||||
width={180}
|
||||
height={37}
|
||||
priority
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className={styles.grid}>
|
||||
<a
|
||||
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
|
||||
className={styles.card}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<h2>
|
||||
Docs <span>-></span>
|
||||
</h2>
|
||||
<p>Find in-depth information about Next.js features and API.</p>
|
||||
</a>
|
||||
|
||||
<a
|
||||
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
|
||||
className={styles.card}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<h2>
|
||||
Learn <span>-></span>
|
||||
</h2>
|
||||
<p>Learn about Next.js in an interactive course with quizzes!</p>
|
||||
</a>
|
||||
|
||||
<a
|
||||
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
|
||||
className={styles.card}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<h2>
|
||||
Templates <span>-></span>
|
||||
</h2>
|
||||
<p>Explore starter templates for Next.js.</p>
|
||||
</a>
|
||||
|
||||
<a
|
||||
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
|
||||
className={styles.card}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<h2>
|
||||
Deploy <span>-></span>
|
||||
</h2>
|
||||
<p>
|
||||
Instantly deploy your Next.js site to a shareable URL with Vercel.
|
||||
</p>
|
||||
</a>
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
export default function Page({ params }: { params: { slug: string } }) {
|
||||
return <div>My Post: {params.slug}</div>
|
||||
}
|
BIN
submissions
BIN
submissions
Binary file not shown.
|
@ -21,6 +21,6 @@
|
|||
"@/*": ["./src/*"]
|
||||
}
|
||||
},
|
||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", "prisma/script.mts"],
|
||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue