Skip to content

Commit f212e15

Browse files
committed
Fixing database seeding bug
1 parent 671c056 commit f212e15

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

client/Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,4 @@ COPY package.json ./
66
COPY package-lock.json ./
77
COPY . .
88
RUN npm install
9-
RUN npm run build
10-
CMD ["npm", "run", "preview"]
9+
RUN npm run build

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ services:
88
POSTGRES_USER: "${POSTGRES_USER}"
99
POSTGRES_PASSWORD: "${POSTGRES_PASSWORD}"
1010
POSTGRES_DB: ${POSTGRES_DB}
11-
command: bash -c "npm run preview"
1211
volumes:
1312
- ./docker_test_db:/var/lib/postgresql/data
1413
healthcheck:
@@ -24,7 +23,7 @@ services:
2423
dockerfile: Dockerfile
2524
ports:
2625
- "7999:8000"
27-
command: bash -c "npx prisma migrate dev && npx prisma db seed && npm start"
26+
command: bash -c "npx prisma migrate reset --force && npm start"
2827
environment:
2928
DATABASE_URL: "${DATABASE_URL}"
3029
PORT: "${PORT}"
@@ -36,6 +35,7 @@ services:
3635
build:
3736
context: ./client
3837
dockerfile: Dockerfile
38+
command: bash -c "npm run preview"
3939
ports:
4040
- "4174:4173"
4141
depends_on:

server/prisma/seed.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,6 @@ async function main() {
411411
async function init() {
412412
const users = await prisma.user.count();
413413

414-
console.log(users)
415-
416414
if (users === 0) {
417415
main()
418416
.then(async () => {
@@ -423,9 +421,10 @@ async function init() {
423421
await prisma.$disconnect();
424422
process.exit(1);
425423
});
424+
console.log("Database is successully seeded");
426425
} else {
427426
console.log("Database seeding is not needed");
428427
}
429428
}
430429

431-
init()
430+
init();

0 commit comments

Comments
 (0)