From a1576273bdd29ea84176578cce46d65218c430f8 Mon Sep 17 00:00:00 2001 From: Supan Adit Pratama Date: Sat, 26 Oct 2024 20:01:34 +0700 Subject: [PATCH] wip: sample with prisma --- libs/prisma/src/prisma-crud.controller.ts | 0 .../migrations/20241026125933_init/migration.sql | 10 ++++++++++ prisma/migrations/migration_lock.toml | 3 +++ prisma/schema.prisma | 15 ++++++++++++--- 4 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 libs/prisma/src/prisma-crud.controller.ts create mode 100644 prisma/migrations/20241026125933_init/migration.sql create mode 100644 prisma/migrations/migration_lock.toml diff --git a/libs/prisma/src/prisma-crud.controller.ts b/libs/prisma/src/prisma-crud.controller.ts new file mode 100644 index 0000000..e69de29 diff --git a/prisma/migrations/20241026125933_init/migration.sql b/prisma/migrations/20241026125933_init/migration.sql new file mode 100644 index 0000000..022b17f --- /dev/null +++ b/prisma/migrations/20241026125933_init/migration.sql @@ -0,0 +1,10 @@ +-- CreateExtension +CREATE EXTENSION IF NOT EXISTS "pgcrypto"; + +-- CreateTable +CREATE TABLE "account" ( + "id" UUID NOT NULL DEFAULT gen_random_uuid(), + "name" TEXT NOT NULL, + + CONSTRAINT "account_pkey" PRIMARY KEY ("id") +); diff --git a/prisma/migrations/migration_lock.toml b/prisma/migrations/migration_lock.toml new file mode 100644 index 0000000..fbffa92 --- /dev/null +++ b/prisma/migrations/migration_lock.toml @@ -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" \ No newline at end of file diff --git a/prisma/schema.prisma b/prisma/schema.prisma index ee282c7..ebdd7d1 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -5,10 +5,19 @@ // Try Prisma Accelerate: https://pris.ly/cli/accelerate-init generator client { - provider = "prisma-client-js" + provider = "prisma-client-js" + previewFeatures = ["postgresqlExtensions"] } datasource db { - provider = "postgresql" - url = env("DATABASE_URL") + provider = "postgresql" + url = env("DATABASE_URL") + extensions = [pgcrypto] +} + +model User { + id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid + name String + + @@map("account") }