Skip to content

Commit

Permalink
Prisma upgrade (#206)
Browse files Browse the repository at this point in the history
* Upgrade Prisma to last of major 3 #200

* Format all schemas with Prisma format

* Preview feature "atomicNumberOperations" is deprecated. The functionality can be used without specifying it as a preview feature.

* Update dependencies also in prisma folder

* Types complain

* Raw query needs to be a template now

* Update documentation

* Another round of running prisma format against all schemas

* Use same types as elsewhere in the same file

* Moving to Prisma 4.0.0

* Going to Prisma v5 which came out like 20 hours ago..

* Remove previous migrations and update import path for generated client

* Update lock file

* Update prisma folder package to match the root more closely

* Works locally until docker-compose...

* Same image versions as frontend currently uses

* Prisma deploy instead of dev

* fix e2e tests (#212)

* fix e2e tests

* migration added

* manual migration are obsolete witn new DB schema

* Let me try PostgreSQL v14

* Just had to try with the predefined server info for pgadmin

---------

Co-authored-by: Juga Paazmaya <[email protected]>

* 200 fix migration (#213)

---------

Co-authored-by: Pavel Strunkin <[email protected]>
  • Loading branch information
paazmaya and pashidlos authored Aug 2, 2023
1 parent 0b6d92e commit 63a81b6
Show file tree
Hide file tree
Showing 95 changed files with 690 additions and 7,249 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,19 @@ on: [push]
jobs:
build:
# https://github.com/actions/runner-images#available-images
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3

- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: '14.16.1'
node-version: '18'

- name: Install npm dependencies
run: npm ci

- name: Prisma generate
run: npm run prisma:generate

- name: Unit tests
run: npm run test:cov

Expand Down
8 changes: 3 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
# https://github.com/Visual-Regression-Tracker/Visual-Regression-Tracker/issues/137
FROM node:14-alpine3.17 AS builder
FROM node:18-alpine3.18 AS builder

# Create app directory
WORKDIR /app

RUN npm install -g @prisma/[email protected] --unsafe-perm

COPY ./prisma/schema.prisma ./

# A wildcard is used to ensure both package.json AND package-lock.json are copied
COPY package*.json ./

# Install app dependencies
RUN npm install
RUN npm ci --verbose

COPY tsconfig*.json ./
COPY src ./src

RUN npm run build

# https://github.com/Visual-Regression-Tracker/Visual-Regression-Tracker/issues/137
FROM node:14-alpine3.17
FROM node:18-alpine3.18
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package*.json ./
COPY --from=builder /app/dist ./dist
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
- Install Node `14`
- clone repo
- Update `.env` and `prisma/.env`
- Make sure Postgres is up and running
- Make sure Postgres is up and running, using `docker-compose up` in a separate terminal
- `npm i`
- `npm run test`
- Create DB structure and apply migrations `npx prisma migrate up -c --experimental`
- Create DB structure `npx prisma db push`
- Apply migrations `npx prisma migrate deploy`
- `npm run test:e2e`
- Seed initial data `npx ts-node prisma/seed.ts`
- Seed initial data `npx prisma db seed`
- `npm run start:debug`

## Local HTTPS config
Expand Down
8 changes: 6 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ services:
- postgres
postgres:
container_name: postgres
image: postgres:12-alpine3.18
image: postgres:15.3-alpine3.18
restart: always
environment:
POSTGRES_USER: ${POSTGRES_USER}
Expand All @@ -40,9 +40,13 @@ services:
- "${POSTGRES_PORT}"
volumes:
- postgres:/var/lib/postgresql/data

# Available at http://localhost:5050
pgadmin:
container_name: pgadmin4
image: dpage/pgadmin4
# https://hub.docker.com/r/dpage/pgadmin4
# https://www.pgadmin.org/docs/pgadmin4/latest/release_notes_7_4.html
image: dpage/pgadmin4:7.4
restart: always
environment:
PGADMIN_DEFAULT_EMAIL: [email protected]
Expand Down
135 changes: 61 additions & 74 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"prisma:generate": "prisma generate",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest --projects src",
"test:watch": "jest --projects src --watch",
Expand All @@ -22,6 +21,9 @@
"test:e2e": "jest --projects test",
"test:acceptance": "jest --projects test_acceptance"
},
"engines": {
"node": ">=16.13.0"
},
"dependencies": {
"@nestjs/common": "^8.4.1",
"@nestjs/config": "^1.2.0",
Expand All @@ -34,7 +36,7 @@
"@nestjs/swagger": "^5.2.0",
"@nestjs/terminus": "^8.0.8",
"@nestjs/websockets": "^8.4.1",
"@prisma/client": "2.12.1",
"@prisma/client": "^5.0.0",
"ajv": "^8.10.0",
"bcryptjs": "^2.4.3",
"cache-manager": "^3.6.0",
Expand All @@ -60,7 +62,6 @@
"@nestjs/cli": "^8.2.3",
"@nestjs/schematics": "^8.0.8",
"@nestjs/testing": "^8.4.1",
"@prisma/cli": "2.12.1",
"@types/bcryptjs": "^2.4.2",
"@types/cache-manager": "^3.4.3",
"@types/cron": "^1.7.3",
Expand All @@ -82,11 +83,15 @@
"eslint-plugin-import": "^2.25.4",
"jest": "^27.5.1",
"prettier": "^2.6.0",
"prisma": "^5.0.0",
"supertest": "^6.2.2",
"ts-jest": "^27.1.3",
"ts-loader": "^9.2.8",
"ts-node": "^10.7.0",
"tsconfig-paths": "^3.14.0",
"typescript": "^4.6.2"
"typescript": "^4.9.2"
},
"prisma": {
"seed": "ts-node prisma/seed.ts"
}
}
4 changes: 2 additions & 2 deletions prisma/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# https://github.com/Visual-Regression-Tracker/Visual-Regression-Tracker/issues/137
FROM node:14-alpine3.17
FROM node:18-alpine3.18

RUN apk add --no-cache bash

WORKDIR /app

COPY . .

RUN npm ci
RUN npm ci --verbose

RUN chmod +x /app/wait-for-it.sh
RUN chmod +x /app/entrypoint.sh
Expand Down
Loading

0 comments on commit 63a81b6

Please sign in to comment.