Skip to content

Commit

Permalink
chore: prisma setup
Browse files Browse the repository at this point in the history
  • Loading branch information
hyochan committed Jun 29, 2024
1 parent ec52b92 commit 6f9ff01
Show file tree
Hide file tree
Showing 6 changed files with 326 additions and 73 deletions.
Binary file modified bun.lockb
Binary file not shown.
21 changes: 20 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,31 @@
"fix:deps": "expo install --fix",
"lint:all": "bun lint && bun lint:i18n",
"build:web": "expo export --platform web",
"test": "jest --runInBand"
"test": "jest --runInBand",
"eas:dev:updates": "dotenv -e .env -- eas update --branch development",
"eas:preview:android": "dotenv -e .env.production -- eas build --profile preview --platform android",
"eas:prod:updates": "dotenv -e .env.production -- eas update --branch production",
"eas:prod:updates:ios": "dotenv -e .env.production -- eas update --branch production --platform ios",
"eas:prod:updates:android": "dotenv -e .env.production -- eas update --branch production --platform android",
"eas:dev:ios": "dotenv -e .env -- eas build --profile development --platform ios",
"eas:dev:android": "dotenv -e .env -- eas build --profile development --platform android",
"eas:prod:secrets": "eas secret:push --scope project --env-file .env.production",
"eas:prod:ios": "dotenv -e .env.production -- eas build --profile production --platform ios",
"eas:prod:android": "dotenv -e .env.production -- eas build --profile production --platform android",
"eas:prod:android:local": "dotenv -e .env.production -- eas build --profile production --platform android --local",
"eas:submit:ios": "dotenv -e .env.production -- eas submit --profile production --platform ios",
"eas:submit:android": "dotenv -e .env.production -- eas submit --profile production --platform android",
"generate:supabase": "bunx supabase gen types typescript --project-id \"nrywcykpuqhlyaavosms\" --schema public > src/types/supabase.ts",
"migrate:dev": "dotenv -e .env -- prisma migrate dev",
"migrate:local": "dotenv -e .env -- prisma migrate deploy",
"migrate:deploy": "dotenv -e .env.production -- prisma migrate deploy"
},
"dependencies": {
"@emotion/native": "^11.11.0",
"@emotion/react": "^11.11.4",
"@expo/match-media": "^0.4.0",
"@expo/react-native-action-sheet": "^4.1.0",
"@prisma/client": "5.16.1",
"@react-native-async-storage/async-storage": "1.23.1",
"@react-native-community/datetimepicker": "8.0.1",
"@shopify/flash-list": "1.6.4",
Expand Down Expand Up @@ -95,6 +113,7 @@
"jest-expo": "~51.0.3",
"jest-fetch-mock": "^3.0.3",
"prettier": "^3.3.2",
"prisma": "^5.16.1",
"react-test-renderer": "18.2.0",
"ts-jest": "^29.1.4",
"ts-node": "^10.9.2",
Expand Down
94 changes: 94 additions & 0 deletions prisma/migrations/20240629150213_init/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
-- CreateEnum
CREATE TYPE "Gender" AS ENUM ('male', 'female', 'intersex');

-- CreateEnum
CREATE TYPE "AuthType" AS ENUM ('email', 'google', 'apple');

-- CreateEnum
CREATE TYPE "Nationality" AS ENUM ('SouthKorea', 'UnitedStates', 'Unknown');

-- CreateTable
CREATE TABLE "users" (
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
"email" TEXT,
"full_name" TEXT,
"name" TEXT,
"avatar_url" TEXT,
"phone_verified" BOOLEAN DEFAULT false,
"provider_id" TEXT,
"sub" TEXT,
"provider" "AuthType" NOT NULL DEFAULT 'email',
"description" TEXT,
"birthday" TIMESTAMP(3),
"gender" "Gender",
"phone" TEXT,
"locale" TEXT,
"confirmed_at" TIMESTAMP(3),
"email_confirmed_at" TIMESTAMP(3),
"last_sign_in_at" TIMESTAMP(3),
"created_at" TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3),
"deleted_at" TIMESTAMP(3),

CONSTRAINT "users_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "developers" (
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
"email" TEXT,
"bio" TEXT,
"nationality" TEXT DEFAULT 'Unknown',
"organization" TEXT,
"meetup_id" TEXT,
"github_id" TEXT,
"twitter_id" TEXT,
"threads_id" TEXT,
"desired_connection" TEXT,
"motivation_for_event_participation" TEXT,
"future_expectations" TEXT,
"created_at" TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3),
"deleted_at" TIMESTAMP(3),
"user_id" UUID,

CONSTRAINT "developers_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "tags" (
"id" VARCHAR(50) NOT NULL,
"tag" VARCHAR(50) NOT NULL,

CONSTRAINT "tags_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "_DeveloperToTag" (
"A" UUID NOT NULL,
"B" VARCHAR(50) NOT NULL
);

-- CreateIndex
CREATE UNIQUE INDEX "developers_email_key" ON "developers"("email");

-- CreateIndex
CREATE UNIQUE INDEX "tags_tag_key" ON "tags"("tag");

-- CreateIndex
CREATE INDEX "tags_tag_idx" ON "tags"("tag");

-- CreateIndex
CREATE UNIQUE INDEX "_DeveloperToTag_AB_unique" ON "_DeveloperToTag"("A", "B");

-- CreateIndex
CREATE INDEX "_DeveloperToTag_B_index" ON "_DeveloperToTag"("B");

-- AddForeignKey
ALTER TABLE "developers" ADD CONSTRAINT "developers_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "_DeveloperToTag" ADD CONSTRAINT "_DeveloperToTag_A_fkey" FOREIGN KEY ("A") REFERENCES "developers"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "_DeveloperToTag" ADD CONSTRAINT "_DeveloperToTag_B_fkey" FOREIGN KEY ("B") REFERENCES "tags"("id") ON DELETE CASCADE ON UPDATE CASCADE;
3 changes: 3 additions & 0 deletions prisma/migrations/migration_lock.toml
Original file line number Diff line number Diff line change
@@ -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"
94 changes: 94 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
generator client {
provider = "prisma-client-js"
output = "../node_modules/.prisma/client"
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}

enum Gender {
male
female
intersex
}

enum AuthType {
email
google
apple
}

model User {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
email String?
fullName String? @map("full_name")
name String?
avatarUrl String? @map("avatar_url")
phoneVerified Boolean? @default(false) @map("phone_verified")
providerId String? @map("provider_id")
sub String?
provider AuthType @default(email)
description String?
birthday DateTime?
gender Gender?
phone String?
locale String?
confirmedAt DateTime? @map("confirmed_at")
emailConfirmedAt DateTime? @map("email_confirmed_at")
lastSignInAt DateTime? @map("last_sign_in_at")
createdAt DateTime? @default(now()) @map("created_at")
updatedAt DateTime? @updatedAt @map("updated_at")
deletedAt DateTime? @map("deleted_at")
developers Developer[]
@@map("users")
}

enum Nationality {
SouthKorea
UnitedStates
Unknown
}

model Developer {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
email String? @unique
bio String?
nationality String? @default("Unknown")
organization String?
meetupId String? @map("meetup_id")
githubId String? @map("github_id")
twitterId String? @map("twitter_id")
threadsId String? @map("threads_id")
/// 연결되고 싶은 분
desiredConnection String? @map("desired_connection")
/// 행사 참여중일 때 동기 입력
motivationForEventParticipation String? @map("motivation_for_event_participation")
/// 앞으로 기대하는 것
futureExpectations String? @map("future_expectations")
createdAt DateTime? @default(now()) @map("created_at")
updatedAt DateTime? @updatedAt @map("updated_at")
deletedAt DateTime? @map("deleted_at")
tags Tag[]
userId String? @map("user_id") @db.Uuid
user User? @relation(fields: [userId], references: [id])
@@map("developers")
}

model Tag {
id String @id @default(cuid()) @db.VarChar(50)
tag String @unique @db.VarChar(50)
developers Developer[]
@@index(tag)
@@map("tags")
}
Loading

0 comments on commit 6f9ff01

Please sign in to comment.