Migrate Prisma seed configuration to `prisma.config.ts` and update API Dockerfile

- Move `prisma.seed` from `package.json` to new `prisma.config.ts`.
- Modify API Dockerfile to include `prisma.config.ts` in the build process.
main
Pau Costa Ferrer 2026-03-28 19:04:18 +01:00
parent 4b7f7887ee
commit 7b6750e17d
6 changed files with 38 additions and 18 deletions

View File

@ -4,7 +4,16 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="6c8b3c54-eabb-40e5-967f-c7b594c750bc" name="Changes" comment="Add health checks for dependent services and automate DB migrations in API Dockerfile&#10;&#10;- Configure `healthcheck` for the PostgreSQL service in `docker-compose.yml`.&#10;- Update service dependencies to use `condition: service_healthy` for PostgreSQL.&#10;- Modify API Dockerfile to run `npx prisma migrate deploy` before starting the application." />
<list default="true" id="6c8b3c54-eabb-40e5-967f-c7b594c750bc" name="Changes" comment="Migrate Prisma seed configuration to `prisma.config.ts` and update API Dockerfile&#10;&#10;- Move `prisma.seed` from `package.json` to new `prisma.config.ts`.&#10;- Modify API Dockerfile to include `prisma.config.ts` in the build process.">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/apps/api/Dockerfile" beforeDir="false" afterPath="$PROJECT_DIR$/apps/api/Dockerfile" afterDir="false" />
<change beforePath="$PROJECT_DIR$/apps/api/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/apps/api/package.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/apps/api/prisma.config.ts" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/apps/api/src/main.ts" beforeDir="false" afterPath="$PROJECT_DIR$/apps/api/src/main.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/apps/web/src/routes/admin/floorplan/[id]/+page.svelte" beforeDir="false" afterPath="$PROJECT_DIR$/apps/web/src/routes/admin/floorplan/[id]/+page.svelte" afterDir="false" />
<change beforePath="$PROJECT_DIR$/apps/web/src/routes/admin/floorplan/[id]/+page.ts" beforeDir="false" afterPath="$PROJECT_DIR$/apps/web/src/routes/admin/floorplan/[id]/+page.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/docker-compose.yml" beforeDir="false" afterPath="$PROJECT_DIR$/docker-compose.yml" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
@ -66,7 +75,7 @@
]
}
}</component>
<component name="RunManager" selected="npm.web &gt; dev">
<component name="RunManager" selected="Docker.docker-compose.yml: Compose Deployment">
<configuration default="true" type="docker-deploy" factoryName="docker-compose.yml" temporary="true">
<deployment type="docker-compose.yml">
<settings />
@ -103,9 +112,9 @@
</configuration>
<recent_temporary>
<list>
<item itemvalue="Docker.docker-compose.yml: Compose Deployment" />
<item itemvalue="npm.api &gt; start:dev" />
<item itemvalue="npm.web &gt; dev" />
<item itemvalue="Docker.docker-compose.yml: Compose Deployment" />
</list>
</recent_temporary>
</component>
@ -125,7 +134,7 @@
<updated>1774643312599</updated>
<workItem from="1774643313611" duration="74000" />
<workItem from="1774643422240" duration="5278000" />
<workItem from="1774706361502" duration="13887000" />
<workItem from="1774706361502" duration="14661000" />
</task>
<task id="LOCAL-00001" summary="Initialize Hot Desking app with web and API services &#10;&#10;- Set up SvelteKit for the web interface with Tailwind CSS. &#10;- Build the API using NestJS with Prisma ORM for database interaction. &#10;- Add environment variable management and docker-compose for PostgreSQL and PgAdmin instances. &#10;- Create shared data models for consistent typing across services. &#10;- Establish basic routing and layouts for web and API services.">
<option name="closed" value="true" />
@ -383,7 +392,23 @@
<option name="project" value="LOCAL" />
<updated>1774720187941</updated>
</task>
<option name="localTasksCounter" value="33" />
<task id="LOCAL-00033" summary="Add organization details to schema and update PostgreSQL health check&#10;&#10;- Add `language`, `logoId`, and `logoUrl` columns to the `Organization` table with relevant constraints and indexes.&#10;- Update `docker-compose.yml` to support dynamic environment variables in PostgreSQL health check.">
<option name="closed" value="true" />
<created>1774720441331</created>
<option name="number" value="00033" />
<option name="presentableId" value="LOCAL-00033" />
<option name="project" value="LOCAL" />
<updated>1774720441331</updated>
</task>
<task id="LOCAL-00034" summary="Migrate Prisma seed configuration to `prisma.config.ts` and update API Dockerfile&#10;&#10;- Move `prisma.seed` from `package.json` to new `prisma.config.ts`.&#10;- Modify API Dockerfile to include `prisma.config.ts` in the build process.">
<option name="closed" value="true" />
<created>1774720600350</created>
<option name="number" value="00034" />
<option name="presentableId" value="LOCAL-00034" />
<option name="project" value="LOCAL" />
<updated>1774720600350</updated>
</task>
<option name="localTasksCounter" value="35" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
@ -401,8 +426,6 @@
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="Add &quot;My Bookings&quot; page and enable reservation updates and cancellations&#10;&#10;- Implement `+page.svelte` for managing user reservations with real-time updates.&#10;- Add API endpoints for updating and canceling reservations with enhanced validation and authorization.&#10;- Introduce `UpdateReservationDto` for refined reservation update handling.&#10;- Update `reservations.service.ts` to handle overlapping checks, time adjustments, and admin actions.&#10;- Extend layout to include a link to the &quot;My Bookings&quot; page.&#10;- Add `date-fns` library for date formatting." />
<MESSAGE value="Add building and floor management with admin editor modal&#10;&#10;- Implement `BuildingEditorModal.svelte` for creating, editing, and deleting buildings and floors.&#10;- Add `CreateBuildingDto`, `UpdateBuildingDto`, `CreateFloorDto`, and `UpdateFloorDto` for validation.&#10;- Extend `SpacesService` and `SpacesController` with endpoints for building and floor CRUD operations.&#10;- Update Prisma schema to include building descriptions and image URLs, and floor names.&#10;- Enhance dashboard with building management functionality for admin users." />
<MESSAGE value="Enhance real-time space status updates and handling&#10;&#10;- Improve WebSocket connection reliability with updated transport options.&#10;- Introduce logic to prioritize real-time updates over initial data for live views.&#10;- Add logging for better debugging of WebSocket events and data propagation.&#10;- Update UI components (`SpaceCard`, `FloorplanViewer`) to avoid overwrites from stale data.&#10;- Refactor date handling for consistent behavior across components." />
<MESSAGE value="Fix ownership checks and improve delete booking button UI&#10;&#10;- Update `isOwner` logic to account for nested user objects in reservation data.&#10;- Enhance delete button styling for better visibility and usability." />
<MESSAGE value="Add organization management with logo support&#10;&#10;- Introduce `OrganizationsModule` with related logic in `AppModule`.&#10;- Update Prisma schema to include `logoUrl` field for organizations.&#10;- Enhance seeds to include default organization logo.&#10;- Update layout to dynamically display organization details, including logo and name.&#10;- Add UI support for organization-based navigation in admin routes." />
@ -426,6 +449,8 @@
<MESSAGE value="Integrate `svelte-i18n` for enhanced localization support&#10;&#10;- Add `svelte-i18n` as a dependency for dynamic translations.&#10;- Replace `@sveltejs/adapter-auto` with `@sveltejs/adapter-node` for better deployment compatibility.&#10;- Update `package-lock.json` to reflect new and updated dependencies." />
<MESSAGE value="Exclude Prisma directory from API build configuration" />
<MESSAGE value="Add health checks for dependent services and automate DB migrations in API Dockerfile&#10;&#10;- Configure `healthcheck` for the PostgreSQL service in `docker-compose.yml`.&#10;- Update service dependencies to use `condition: service_healthy` for PostgreSQL.&#10;- Modify API Dockerfile to run `npx prisma migrate deploy` before starting the application." />
<option name="LAST_COMMIT_MESSAGE" value="Add health checks for dependent services and automate DB migrations in API Dockerfile&#10;&#10;- Configure `healthcheck` for the PostgreSQL service in `docker-compose.yml`.&#10;- Update service dependencies to use `condition: service_healthy` for PostgreSQL.&#10;- Modify API Dockerfile to run `npx prisma migrate deploy` before starting the application." />
<MESSAGE value="Add organization details to schema and update PostgreSQL health check&#10;&#10;- Add `language`, `logoId`, and `logoUrl` columns to the `Organization` table with relevant constraints and indexes.&#10;- Update `docker-compose.yml` to support dynamic environment variables in PostgreSQL health check." />
<MESSAGE value="Migrate Prisma seed configuration to `prisma.config.ts` and update API Dockerfile&#10;&#10;- Move `prisma.seed` from `package.json` to new `prisma.config.ts`.&#10;- Modify API Dockerfile to include `prisma.config.ts` in the build process." />
<option name="LAST_COMMIT_MESSAGE" value="Migrate Prisma seed configuration to `prisma.config.ts` and update API Dockerfile&#10;&#10;- Move `prisma.seed` from `package.json` to new `prisma.config.ts`.&#10;- Modify API Dockerfile to include `prisma.config.ts` in the build process." />
</component>
</project>

View File

@ -20,7 +20,6 @@ COPY shared ./shared
# Generate Prisma client
WORKDIR /app/apps/api
COPY apps/api/prisma.config.ts ./
RUN npx prisma generate
# Build the app
@ -36,7 +35,6 @@ COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/apps/api/dist ./apps/api/dist
COPY --from=builder /app/apps/api/package.json ./apps/api/package.json
COPY --from=builder /app/apps/api/prisma ./apps/api/prisma
COPY --from=builder /app/apps/api/prisma.config.ts ./apps/api/prisma.config.ts
COPY --from=builder /app/shared/dist ./shared/dist
COPY --from=builder /app/shared/package.json ./shared/package.json

View File

@ -84,5 +84,8 @@
],
"coverageDirectory": "../coverage",
"testEnvironment": "node"
},
"prisma": {
"seed": "ts-node prisma/seed.ts"
}
}

View File

@ -1,7 +0,0 @@
import { defineConfig } from 'prisma/config';
export default defineConfig({
seed: {
command: 'ts-node prisma/seed.ts',
},
});

View File

@ -18,7 +18,7 @@ async function bootstrap() {
app.useGlobalFilters(new HttpExceptionFilter());
app.enableCors({
origin: ['http://localhost:5173'],
origin: process.env.CORS_ORIGIN ? process.env.CORS_ORIGIN.split(',') : ['http://localhost:5173'],
credentials: true,
});

View File

@ -29,6 +29,7 @@ services:
DATABASE_URL: "postgresql://${DB_USER:-postgres}:${DB_PASSWORD:-postgres}@postgres:5432/${DB_NAME:-hotdesking}"
PORT: 3000
JWT_SECRET: ${JWT_SECRET:-super-secret-change-me}
CORS_ORIGIN: ${WEB_ORIGIN:-http://localhost:5173}
depends_on:
postgres:
condition: service_healthy