Initial schema working

This commit is contained in:
Fergal Moran
2022-09-28 11:24:56 +01:00
parent 04c47139f1
commit ea845e9e58
20 changed files with 84 additions and 0 deletions

7
.env Normal file
View File

@@ -0,0 +1,7 @@
# 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="postgresql://postgres:hackme@localhost:5432/frasier-gifs?schema=public"

View File

@@ -9,6 +9,7 @@
"lint": "next lint"
},
"dependencies": {
"@prisma/client": "4.4.0",
"next": "12.3.1",
"react": "18.2.0",
"react-dom": "18.2.0"
@@ -21,6 +22,7 @@
"eslint": "8.24.0",
"eslint-config-next": "12.3.1",
"postcss": "^8.4.16",
"prisma": "^4.4.0",
"tailwindcss": "^3.1.8",
"typescript": "4.8.4"
}

View File

@@ -0,0 +1,12 @@
-- CreateTable
CREATE TABLE "Gif" (
"id" TEXT NOT NULL,
"title" VARCHAR(100) NOT NULL,
"description" VARCHAR(2000) NOT NULL,
"searchTerms" VARCHAR(2000) NOT NULL,
"upVotes" INTEGER NOT NULL DEFAULT 0,
"downVotes" INTEGER NOT NULL DEFAULT 0,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "Gif_pkey" PRIMARY KEY ("id")
);

View File

@@ -0,0 +1,8 @@
/*
Warnings:
- Added the required column `fileName` to the `Gif` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "Gif" ADD COLUMN "fileName" VARCHAR(100) NOT NULL;

View File

@@ -0,0 +1,3 @@
-- AlterTable
ALTER TABLE "Gif" ALTER COLUMN "description" DROP NOT NULL,
ALTER COLUMN "searchTerms" DROP NOT NULL;

View File

@@ -0,0 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (i.e. Git)
provider = "postgresql"

25
prisma/schema.prisma Normal file
View File

@@ -0,0 +1,25 @@
// 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 = "postgresql"
url = env("DATABASE_URL")
}
model Gif {
id String @id @default(uuid())
title String @db.VarChar(100)
description String? @db.VarChar(2000)
searchTerms String? @db.VarChar(2000)
//this is temporary, filenames should always match the GUID above
fileName String @db.VarChar(100)
upVotes Int @default(0)
downVotes Int @default(0)
createdAt DateTime @default(now())
}

BIN
public/samples/sample-1.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 461 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 490 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

BIN
public/samples/sample-2.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 860 KiB

BIN
public/samples/sample-4.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

BIN
public/samples/sample-5.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

BIN
public/samples/sample-6.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 KiB

BIN
public/samples/sample-7.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 KiB

BIN
public/samples/sample-8.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 MiB

BIN
public/samples/sample-9.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 MiB

View File

@@ -154,6 +154,23 @@
"@nodelib/fs.scandir" "2.1.5"
fastq "^1.6.0"
"@prisma/client@4.4.0":
version "4.4.0"
resolved "https://registry.yarnpkg.com/@prisma/client/-/client-4.4.0.tgz#45f59c172dd3621ecc92d7cf9bc765d85e6c7d56"
integrity sha512-ciKOP246x1xwr04G9ajHlJ4pkmtu9Q6esVyqVBO0QJihaKQIUvbPjClp17IsRJyxqNpFm4ScbOc/s9DUzKHINQ==
dependencies:
"@prisma/engines-version" "4.4.0-66.f352a33b70356f46311da8b00d83386dd9f145d6"
"@prisma/engines-version@4.4.0-66.f352a33b70356f46311da8b00d83386dd9f145d6":
version "4.4.0-66.f352a33b70356f46311da8b00d83386dd9f145d6"
resolved "https://registry.yarnpkg.com/@prisma/engines-version/-/engines-version-4.4.0-66.f352a33b70356f46311da8b00d83386dd9f145d6.tgz#00875863bb30b670a586a5b5794a000f7f3ad976"
integrity sha512-P5v/PuEIJLYXZUZBvOLPqoyCW+m6StNqHdiR6te++gYVODpPdLakks5HVx3JaZIY+LwR02juJWFlwpc9Eog/ug==
"@prisma/engines@4.4.0":
version "4.4.0"
resolved "https://registry.yarnpkg.com/@prisma/engines/-/engines-4.4.0.tgz#6ca7d3ce8eee08dcfa82311b0a02f5ccaac7dc0c"
integrity sha512-Fpykccxlt9MHrAs/QpPGpI2nOiRxuLA+LiApgA59ibbf24YICZIMWd3SI2YD+q0IAIso0jCGiHhirAIbxK3RyQ==
"@rushstack/eslint-patch@^1.1.3":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@rushstack/eslint-patch/-/eslint-patch-1.2.0.tgz#8be36a1f66f3265389e90b5f9c9962146758f728"
@@ -1630,6 +1647,13 @@ prelude-ls@^1.2.1:
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396"
integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==
prisma@^4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/prisma/-/prisma-4.4.0.tgz#0c53324bf6a29474636b3e1964e0d72e0277bf8f"
integrity sha512-l/QKLmLcKJQFuc+X02LyICo0NWTUVaNNZ00jKJBqwDyhwMAhboD1FWwYV50rkH4Wls0RviAJSFzkC2ZrfawpfA==
dependencies:
"@prisma/engines" "4.4.0"
prop-types@^15.8.1:
version "15.8.1"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.8.1.tgz#67d87bf1a694f48435cf332c24af10214a3140b5"