git clone git@github.com:pawanbenjamin/simplePrisma.git
npm install
createdb pupsNstuff
locally
Make sure to create a .env
file with
DATABASE_URL="postgresql://janedoe:mypassword@localhost:5432/mydb?schema=public"
You can build your schema in your prisma/schema.prisma
file
To then perform the db migration:
npx prisma migrate dev
While you develop, you can also push changes by
npx prisma db push
When seeding needed, run npx prisma db seed
to run the seed file at db/seed.js
Don't forget in your package.json
add a prisma portion, with a seed command running your seed file:
npx prisma init
npx prisma generate
(so you can):
npx prisma studio
Create migrations from your Prisma schema, apply them to the database, generate artifacts (e.g. Prisma Client)
npx prisma migrate dev
npx prisma db pull
Make sure you have your DATABASE_URL set in you .env
file
npx prisma db push
npx prisma migrate dev
(seed command is run here as well as pushing our schema to your db)
also there is prisma migrate deploy
for dev
or npx prisma migrate reset
Prisma Migrate resets the database and triggers seeding in the following scenarios:
1.You manually run the npx prisma migrate reset
CLI command.
2.The database is reset interactively in the context of using prisma migrate dev
- for example, as a result of migration history conflicts or database schema drift.
---> When you want to use npx prisma migrate dev
or npx prisma migrate reset
without seeding,
---> you can pass the --skip-seed
flag.
heroku apps:create your-app-name
heroku addons:create heroku-postgresql:hobby-dev
git push heroku main
heroku run npx prisma migrate deploy
or
heroku run npx prisma db push
,
heroku run npx prisma db seed