Skip to content

nimbit-software/prisma-merge-schema

 
 

Repository files navigation

prisma-merge-schema

Merges/postfixes Prisma v2 schemas.

See usage section and examples for more details.

oclif Version Downloads/week License

Examples

Merge schemas (glob pattern)

npx prisma-merge-schema \
  --datasource ./prisma/src/**/* 
  --outputFile output.schema

Merge schemas (multiple files explicitly declared)

npx prisma-merge-schema \
  --datasource ./prisma/src/datasource1.prisma  \
  --datasource ./prisma/src/datasource2.prisma  \
  --outputFile output.schema

Merge schemas and apply decorators

npx prisma-merge-schema \
  --datasource ./prisma/src/datasource.prisma \
  --decorators ./prisma/src/decorators.prisma \
  --outputFile output.schema

Decorators

Given a datasource of

model User {
  id          Int       @id
  username    String    @default("") @db.VarChar(1000)
  extrafield  String    @default("") @db.VarChar(1000)
}

and a decorator file of

extends model User {
  newfield    String    @default("") @db.VarChar(1000)
}

replaces model User {
  id          Int       @id @db.UnsignedInt
}

remove model User {
  extrafield
}

running

npx prisma-merge-schema \
  --datasource ./prisma/src/datasource.prisma \
  --decorators ./prisma/src/decorators.prisma \
  --outputFile ./prisma/schema.prisma

produces a schema file

model User {
  id          Int       @id @db.UnsignedInt
  username    String    @default("") @db.VarChar(1000)
  newfield    String    @default("") @db.VarChar(1000)
}

Useful for applying changes after prisma introspect without modifying your original schema.

Feature roadmap

  • Handle automatic deletion of @@index annotations

Usage

$ npm install -g prisma-merge-schema
$ prisma-merge-schema COMMAND
running command...
$ prisma-merge-schema (-v|--version|version)
prisma-merge-schema/1.0.0 darwin-x64 node-v12.18.2
$ prisma-merge-schema --help [COMMAND]
USAGE
  $ prisma-merge-schema COMMAND
...

Commands

About

Merges/postfixes Prisma (v2) schemas

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 95.4%
  • JavaScript 4.2%
  • Batchfile 0.4%