Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

prisma-data-migrate

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prisma-data-migrate

A CLI tool for running data migrations with Prisma in TypeScript

  • 1.0.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-71.43%
Maintainers
1
Weekly downloads
 
Created
Source

Prisma-data-migrate

A CLI tool for running data migrations with Prisma in TypeScript

GitHub

Description

Prisma does not have the functionality of migrating the actual data with Typescript built in - it only allows to migrate the database schema using SQL. RedwoodJS solves that problem with data migrations, but it is specific only to Redwood applications. This package is a CLI tool for creating data migrations and applying them to any project that uses Prisma.

Getting started

Install the prisma-data-migrate tool with your favorite package manager:

yarn add prisma-data-migrate

or

npm install prisma-data-migrate

You can install prisma-data-migrate globally but it's preffered to add this package to dev dependencies and then use npx to invoke commands.

In order to initialize data migrations, run:

npx prisma-data-migrate init

This command will automatically look for schema.prisma file in the prisma directory. If it's not found, then you have to specify the path to the schema file with --schema "relative-path-to-schema" parameter.

Prisma-migrate-schema needs a table in your database in order to store the actual state of database migrations that have been run. By default, this table is called prisma_data_migrations but you can change that with --table "table-name" parameter.

After initializing the prisma-data-migrate, you have to run an actual migration with Prisma migrate in order for Prisma to create the prisma_data_migrations table. After that you're good to go!

Commands

create

npx prisma-data-migrate create --name "name_of_the_migration"

Creates a new data migration file with a name of choice. Name parameter is required. Also you can provide a custom path to the prisma schema file with --schema "relative-path-to-schema". New data migration will be created in the dataMigrations directory which is a sibling to the prisma schema file.

deploy

npx prisma-data-migrate deploy

Deploys all the migrations that are present in the dataMigrations directory but not saved as executed in the database.

status

npx prisma-data-migrate status

Returns a status of the database, whether it is up-to-date or not.

baseline

npx prisma-data-migrate status --migration "20220723130345_name_of_the_migration_file.ts"

Marks all the migrations as executed up to the selected migration (including the selected one).

FAQs

Package last updated on 30 Jul 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc