Skip to content

junaidmugloo/Prisma_ORM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

# Prisma Commands

## Here is a list of the commonly used Prisma commands and what they do:

### 1. `prisma init`
Initializes Prisma in your project by creating a `prisma` folder with a `schema.prisma` file and a `.env` file.

**Example:**
```bash
npx prisma init

2. prisma generate

Generates the Prisma Client based on your Prisma schema. Run this after modifying your schema.prisma.

Example:

npx prisma generate

3. prisma db push

Pushes the schema changes in your schema.prisma to your database without creating a migration. It synchronizes the Prisma schema with the database schema.

Example:

npx prisma db push

4. prisma migrate dev

Creates a new migration based on the changes in your Prisma schema and applies it to your development database.

Example:

npx prisma migrate dev --name <migration_name>

5. prisma migrate deploy

Applies all pending migrations to your production database. Use this when deploying to production.

Example:

npx prisma migrate deploy

6. prisma migrate resolve

Marks a specific migration as applied or rolled back without running it. This can be useful in scenarios where a migration was manually applied or reverted.

Example:

npx prisma migrate resolve --applied <migration_id>

7. prisma migrate reset

Resets the database by dropping all data and applying all migrations from scratch. Useful during development to start with a clean database.

Example:

npx prisma migrate reset

8. prisma db seed

Runs the seed script defined in your prisma/schema.prisma. This command helps seed your database with initial data.

Example:

npx prisma db seed

9. prisma db pull

Introspects your database schema and updates the Prisma schema file (schema.prisma) to reflect any changes in your database.

Example:

npx prisma db pull

10. prisma studio

Launches Prisma Studio, a web interface for browsing and editing your database data.

Example:

npx prisma studio

11. prisma format

Formats the Prisma schema file to a standardized format.

Example:

npx prisma format

12. prisma version

Outputs the current version of Prisma that you have installed.

Example:

npx prisma version

13. prisma validate

Validates the Prisma schema for any errors without applying any changes.

Example:

npx prisma validate

14. prisma migrate diff

Compares two database states or schema files and outputs a list of differences.

Example:

npx prisma migrate diff --from-url <DATABASE_URL_1> --to-url <DATABASE_URL_2>

Enabling MongoDB Replica Set Locally

Step 1: Modify MongoDB Config File

To enable replication, modify the replication settings in your MongoDB configuration file (mongod.conf or equivalent).

Add the following lines:

replication:
  replSetName: "myReplicaSet"

Step 2: Restart MongoDB

After making the changes, restart your MongoDB instance for the new replication settings to take effect.


Step 3: Initiate Replica Set in Mongo Shell

Open your Mongo shell.

Switch to your desired database (for example, from test to prisma):

test> use prisma
switched to db prisma

Initiate the replica set by running the following command & make sure follow indentation:

prisma> rs.initiate({
  _id: "myReplicaSet",
  members: [{ _id: 0, host: "127.0.0.1:27017" }]
})

Step 4: Verify Replica Set Status

Check that the replica set has been initiated correctly. You should see:

{ ok: 1 }

For more information, visit the Prisma Documentation.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published