-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4c1dd00
commit 65be335
Showing
5 changed files
with
219 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
version: 0.2 | ||
|
||
phases: | ||
install: | ||
runtime-versions: | ||
nodejs: 18 | ||
commands: | ||
- npm i -g pnpm | ||
- pnpm i --frozen-lockfile | ||
pre_build: | ||
commands: | ||
- pnpm nx clean recnet-api | ||
- pnpm nx prisma:generate recnet-api | ||
build: | ||
commands: | ||
- pnpm nx build recnet-api | ||
post_build: | ||
commands: | ||
- rm -rf node_modules | ||
- mv package.json package.json.bak | ||
- mv pnpm-lock.yaml pnpm-lock.yaml.bak | ||
- mv dist/apps/recnet-api/package.json package.json | ||
- mv dist/apps/recnet-api/pnpm-lock.yaml pnpm-lock.yaml | ||
- pnpm install --prod --frozen-lockfile | ||
- pnpx prisma generate --schema=apps/recnet-api/prisma/schema.prisma | ||
- cp -R apps/recnet-api/prisma/ dist/apps/recnet-api/prisma | ||
artifacts: | ||
files: | ||
- "dist/apps/recnet-api/**/*" | ||
- "node_modules/**/*" | ||
- "package.json" | ||
- "Procfile" | ||
enable-symlinks: yes |
102 changes: 102 additions & 0 deletions
102
apps/recnet-api/prisma/migrations/20240306035932_init/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
-- CreateEnum | ||
CREATE TYPE "Provider" AS ENUM ('FACEBOOK', 'GOOGLE'); | ||
|
||
-- CreateEnum | ||
CREATE TYPE "Role" AS ENUM ('ADMIN', 'USER'); | ||
|
||
-- CreateTable | ||
CREATE TABLE "User" ( | ||
"id" TEXT NOT NULL, | ||
"provider" "Provider" NOT NULL, | ||
"providerId" VARCHAR(128) NOT NULL, | ||
"email" VARCHAR(128) NOT NULL, | ||
"handle" VARCHAR(32) NOT NULL, | ||
"displayName" VARCHAR(32) NOT NULL, | ||
"inviteCode" VARCHAR(64), | ||
"photoUrl" VARCHAR(256) NOT NULL, | ||
"affiliation" VARCHAR(32), | ||
"bio" TEXT, | ||
"lastLoginAt" TIMESTAMP(3) NOT NULL, | ||
"role" "Role" NOT NULL DEFAULT 'USER', | ||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
|
||
CONSTRAINT "User_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "FollowingRecord" ( | ||
"userId" TEXT NOT NULL, | ||
"followerId" TEXT NOT NULL, | ||
"createdAt" TIMESTAMP(3) NOT NULL, | ||
|
||
CONSTRAINT "FollowingRecord_pkey" PRIMARY KEY ("userId","followerId") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Recommendation" ( | ||
"id" TEXT NOT NULL, | ||
"userId" TEXT NOT NULL, | ||
"articleId" TEXT NOT NULL, | ||
"description" TEXT NOT NULL, | ||
"cutoff" TIMESTAMP(3) NOT NULL, | ||
"createAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updateAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
|
||
CONSTRAINT "Recommendation_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Article" ( | ||
"id" TEXT NOT NULL, | ||
"doi" VARCHAR(32), | ||
"title" VARCHAR(256) NOT NULL, | ||
"author" VARCHAR(256) NOT NULL, | ||
"link" VARCHAR(256) NOT NULL, | ||
"year" SMALLINT NOT NULL, | ||
"month" SMALLINT, | ||
"isVerified" BOOLEAN NOT NULL DEFAULT false, | ||
"createAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updateAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
|
||
CONSTRAINT "Article_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "InviteCode" ( | ||
"id" SERIAL NOT NULL, | ||
"code" VARCHAR(64) NOT NULL, | ||
"ownerId" VARCHAR(32) NOT NULL, | ||
"issuedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"usedById" VARCHAR(32), | ||
"usedAt" TIMESTAMP(3), | ||
|
||
CONSTRAINT "InviteCode_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "User_handle_key" ON "User"("handle"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "InviteCode_usedById_key" ON "InviteCode"("usedById"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "FollowingRecord" ADD CONSTRAINT "FollowingRecord_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "FollowingRecord" ADD CONSTRAINT "FollowingRecord_followerId_fkey" FOREIGN KEY ("followerId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Recommendation" ADD CONSTRAINT "Recommendation_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Recommendation" ADD CONSTRAINT "Recommendation_articleId_fkey" FOREIGN KEY ("articleId") REFERENCES "Article"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "InviteCode" ADD CONSTRAINT "InviteCode_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "InviteCode" ADD CONSTRAINT "InviteCode_usedById_fkey" FOREIGN KEY ("usedById") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters