diff --git a/appStartUp.sh b/appStartUp.sh new file mode 100644 index 0000000..29a903d --- /dev/null +++ b/appStartUp.sh @@ -0,0 +1,10 @@ +#!/bin/bash +set -eo pipefail + +export DATABASE_URL=$(echo -e ${DATABASE_URL}) + +echo "Database - running migrations." +npx prisma migrate deploy + +echo "Starting resource-api-v6." +npm start \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile index 75bbf0f..3998fa3 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,6 +1,6 @@ # Use the base image with Node.js FROM node:22.13.1-alpine -RUN apk add --update --no-cache openssh-client git +RUN apk add --update --no-cache bash openssh-client git RUN mkdir -p -m 0600 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts # Copy the current directory into the Docker image COPY . /resources-api @@ -13,5 +13,6 @@ RUN npm install -g pnpm@10.33.2 RUN pnpm install --frozen-lockfile RUN pnpm lint RUN pnpm lint:fix +RUN chmod +x appStartUp.sh -CMD pnpm start +CMD [ "./appStartUp.sh" ] diff --git a/prisma/migrations/20260512111000_add_resource_created_at_index/migration.sql b/prisma/migrations/20260512111000_add_resource_created_at_index/migration.sql new file mode 100644 index 0000000..49982c4 --- /dev/null +++ b/prisma/migrations/20260512111000_add_resource_created_at_index/migration.sql @@ -0,0 +1,2 @@ +-- CreateIndex +CREATE INDEX idx_resource_created_at ON resources."Resource"("createdAt" DESC); diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 3d0469d..796684c 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -3,8 +3,8 @@ generator client { } generator externalClient { - provider = "prisma-client-js" - output = "../packages/resources-prisma-client" + provider = "prisma-client-js" + output = "../packages/resources-prisma-client" binaryTargets = ["native", "debian-openssl-3.0.x"] } @@ -14,7 +14,7 @@ datasource db { } model ResourceRole { - id String @id @default(uuid()) + id String @id @default(uuid()) name String nameLower String fullReadAccess Boolean @@ -22,7 +22,7 @@ model ResourceRole { isActive Boolean selfObtainable Boolean legacyId Int? - createdAt DateTime @default(now()) + createdAt DateTime @default(now()) createdBy String updatedAt DateTime? @updatedAt updatedBy String? @@ -37,17 +37,17 @@ model ResourceRole { } model Resource { - id String @id @default(uuid()) - challengeId String - memberId String - memberHandle String - roleId String - legacyId Int? - phaseChangeNotifications Boolean? @default(true) - createdAt DateTime @default(now()) - createdBy String - updatedAt DateTime? @updatedAt - updatedBy String? + id String @id @default(uuid()) + challengeId String + memberId String + memberHandle String + roleId String + legacyId Int? + phaseChangeNotifications Boolean? @default(true) + createdAt DateTime @default(now()) + createdBy String + updatedAt DateTime? @updatedAt + updatedBy String? resourceRole ResourceRole @relation(fields: [roleId], references: [id]) @@ -57,6 +57,7 @@ model Resource { @@index([roleId], map: "resource-roleId-index") @@index([memberId, challengeId], map: "resource-memberIdChallengeId-index") @@index([createdAt(sort: Desc), memberId], map: "idx_resource_created_member") + @@index([createdAt(sort: Desc)], map: "idx_resource_created_at") } model ResourceRolePhaseDependency {