Prisma not seed on Docker container (Windows platform)
See original GitHub issueBug description
Hello @prisma,
After I asked about seeding on #7199 . I got a new problem with seeding on windows.
When I run npx prisma migrate dev
and npx migrate reset
, I got Running seed from "prisma\seed.js" ...
but no response from seed files and the database has no update records. (either npx prisma db seed --preview-feature
)
How to reproduce
- run
docker compose -f docker-compose.yaml -f docker-compose.dev.yaml up -d --build
- after container run.
npx prisma migrate dev
- Run
npx prisma migrate reset
- See an error (
Running seed from "prisma\seed.js" ...
) - try
npx prisma db seed --preview-feature
- See an another error (something like
Your database has seed already
)
Expected behavior
🌱 Start seeding … ✅ ✨ Created Restaurants : [Res1] Seeding finished. 🌱
Prisma information
//schema.prisma
model Restaurants {
restaurant_id Int @id @default(autoincrement())
merchant_id Int
name String
image_url String
products Json
location_lat Decimal @db.Decimal(12, 7)
location_lng Decimal @db.Decimal(12, 7)
open_hour String
close_hour String
open_days Json
created_at DateTime @default(now())
updated_at DateTime @updatedAt
delete_flag Boolean @default(false)
Merchant Merchants @relation(fields: [merchant_id], references: [merchant_id])
Jobs Jobs[]
}
// seed.js
const restaurantsData = [
{
Merchant: {
connect: { merchant_id: 1 },
},
name: "[Name1]",
image_url: "PATH",
products: [
{
product_id: 1,
product_name: "[Food 1]",
product_price: 50,
product_discount: 0,
product_image_url: "PATH",
product_status: "Available",
},
{
product_id: 2,
product_name: "[Food 2]",
product_price: 60,
product_discount: 20,
product_image_url: "PATH",
product_status: "Available",
},
{
product_id: 3,
product_name: "[Food 3]",
product_price: 60,
product_discount: 0,
product_image_url: "PATH",
product_status: "Unavailable",
},
],
location_lat: 13.8649955,
location_lng: 100.5196122,
open_hour: "10.00 - 21.00",
close_hour: "21.00 - 10.00",
open_days: {
Mon: false,
Tue: true,
Wed: true,
Thu: true,
Fri: true,
Sat: true,
Sun: true,
},
},
];
async function main() {
for (const data of restaurantsData) {
const restaurant = await prisma.restaurants.create({
data: data,
});
}
main()
.catch((e) => {
console.error(e);
process.exit(1);
})
.finally(async () => {
await prisma.$disconnect();
});
Environment & setup
- OS: Windows
- Database: PostgreSQL 13
- Node.js version: 14.16.0 (on Docker container), 14.15.4 (on Windows)
// DockerFile
FROM node:14.16
WORKDIR /app
COPY package.json .
ARG NODE_ENV
RUN if [ "$NODE_ENV" = "development" ]; \
then npm install; \
else npm install --production; \
fi
COPY . ./
RUN npx prisma generate;
ENV HOST 0.0.0.0
ENV PORT 3000
EXPOSE 3000
CMD ["npm", "run", "dev"]
// docker-compose.yaml
version: "3"
services:
node:
build: .
restart: always
ports:
- "3000:3000"
environment:
- PORT=3000
depends_on:
- db
db:
image: postgres
restart: always
expose:
- "5432"
ports:
- "5432:5432"
environment:
POSTGRES_DB: ####
POSTGRES_USER: ####
POSTGRES_PASSWORD: ####
POSTGRES_HOST_AUTH: trust
volumes:
- postgres-db:/var/lib/postgresql/data
redis:
image: redis
expose:
- "6379"
ports:
- "6379:6379"
volumes:
postgres-db:
redis-service:
// docker-compose.dev.yaml
version: "3"
services:
node:
build:
context: .
args:
NODE_ENV: development
volumes:
- ./:/app
- /app/node_modules
environment:
- NODE_ENV=development
- POSTGRES_USER=####
- POSTGRES_PASSWORD=####
command: npm run dev
db:
environment:
- POSTGRES_DB=###
- POSTGRES_HOST_AUTH=trust
Prisma Version
Environment variables loaded from .env
prisma : 2.23.0
@prisma/client : 2.23.0
Current platform : windows
Query Engine : query-engine adf5e8cba3daf12d456d911d72b6e9418681b28b (at node_modules\@prisma\engines\query-engine-windows.exe)
Migration Engine : migration-engine-cli adf5e8cba3daf12d456d911d72b6e9418681b28b (at node_modules\@prisma\engines\migration-engine-windows.exe)
Introspection Engine : introspection-core adf5e8cba3daf12d456d911d72b6e9418681b28b (at node_modules\@prisma\engines\introspection-engine-windows.exe)
Format Binary : prisma-fmt adf5e8cba3daf12d456d911d72b6e9418681b28b (at node_modules\@prisma\engines\prisma-fmt-windows.exe)
Default Engines Hash : adf5e8cba3daf12d456d911d72b6e9418681b28b
Studio : 0.393.0
Preview Features : filterJson
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
Seeding your database - Prisma
This guide describes how to seed your database using Prisma Client and Prisma's integrated seeding functionality. Seeding allows you to consistently ...
Read more >Prisma Migrate limitations and known issues
The following limitations apply to Prisma Migrate. MongoDB connector not supported. Prisma Migrate does not currently support the MongoDB connector.
Read more >Environment variables - Prisma
An environment variable is a key value pair of string data that is stored on your machine's local environment. Refer to our Environment...
Read more >Prisma Migrate | Database, Schema, SQL Migration Tool
Prisma Migrate is a database migration tool available via the Prisma CLI that integrates with Prisma schema for data modeling.
Read more >Prisma Server as Docker container? - Questions
The problem is prisma deploy from 1.7.3 creates another docker-compose.yml inside the docker container and automatically tries to start docker inside docker. It ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
🗒️ We heard the feedback and we are planning a redesign of
db seed
(currently planned to be released early September)How it will work is that a
prisma.seed
property in the package.json of your project will be required if you want to useprisma db seed
.This property is where you will be able to put any command you want to execute your seed script.
More info/details & how to try it out now in: https://github.com/prisma/prisma/issues/8732
I think this is a duplicate of https://github.com/prisma/prisma/issues/7176
I will still keep this open so that we can make sure this is also fixed after the first issue is patched.