From f27cb92892dfb820c3326a82d88d7455a9f560f5 Mon Sep 17 00:00:00 2001 From: Ruslan Gonzalez Date: Sun, 17 Jan 2021 19:48:43 +0000 Subject: [PATCH] added prisma --- .env | 7 +++++++ docker-compose.yml | 12 ++++++++++++ package.json | 1 + prisma/schema.prisma | 26 ++++++++++++++++++++++++++ yarn.lock | 18 ++++++++++++++++++ 5 files changed, 64 insertions(+) create mode 100644 .env create mode 100644 docker-compose.yml create mode 100644 prisma/schema.prisma diff --git a/.env b/.env new file mode 100644 index 0000000..a4b395f --- /dev/null +++ b/.env @@ -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#using-environment-variables + +# Prisma supports the native connection string format for PostgreSQL, MySQL and SQLite. +# See the documentation for all the connection string options: https://pris.ly/d/connection-strings + +DATABASE_URL="postgresql://prisma:prisma@localhost:5432/prisma?schema=public" diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..9ff1125 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,12 @@ +version: '3' +services: + postgres: + image: postgres + ports: + - 5432:5432 + environment: + POSTGRES_DB: prisma + POSTGRES_USER: prisma + POSTGRES_PASSWORD: prisma + volumes: + - ./tmp/postgres:/var/lib/postgresql/data diff --git a/package.json b/package.json index e57af68..0ba7d11 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "@nrwl/nx-cloud": "latest", "@nrwl/tao": "11.1.5", "@nrwl/workspace": "11.1.5", + "@prisma/cli": "^2.14.0", "@types/jest": "26.0.8", "@types/node": "12.12.38", "@typescript-eslint/eslint-plugin": "4.3.0", diff --git a/prisma/schema.prisma b/prisma/schema.prisma new file mode 100644 index 0000000..5f247bb --- /dev/null +++ b/prisma/schema.prisma @@ -0,0 +1,26 @@ +// This is your Prisma schema file, +// learn more about it in the docs: https://pris.ly/d/prisma-schema + +datasource db { + provider = "postgresql" + url = env("DATABASE_URL") +} + +generator client { + provider = "prisma-client-js" +} + +model Listing { + id String @id @default(cuid()) + createdAt DateTime @default(now()) + updatedAt DateTime @default(now()) @updatedAt + title String + text String + type ListingType + price Int +} + +enum ListingType { + Product + Service +} diff --git a/yarn.lock b/yarn.lock index 0f4dad9..83c9bc2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -817,6 +817,24 @@ consola "^2.15.0" node-fetch "^2.6.1" +"@prisma/bar@^0.0.1": + version "0.0.1" + resolved "https://registry.yarnpkg.com/@prisma/bar/-/bar-0.0.1.tgz#088c4fbbb79c588391437ade9fd3a85527e753b3" + integrity sha512-FVLhwVkbfhXlBhroWfIXMLi+3Jh9IEzYp+9z+MUUiw3ZsbcoAil7CN9/QIjHc4/TcCRyRfuSmT7qCnn4O+TjJw== + +"@prisma/cli@^2.14.0": + version "2.14.0" + resolved "https://registry.yarnpkg.com/@prisma/cli/-/cli-2.14.0.tgz#6aa298a389fb899730ee68d3487633e19677d416" + integrity sha512-zKYiOGlc/Y0VVRQew0jMR2sGSFnKnNGlgY4ToB5K1JMv7jCg51w+FJe2FwTOF4uWv+0Yp2KC1b0TAP8KUbNJ3A== + dependencies: + "@prisma/bar" "^0.0.1" + "@prisma/engines" "2.14.0-28.5d491261d382a2a5ffdc71de17072b0e409f1cc1" + +"@prisma/engines@2.14.0-28.5d491261d382a2a5ffdc71de17072b0e409f1cc1": + version "2.14.0-28.5d491261d382a2a5ffdc71de17072b0e409f1cc1" + resolved "https://registry.yarnpkg.com/@prisma/engines/-/engines-2.14.0-28.5d491261d382a2a5ffdc71de17072b0e409f1cc1.tgz#dee16f1c648cd291540937ad5d69062526368946" + integrity sha512-t5/Mq0VtL7khYQtbap8myr7RwyIvmruCFxsph6oTi8QZaklmuxSp7FAC2DWBz8r/KoZFngMpmliKfDrWN7uwzQ== + "@sinonjs/commons@^1.7.0": version "1.8.2" resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.8.2.tgz#858f5c4b48d80778fde4b9d541f27edc0d56488b"