api: add prisma configs and baseline schema

Pedro Lucas Porcellis porcellis@eletrotupi.com 3 months ago 836d3533005b68bed399214d7af47d18ccfe90fe
Parents: 0be1c3d
4 file(s) changed
  • api/.gitignore +1 -1
  • api/prisma.config.ts +12 -0
  • api/prisma/migrations/0_init/migration.sql +14 -0
  • api/prisma/schema.prisma +21 -0
api/.gitignore
@@ -1,4 +1,4 @@
1 1 node_modules
2 2 .env
3 - src/generated_prisma
3 + src/generated/prisma
4 4 orbit.db
api/prisma.config.ts
@@ -0,0 +1,12 @@
1 + import "dotenv/config";
2 + import { defineConfig } from "prisma/config";
3 +
4 + export default defineConfig({
5 + schema: "prisma/schema.prisma",
6 + migrations: {
7 + path: "prisma/migrations",
8 + },
9 + datasource: {
10 + url: process.env["DATABASE_URL"],
11 + },
12 + });
api/prisma/migrations/0_init/migration.sql
@@ -0,0 +1,14 @@
1 + -- CreateTable
2 + CREATE TABLE "users" (
3 + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
4 + "first_name" TEXT NOT NULL,
5 + "last_name" TEXT,
6 + "email" TEXT NOT NULL,
7 + "encrypted_password" TEXT NOT NULL,
8 + "created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
9 + "updated_at" DATETIME NOT NULL
10 + );
11 +
12 + -- CreateIndex
13 + CREATE UNIQUE INDEX "users_email_key" ON "users"("email");
14 +
api/prisma/schema.prisma
@@ -0,0 +1,21 @@
1 + generator client {
2 + provider = "prisma-client"
3 + output = "../src/generated/prisma"
4 + }
5 +
6 + datasource db {
7 + provider = "sqlite"
8 + }
9 +
10 + model User {
11 + id Int @id @default(autoincrement())
12 + firstName String @map("first_name")
13 + lastName String? @map("last_name")
14 + email String @unique
15 + encryptedPassword String @map("encrypted_password")
16 + createdAt DateTime @default(now()) @map("created_at")
17 + updatedAt DateTime @updatedAt @map("updated_at")
18 +
19 +
20 + @@map("users")
21 + }