createdb pupsNstuff
git clone git@github.com:pawanbenjamin/simplePrisma.git
cd simplePrisma
npm install
Make sure to create a .env file with the following: (change to your username and password if you have one)
DATABASE_URL="postgresql://janedoe:mypassword@localhost:5432/pupsNstuff?schema=public"
There is a file in db/demo which goes through basic crud queries
npm install prisma @prisma/client
npx prisma init
Change the db url in the newly generated .env file
DATABASE_URL="postgresql://janedoe:mypassword@localhost:5432/<your db name>?schema=public"
npx prisma generate
So later in your application, you can:
You can build your schema in your prisma/schema.prisma file
- Quickstart Guide to Schema from DOCUMENTATION
To then perform the db migration (including running a prisma seed command if any exists) ->
npx prisma migrate dev
You can add this command in your package.json
All you need to do is add a prisma portion, with a seed command running your local seed file:
While you develop, you can also push changes by
npx prisma db push
To only run the seed script npx prisma db seed
This repo drops and builds tables before running the seed file with prisma.$executeRaw
npx prisma init
npx prisma generate
npx prisma studio
Create migrations from your Prisma schema, apply them to the database, seed data, and 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

