Skip to content

Latest commit

 

History

History
112 lines (85 loc) · 2.48 KB

README.md

File metadata and controls

112 lines (85 loc) · 2.48 KB

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