Giter Site home page Giter Site logo

sabinadams / aurora Goto Github PK

View Code? Open in Web Editor NEW
209.0 6.0 15.0 854 KB

CLI tool that orchestrates prisma files in a way that allows multiple .prisma files with cross-relations

Home Page: https://twitter.com/sabinthedev

JavaScript 0.66% TypeScript 99.34%
prisma schema database typescript library package split nodejs javascript mysql

aurora's Introduction


  

❗️ NOTICE

This repository is no longer maintained. There is an AMAZING community solution to this issue that not only solves the schema merging issue, but also the VSCode intellisense implications of splitting your schema 🚀

🔗 Head over to https://github.com/ajmnz/prisma-import to check it out.


P.S.: Shoutout to Arnau Jiménez for creating this awesome tool!

aurora's People

Contributors

codeninja avatar dependabot[bot] avatar sabinadams avatar turn-a-round avatar yassineldeeb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

aurora's Issues

Allow for multiple copies of the same `generator` across files to enable `previewFeature` support

Is your feature request related to a problem? Please describe.
It's sometimes necessary to duplicate a generator argument across files to enable preview features. This used to be necessary for referentialActions, and is now necessary for mongoDb.

When I try to combine multiple files with identical copies of generator, the resulting schema contains multiple copies. This makes it invalid and prevents me from running prisma commands until I manually fix it.

Even though my project doesn't use mongoDb, this issue will prevent us from using any future preview features that require the existence of a generator in 2 or more schema files.

Consider these two schemas:

datasource db {
  provider = "mongodb"
  url      = env("MONGODB_URI")
}

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["mongoDb"]
}

model Author {
  id        String   @id @default(dbgenerated()) @map("_id") @db.ObjectId
  firstName String
  lastName  String
  dob       DateTime
  age       Int
  books     Book[]
}
datasource db {
  provider = "mongodb"
  url      = env("MONGODB_URI")
}

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["mongoDb"]
}

model Book {
  id          String   @id @default(dbgenerated()) @map("_id") @db.ObjectId
  authorId    Int
  author      Author   @relation(fields: [authorId], references: [id])
  pages       Int
  releaseDate DateTime
  genre       String
}

model Author {
  id    String @id @default(dbgenerated()) @map("_id") @db.ObjectId
  books Book[]
}

They will be combined into:

// ◮◮◮ GENERATED BY AURORA ◮◮◮
datasource db {
  provider       = "mongodb"
  activeProvider = "mongodb"
  url            = env("MONGODB_URI")
}

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["mongoDb"]
}

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["mongoDb"]
}

model Author {
  id        String   @id @default(dbgenerated()) @map("_id") @db.ObjectId
  books     Book[]
  firstName String
  lastName  String
  dob       DateTime
  age       Int
}

model Book {
  id          String   @id @default(dbgenerated()) @map("_id") @db.ObjectId
  authorId    Int
  author      Author   @relation(fields: [authorId], references: [id])
  pages       Int
  releaseDate DateTime
  genre       String
}

The resulting schema is invalid. And it's not possible to combine them at all without the generator in each, since without it, the schemas aren't valid.

Describe the solution you'd like
aurora should only use the first copy it finds of a generator with a given name.

Describe alternatives you've considered
It might also be reasonable to combine the entries together, but I don't think that flexibility would be worth the increase in complexity.

Problem occurring in @relation part when generating schema.prisma

If the @relation part in the .prisma file is changed as follows, a syntax error occurs in @relation in the generated schema.prisma.

  • sample.prisma
    before↓
model Sample {
  ...
  employee        Employee   @relation(fields: [employee_id], references: [id])
  employee_id     Int
  ...
}

after↓

model Sample {
  ...
  employee        Employee   @relation(fields: [employee_id], references: [id], onDelete: Cascade)
  employee_id     Int
  ...
}
  • schema.prisma
model Employee_Assignment {
  ...
  employee        Employee   @relation(fields: [employee_id], references: [id]) @relation(fields: [employee_id], references: [id], onDelete: Cascade)
  employee_id     Int
  ...
}

Error

Error: Schema validation error - Error (query-engine-node-api library)
Error code: P1012
error: Attribute "@relation" can only be defined once.
  -->  schema.prisma:103
   | 
103 |   employee        Employee   @relation(fields: [employee_id], references: [id]) @relation(fields: [employee_id], references: [id], onDelete: Cascade)
   | 
error: Attribute "@relation" can only be defined once.
  -->  schema.prisma:103
   | 
103 |   employee        Employee   @relation(fields: [employee_id], references: [id]) @relation(fields: [employee_id], references: [id], onDelete: Cascade)
   | 

Validation Error Count: 2
[Context: getDmmf]

Support type keyword for mongodb

Is your feature request related to a problem? Please describe.
Currently, Aurora doesn't transform and parse type definations in Prisma schemas.

Describe the solution you'd like
Add support for type definations in schemas. They should be copied to the output schema file.

Describe alternatives you've considered
N/A

Additional context
Current behavior: it ignores all type definitions:

Input: session.model.schema

datasource db {
  provider = "mongodb"
  url      = env("DATABASE_URL")
}

model Session {
  id               String                   @id @default(auto()) @map("_id") @db.ObjectId
  sessionId        String                   @unique
  shop             String
  state            String
  isOnline         Boolean
  scope            String
  expires          DateTime?
  accessToken      String
  onlineAccessInfo SessionOnlineAccessInfo?
}

type SessionOnlineAccessInfo {
  expires_in            Int
  associated_user_scope String
  associated_user       SessionAssociatedUser
}

type SessionAssociatedUser {
  id             Int
  first_name     String
  last_name      String
  email          String
  email_verified Boolean
  account_owner  Boolean
  locale         String
  collaborator   Boolean
}

Output: schema.prisma

// ◮◮◮ GENERATED BY AURORA ◮◮◮
datasource db {
  provider = "mongodb"
  url      = env("DATABASE_URL")
}

generator client {
  provider = "prisma-client-js"
}

model Session {
  id               String                   @id @default(auto()) @map("_id") @db.ObjectId
  sessionId        String                   @unique
  shop             String
  state            String
  isOnline         Boolean
  scope            String
  expires          DateTime?
  accessToken      String
  onlineAccessInfo SessionOnlineAccessInfo?
}

Default value deleted

Hi!

When I do this :

model Post {
  id        Int      @id @default(autoincrement())
  title     String  
  createdAt DateTime @default(now())
  content   String?
  published Boolean  @default(false)

  dateBegin DateTime @default(now())
  dateEnd   DateTime @default(now())

  mainImg   String?

  latitude  Decimal?
  longitude Decimal?

  authorId  Int
  author    User      @relation(fields: [authorId], references: [id])

  // postDateGroupId  Int
  // postDateGroup    PostDateGroup      @relation(fields: [postDateGroupId], references: [id])

  organizationId  Int
  organization    Organization      @relation(fields: [organizationId], references: [id])

  likeCount Int @default(0)
  like User[] @relation("PostToUserLike")
}

It generate :

model Post {
  id             Int             @id @default(autoincrement())
  usersVisited   PostStatistic[]
  categories     Category[]      @relation(name: "CategoryToPost")
  title          String
  createdAt      DateTime        @default(now())
  content        String?
  published      Boolean         @default(false)
  dateBegin      DateTime        @default(now())
  dateEnd        DateTime        @default(now())
  mainImg        String?
  latitude       Decimal?
  longitude      Decimal?
  authorId       Int
  author         User            @relation(fields: [authorId], references: [id])
  // postDateGroupId Int PostDateGroup @relation(fields: [postDateGroupId], references: [id])
  organizationId Int
  organization   Organization    @relation(fields: [organizationId], references: [id])
  likeCount      Int             @default
  like           User[]          @relation(name: "PostToUserLike")
}

The field likeCount has @default and not @default(0).
it throw me an error after running npx prisma generate.

Thanks

Comments on attributes do not merge correctly

Describe the bug
In the case of "Handling Relations Across Files" (see prisma-aurora README), adding comments to attributes are not merged correctly on the aurora-built prisma schema

NB In our use case we using 3 slashes for comments /// as this is required for a different prisma library we are using that generates documentation and displays comments from the schema as descriptions. The error also occurs with 2 slashes //

To Reproduce
Steps to reproduce the behavior:

  1. Create 2 models with relationships in different files, i.e. Author and Book per prisma-aurora README
  2. Create a prisma-aurora json config file
  3. Add a comment above the attributes on the models, e.g. /// my comment
  4. View the built prisma schema

Expected behavior
The prisma schema should be built with attribute comments deduped/merged appropriately

Screenshots
image

Desktop (please complete the following information):

  • Ubuntu
  • 20.04.4

Additional context

  • Node fermium

Enumeration nullable type generation

Hi !

When I run aurora script with :

User.prisma

generator client {
  provider = "prisma-client-js"
  previewFeatures = ["interactiveTransactions"]
  output   = "../src/generated/client"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model Right {
  id        Int      @id @default(autoincrement())
  ruleId  Int?
  rule    Rule?      @relation(fields: [ruleId], references: [id])
  value String
  active Boolean @default(true)
}

model Rule {
  id        Int      @id @default(autoincrement())
  contractId  Int?
  contract    Contract?      @relation(fields: [contractId], references: [id])
  rights Right[]
  value String
  active Boolean @default(true)
}

enum Role {
  USER
  ADMIN
}

model Contract {
  id        Int      @id @default(autoincrement())
  userId  Int
  user    User      @relation(fields: [userId], references: [id])
  rules Rule[]
  role  Role    @default(USER)
}

model ResetPasswordToken {
  id          String      @id @default(uuid())
  createdAt   DateTime    @default(now()) @db.Timestamp(6)
  userId      Int
  user    User      @relation(fields: [userId], references: [id])
}

model User {
  id      Int      @id @default(autoincrement())
  name    String?  @db.VarChar(255)
  email   String   @unique @db.VarChar(255)
  password String
  contract Contract?
  resetPasswordToken ResetPasswordToken[]
}

Post.prisma

model Post {
  id        Int      @id @default(autoincrement())
  title     String   //@db.VarChar(255)
  createdAt DateTime @default(now()) //@db.Timestamp(6)
  content   String?
  published Boolean  @default(false)
  authorId  Int
  author    User      @relation(fields: [authorId], references: [id])
}

model User {
    id      Int      @id @default(autoincrement())
    posts     Post[]
}

It generate :

// *** GENERATED BY AURORA :: DO NOT EDIT ***
datasource db {
	provider = "postgresql"
	url = env("DATABASE_URL")
}
generator client {
	provider = "prisma-client-js"
	output = "../src/generated/client"
	previewFeatures = ["interactiveTransactions"]
}
model Post {
	id Int @id @default(autoincrement())
	title String
	createdAt DateTime @default(now())
	content String?
	published Boolean @default(false)
	authorId Int
	author User? @relation(name: "PostToUser", fields: [authorId], references: [id])
}
model User {
	id Int @id @default(autoincrement())
	name String?
	email String @unique
	password String
	contract Contract? @relation(name: "ContractToUser")
	resetPasswordToken ResetPasswordToken[] @relation(name: "ResetPasswordTokenToUser")
	posts Post[] @relation(name: "PostToUser")
}
model Right {
	id Int @id @default(autoincrement())
	ruleId Int?
	rule Rule? @relation(name: "RightToRule", fields: [ruleId], references: [id])
	value String
	active Boolean @default(true)
}
model Rule {
	id Int @id @default(autoincrement())
	contractId Int?
	contract Contract? @relation(name: "ContractToRule", fields: [contractId], references: [id])
	rights Right[] @relation(name: "RightToRule")
	value String
	active Boolean @default(true)
}
model Contract {
	id Int @id @default(autoincrement())
	userId Int @unique
	user User? @relation(name: "ContractToUser", fields: [userId], references: [id])
	rules Rule[] @relation(name: "ContractToRule")
	role Role? @default(USER)
}
model ResetPasswordToken {
	id String @id @default(uuid())
	createdAt DateTime @default(now())
	userId Int
	user User? @relation(name: "ResetPasswordTokenToUser", fields: [userId], references: [id])
}
enum Role {
	USER
	ADMIN
}

But my model Contract has now an enumeration with type Role? but I write Role in the User.prisma file.

I don't want to be Role? but Role.

Is it possible to fix it ?

Thanks

unable to use more than one generator

Describe the bug
When running aurora with a _base.prisma file below.
image

datasource db { ... } 

generator client {
  provider        = "prisma-client-js"
  binaryTargets   = ["native"]
  engineType      = "node"
  output          = "client-js"
  previewFeatures = ["fullTextSearch", "referentialIntegrity"]
}
generator graphql {
  provider = "graphql-schema-generator"
  output   = "../src/schemas"
  createCRUD = "true"
}

Aroura errors stating that there may only be one generator but the prisma schema allows for multiple generators.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior

  • yarn aurora should execute
  • The generators should be added to the schema

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

path support of * and **

{
  "files": [
      "./src/schema/*.prisma",  // example 1
      "./src/module/**/module.prisma"  // example 2
      "./src/module/**/*.prisma",  // example 3
  ],
  "output": "./prisma/schema2.prisma"
}

it would be really nice if this feature was added ^^

/// }) in comments fails silently

Hi there,

When }) is in a comment of a field the program will stop merging silently. There is no visible error.

model Person{
  id                            String    @id /// }) <--- stops processing
  a                             String
  b                             String
  c                             String
}

Thanks!
-Paul

Schemas with multiple generators are missing values in the compiled schema.

Describe the bug

On v.1.3.1: Running aurora with multiple generators results in missing values

To Reproduce
Steps to reproduce the behavior:

  1. have the following file structure:
    image

image

  1. run aurora

  2. Note the missing graphql fields.
    image

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Missing one-letter enum values

Describe the bug
Missing one-letter enum values after running aurora.

To Reproduce
Steps to reproduce the behavior:

  1. With the following enum:
    image

  2. Running aurora will result in:
    image

Expected behavior
Enum should contain both values

Add tests to ensure multiple/no generators are added correctly

Describe the bug
Need tests to cover the multiple/no generator scenario

Expected behavior
Test suite should include a test that checks that a schema with multiple generators will properly be handled. It should also test a schema with no generator, which should pass.

Additional context
PR #38 Added this enhancement

Native DB type attributes not saving

Native DB type attributes are saving, but not their options.

To Reproduce
Use the following schema

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["interactiveTransactions"]
  output          = "../src/generated/client"
}

datasource db {
  provider = "postgresql"
  url      = "postgres://"
}

model Right {
  id     Int     @id @default(autoincrement())
  ruleId Int?
  rule   Rule?   @relation(fields: [ruleId], references: [id])
  value  String
  active Boolean @default(true)
}

model Rule {
  id         Int       @id @default(autoincrement())
  contractId Int?
  contract   Contract? @relation(fields: [contractId], references: [id])
  rights     Right[]
  value      String
  active     Boolean   @default(true)
}

enum Role {
  USER
  ADMIN
}

model Contract {
  id     Int    @id @default(autoincrement())
  userId Int    @unique
  user   User   @relation(fields: [userId], references: [id])
  rules  Rule[]
  role   Role   @default(USER)
}

model ResetPasswordToken {
  id        String   @id @default(uuid())
  createdAt DateTime @default(now()) @db.Timestamp(6)
  userId    Int
  user      User     @relation(fields: [userId], references: [id])
}

model User {
  id                 Int                  @id @default(autoincrement())
  name               String?              @db.VarChar(255)
  email              String               @unique @db.VarChar(255)
  password           String
  contract           Contract?
  resetPasswordToken ResetPasswordToken[]
}

An example in this schema is the @db.Timestamp. It should have (6), but in the output it does not

Screen Shot 2022-01-13 at 12 13 18 AM

All native @db fields behave this way.

Expected behavior
Any @db native type with an option should be moved over correctly with that option.

Screenshots

Screen Shot 2022-01-13 at 12 22 23 AM

Comments Break Parsing Logic

Describe the bug
It would seem that the presence of comments in my files is confusing aurora. In my org, we like to use comments as dividers to make our files easier to navigate, like so:

//--------------------------------------------------------------------------------------------------//

But the presence of a single //- sequence causes aurora to crash.

To Reproduce

  1. Install aurora.
  2. Pick the Author and Book schemas from README.md, and set up aurora.config.json` to combine them.
  3. Add //- anywhere in either file.
  4. Run aurora

Expected behavior
The two schemas are combined into a single schema

Actual Behavior
The following error is printed:

    / \     _   _   _ __    ___    _ __    __ _ 
   / _ \   | | | | | '__|  / _ \  | '__|  / _` |
  / ___ \  | |_| | | |    | (_) | | |    | (_| |
 /_/   \_\  \__,_| |_|     \___/  |_|     \__,_|
                                                
TypeError: Cannot read properties of undefined (reading 'filter')
    at /home/davidhorstman/GitHub/clipboard-staffing-api/node_modules/prisma-aurora/lib/helpers/parseSchema.js:103:84
    at Array.map (<anonymous>)
    at /home/davidhorstman/GitHub/clipboard-staffing-api/node_modules/prisma-aurora/lib/helpers/parseSchema.js:102:59
    at step (/home/davidhorstman/GitHub/clipboard-staffing-api/node_modules/prisma-aurora/lib/helpers/parseSchema.js:44:23)
    at Object.next (/home/davidhorstman/GitHub/clipboard-staffing-api/node_modules/prisma-aurora/lib/helpers/parseSchema.js:25:53)
    at fulfilled (/home/davidhorstman/GitHub/clipboard-staffing-api/node_modules/prisma-aurora/lib/helpers/parseSchema.js:16:58) Aurora could not parse the schema at ./src/modules/workers/worker-model.prisma. Please ensure it is of a proper format.
/home/davidhorstman/GitHub/clipboard-staffing-api/node_modules/prisma-aurora/lib/helpers/parseSchema.js:103
                                model.extendedFields = attributeData_1[model.name].filter(function (attribute) { return attribute.isFieldAttribute; });
                                                                                   ^

TypeError: Cannot read properties of undefined (reading 'filter')
    at /home/davidhorstman/GitHub/clipboard-staffing-api/node_modules/prisma-aurora/lib/helpers/parseSchema.js:103:84
    at Array.map (<anonymous>)
    at /home/davidhorstman/GitHub/clipboard-staffing-api/node_modules/prisma-aurora/lib/helpers/parseSchema.js:102:59
    at step (/home/davidhorstman/GitHub/clipboard-staffing-api/node_modules/prisma-aurora/lib/helpers/parseSchema.js:44:23)
    at Object.next (/home/davidhorstman/GitHub/clipboard-staffing-api/node_modules/prisma-aurora/lib/helpers/parseSchema.js:25:53)
    at fulfilled (/home/davidhorstman/GitHub/clipboard-staffing-api/node_modules/prisma-aurora/lib/helpers/parseSchema.js:16:58)

Desktop (please complete the following information):

  • OS: Windows 10, WSL2 (Ubuntu 20.04)

Screenshots
image

This project is abandoned.

It doesnt support new commands such as 'relationMode'.

GetDmmfError: Get DMMF: Schema parsing
error: Property not known: "relationMode".
 -->  schema.prisma:14

 url          = env("GPerson-DATABASE_URL")
 relationMode = "prisma"
 }

Is there a fork that still works?

One To many on itselft

Hi!

When I do this :

model Process {
    id        Int      @id @default(autoincrement())
    title String

    content String @db.Xml

    parentId Int?
    parent   Process?   @relation("ProcessParentChildren", fields: [parentId], references: [id])
    children  Process[]  @relation("ProcessParentChildren")
}

it generate me :

model Process {
  id       Int       @id @default(autoincrement())
  title    String
  content  String    @db.Xml
  parentId Int?
  parent Process? @relation(name:"ProcessParentChildren"fields:[parentId]references:[id])", fields: [parentId], references: [id])
  children Process[] @relation(name: "ProcessParentChildren")
}

The field parent do a weird thing on @relation.

Is it possible to fix it ?

Thanks

Unable to use Decimal @db.Money without including datasource in the partial schema file

If I have a column type of Decimal @db.Money in one of the schemas I'm importing in my aurora.config.json to merge, I get a panic from rust

To Reproduce
Steps to reproduce the behavior:

  1. Create prisma/base.prisma with contents:
datasource db {
  provider = "postgres"
  url      = env("DATABASE_URL")
}
generator client {
  provider = "prisma-client-js"
}
  1. Create ./prisma/model.prisma with content:
model MyModel {
  id String @id @default(cuid())
  value Decimal @db.Money
}
  1. Create aurora.config.json with
  "files": [
    "./prisma/base.prisma",
    "./prisma/model.prisma"
  ],
  "output": "./prisma/schema.prisma"
}
  1. Run aurora
  2. See error
Error: Command failed with exit code 101: /mnt/hdd/cloud/projects/code/apps/test-app/node_modules/@prisma/sdk/node_modules/@prisma/engines/prisma-fmt-debian-openssl-1.1.x format
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: DatamodelError(InvalidNativeType { native_type: "Money", span: Span { start: 186, end: 210 } })', libs/datamodel/core/src/transform/ast_to_dml/lift.rs:484:26
stack backtrace:
   0: rust_begin_unwind
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:498:5
   1: core::panicking::panic_fmt
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:116:14
   2: core::result::unwrap_failed
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/result.rs:1690:5
   3: datamodel::transform::ast_to_dml::lift::LiftAstToDml::lift_scalar_field_type
   4: datamodel::transform::ast_to_dml::lift::LiftAstToDml::lift
   5: datamodel::reformat::reformat
   6: prisma_fmt::format::run
   7: prisma_fmt::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
    at makeError (/mnt/hdd/cloud/projects/code/apps/test-app/node_modules/execa/lib/error.js:60:11)
    at handlePromise (/mnt/hdd/cloud/projects/code/apps/test-app/node_modules/execa/index.js:118:26)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async formatSchema (/mnt/hdd/cloud/projects/code/apps/test-app/node_modules/@prisma/sdk/dist/engine-commands/formatSchema.js:57:14) {
  shortMessage: 'Command failed with exit code 101: /mnt/hdd/cloud/projects/code/apps/test-app/node_modules/@prisma/sdk/node_modules/@prisma/engines/prisma-fmt-debian-openssl-1.1.x format',
  command: '/mnt/hdd/cloud/projects/code/apps/test-app/node_modules/@prisma/sdk/node_modules/@prisma/engines/prisma-fmt-debian-openssl-1.1.x format',
  escapedCommand: '"/mnt/hdd/cloud/projects/code/apps/test-app/node_modules/@prisma/sdk/node_modules/@prisma/engines/prisma-fmt-debian-openssl-1.1.x" format',
  exitCode: 101,
  signal: undefined,
  signalDescription: undefined,
  stdout: '',
  stderr: 'thread \'main\' panicked at \'called `Result::unwrap()` on an `Err` value: DatamodelError(InvalidNativeType { native_type: "Money", span: Span { start: 186, end: 210 } })\', libs/datamodel/core/src/transform/ast_to_dml/lift.rs:484:26\n' +
    'stack backtrace:\n' +
    '   0: rust_begin_unwind\n' +
    '             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:498:5\n' +
    '   1: core::panicking::panic_fmt\n' +
    '             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:116:14\n' +
    '   2: core::result::unwrap_failed\n' +
    '             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/result.rs:1690:5\n' +
    '   3: datamodel::transform::ast_to_dml::lift::LiftAstToDml::lift_scalar_field_type\n' +
    '   4: datamodel::transform::ast_to_dml::lift::LiftAstToDml::lift\n' +
    '   5: datamodel::reformat::reformat\n' +
    '   6: prisma_fmt::format::run\n' +
    '   7: prisma_fmt::main\n' +
    'note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.',
  failed: true,
  timedOut: false,
  isCanceled: false,
  killed: false
} Aurora could not parse the schema at ./prisma/model.prisma. Please ensure it is of a proper format.

Expected behavior
I expect the ./prisma/schema.prisma to be generated correctly

Desktop (please complete the following information):

  • OS: Linux
  • Version 5.16.12-arch1-1

tool version
"prisma-aurora": "^1.3.5",

Additional context
I can work around this by including a duplicate datasource db { provider = "postgres" url = env("DATABASE_URL") } into the second schema file, but it does mean I'm now having to declare this in every file that might be using this extended native type

Feature Request: Integration with the prisma VSC extension + Aurora VSC extension for auto completing relations.

Is your feature request related to a problem? Please describe.

  1. It's very annoying to duplicate a target relation model in the file when we need to use it in a model field.
// Author.prisma
model Author {
    id        Int @id @default(autoincrement())
    books     Book[]
}

model Book {
    id Int @id
    authorId Int
    author Author @relation(fields: [authorId], references: [id])
}
  1. There's no auto-completion in the relation models that are defined in other files.

Describe the solution you'd like

  1. Make a VSC extension for Aurora and Its job will be as the following:

    • Read the aurora.config.json file to get the files array so that we can add onChange watchers on the matching files using VSC SDK.
    • Add provideCompletionItems to the IntelliSense with the models specified in the files that we're watching to provide auto completion when writing relations in model fields.
    • Add an onChange watcher for the aurora.config.json to reset the files' watchers if it changes.
  2. Add an Integration for Aurora with Prisma's VSC extension as the following:

    • Ignore throwing errors on missing models in relationships when an aurora.config.json file is found in the project so that handling missing models will be Aurora's responsibility as it has all of the information about all of the models that are defined in the project.
  3. Add an optional config object to getDMMF so that we can optionally apply a feature to use Aurora which will skip throwing errors related to missing models in relations.

Additional context

I'm willing to contribute to this repo and the Prisma extension repo to implement this feature, just let me know WDYT?

Update @prisma/sdk to latest

We had to stick to @prisma/sdk v3.6.0 because of an issue with the library. A patch has been put out so we can now go back to normal "latest" versions of the library.

Model column attribute missing if referenced in multiple files

Describe the bug
Model column attribute missing if referenced in multiple files.

To Reproduce
Steps to reproduce the behavior:

user.prisma

model User {
  id        BigInt   @id @default(autoincrement())
  email     String   @unique
  name      String?
  role      String?
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
}

post.prisma

model Post {
  id        BigInt   @id @default(autoincrement())
  title     String
  authorId  BigInt
  published Boolean  @default(false)
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  author    User     @relation(fields: [authorId], references: [id])
}

model User {
  id    BigInt @id
  Posts Post[]
}

aurora.config.json

{
  "files": [
    "./db/provider/datasource.prisma",
    "./db/provider/generator.prisma",
    "./db/models/user.prisma",
    "./db/models/post.prisma"
  ],
  "output": "./db/dbcontext.prisma"
}

Output: dbcontext.prisma

// *** GENERATED BY AURORA :: DO NOT EDIT ***
datasource appDb {
  provider = "sqlite"
  url      = env("APP_DATABASE_URL")
}

generator prismaClient {
  provider = "prisma-client-js"
}

model User {
  id        BigInt   @id   //# 👈 `@default(autoincrement())` is missing
  Posts     Post[]
  email     String   @unique
  name      String?
  role      String?
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
}

model Post {
  id        BigInt   @id @default(autoincrement())
  title     String
  authorId  BigInt
  published Boolean  @default(false)
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  author    User     @relation(fields: [authorId], references: [id])
}

But, order of files matter

aurora.config.json

{
  "files": [
    "./db/provider/datasource.prisma",
    "./db/provider/generator.prisma",
    "./db/models/post.prisma",
    "./db/models/user.prisma"    # 👈 moved `user.prisma` after `post.prisma`
  ],
  "output": "./db/dbcontext.prisma"
}

It rectifies the output

Output: dbcontext.prisma

// *** GENERATED BY AURORA :: DO NOT EDIT ***
datasource appDb {
  provider = "sqlite"
  url      = env("APP_DATABASE_URL")
}

generator prismaClient {
  provider = "prisma-client-js"
}

model Post {
  id        BigInt   @id @default(autoincrement())
  title     String
  authorId  BigInt
  published Boolean  @default(false)
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  author    User     @relation(fields: [authorId], references: [id])
}

model User {
  id        BigInt   @id @default(autoincrement())  //# 👈 Fixed
  email     String   @unique
  name      String?
  role      String?
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  Posts     Post[]
}

Expected behavior
Model column should accumulate all attributes across files.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS] Linux, Node.js v14.17.3
  • Version [e.g. 22] v1.2.7

Additional context
Add any other context about the problem here.

Please stop bloating the output

Hello,

The following lines are unnecessary, and I hate having my terminal cleared by surprise.

aurora/src/index.ts

Lines 13 to 15 in 13ea9f1

// Console Welcome
clear();
console.log(chalk.bold.magenta(figlet.textSync('Aurora', { horizontalLayout: 'full' })));

Cannot fork and clone

When cloning my fork to my local computer, getting:

Cloning into 'aurora'...
remote: Enumerating objects: 1094, done.
remote: Counting objects: 100% (826/826), done.
remote: Compressing objects: 100% (642/642), done.
remote: Total 1094 (delta 525), reused 380 (delta 155), pack-reused 268
Receiving objects: 100% (1094/1094), 637.41 KiB | 5.40 MiB/s, done.
Resolving deltas: 100% (666/666), done.
error: invalid path 'src/tests/schemas/feature-specific/model-fields/model-field-?.prisma'
fatal: unable to checkout working tree
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry with 'git restore --source=HEAD :/'

If I run git status, I get:

Click to expand
On branch master
Your branch is up to date with 'origin/master'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        deleted:    .github/ISSUE_TEMPLATE/bug_report.md
        deleted:    .github/ISSUE_TEMPLATE/feature_request.md
        deleted:    .github/dependabot.yml
        deleted:    .github/workflows/codeql-analysis.yml
        deleted:    .github/workflows/node.js.yml
        deleted:    .github/workflows/npm-publish-github-packages.yml
        deleted:    .gitignore
        deleted:    .prettierignore
        deleted:    .prettierrc
        deleted:    README.md
        deleted:    aurora.config.json
        deleted:    generated.prisma
        deleted:    jest.config.js
        deleted:    lib/aurora.d.ts
        deleted:    lib/aurora.js
        deleted:    lib/functions/combineModels.d.ts
        deleted:    lib/functions/combineModels.js
        deleted:    lib/functions/getAuroraConfigJson.d.ts
        deleted:    lib/functions/getAuroraConfigJson.js
        deleted:    lib/functions/index.d.ts
        deleted:    lib/functions/index.js
        deleted:    lib/functions/parseSchema.d.ts
        deleted:    lib/functions/parseSchema.js
        deleted:    lib/functions/renderer.d.ts
        deleted:    lib/functions/renderer.js
        deleted:    lib/functions/test.d.ts
        deleted:    lib/functions/test.js
        deleted:    lib/functions/util.d.ts
        deleted:    lib/functions/util.js
        deleted:    lib/functions/writeSchema.d.ts
        deleted:    lib/functions/writeSchema.js
        deleted:    lib/helpers/CustomParsers/datasource-fields.d.ts
        deleted:    lib/helpers/CustomParsers/datasource-fields.js
        deleted:    lib/helpers/CustomParsers/generator-fields.d.ts
        deleted:    lib/helpers/CustomParsers/generator-fields.js
        deleted:    lib/helpers/CustomParsers/model-fields.d.ts
        deleted:    lib/helpers/CustomParsers/model-fields.js
        deleted:    lib/helpers/CustomParsers/parse-blocks.d.ts
        deleted:    lib/helpers/CustomParsers/parse-blocks.js
        deleted:    lib/helpers/combineModels.d.ts
        deleted:    lib/helpers/combineModels.js
        deleted:    lib/helpers/expandGlobPatterns.d.ts
        deleted:    lib/helpers/expandGlobPatterns.js
        deleted:    lib/helpers/getAuroraConfigJson.d.ts
        deleted:    lib/helpers/getAuroraConfigJson.js
        deleted:    lib/helpers/getModelFieldIndexes.d.ts
        deleted:    lib/helpers/getModelFieldIndexes.js
        deleted:    lib/helpers/getModelFieldMappings.d.ts
        deleted:    lib/helpers/getModelFieldMappings.js
        deleted:    lib/helpers/index.d.ts
        deleted:    lib/helpers/index.js
        deleted:    lib/helpers/parseModels.d.ts
        deleted:    lib/helpers/parseModels.js
        deleted:    lib/helpers/parseSchema.d.ts
        deleted:    lib/helpers/parseSchema.js
        deleted:    lib/helpers/renderer.d.ts
        deleted:    lib/helpers/renderer.js
        deleted:    lib/helpers/writeSchema.d.ts
        deleted:    lib/helpers/writeSchema.js
        deleted:    lib/index.d.ts
        deleted:    lib/index.js
        deleted:    lib/models/AuroraConfig.type.d.ts
        deleted:    lib/models/AuroraConfig.type.js
        deleted:    lib/models/ModelFields.type.d.ts
        deleted:    lib/models/ModelFields.type.js
        deleted:    lib/models/ModelIndex.type.d.ts
        deleted:    lib/models/ModelIndex.type.js
        deleted:    lib/models/ModelMappings.type.d.ts
        deleted:    lib/models/ModelMappings.type.js
        deleted:    lib/models/SchemaInformation.type.d.ts
        deleted:    lib/models/SchemaInformation.type.js
        deleted:    lib/models/index.d.ts
        deleted:    lib/models/index.js
        deleted:    lib/models/util.d.ts
        deleted:    lib/models/util.js
        deleted:    lib/tests/aurora.test.d.ts
        deleted:    lib/tests/aurora.test.js
        deleted:    lib/tests/combineModels.test.d.ts
        deleted:    lib/tests/combineModels.test.js
        deleted:    lib/tests/getModelFieldIndexes.test.d.ts
        deleted:    lib/tests/getModelFieldIndexes.test.js
        deleted:    lib/tests/helpers/mockConfigFetcher.d.ts
        deleted:    lib/tests/helpers/mockConfigFetcher.js
        deleted:    lib/tests/helpers/readFile.d.ts
        deleted:    lib/tests/helpers/readFile.js
        deleted:    lib/tests/parseSchema.test.d.ts
        deleted:    lib/tests/parseSchema.test.js
        deleted:    lib/tests/renderer.test.d.ts
        deleted:    lib/tests/renderer.test.js
        deleted:    lib/util/CONSTANTS.d.ts
        deleted:    lib/util/CONSTANTS.js
        deleted:    package-lock.json
        deleted:    package.json
        deleted:    prisma/schema.prisma
        deleted:    prisma/test.prisma
        deleted:    src/aurora.ts
        deleted:    src/helpers/CustomParsers/datasource-fields.ts
        deleted:    src/helpers/CustomParsers/generator-fields.ts
        deleted:    src/helpers/CustomParsers/model-fields.ts
        deleted:    src/helpers/CustomParsers/parse-blocks.ts
        deleted:    src/helpers/combineModels.ts
        deleted:    src/helpers/expandGlobPatterns.ts
        deleted:    src/helpers/getAuroraConfigJson.ts
        deleted:    src/helpers/index.ts
        deleted:    src/helpers/parseModels.ts
        deleted:    src/helpers/parseSchema.ts
        deleted:    src/helpers/renderer.ts
        deleted:    src/helpers/writeSchema.ts
        deleted:    src/index.ts
        deleted:    src/models/AuroraConfig.type.ts
        deleted:    src/models/ModelFields.type.ts
        deleted:    src/models/ModelIndex.type.ts
        deleted:    src/models/ModelMappings.type.ts
        deleted:    src/models/SchemaInformation.type.ts
        deleted:    src/models/index.ts
        deleted:    src/tests/aurora.test.ts
        deleted:    src/tests/combineModels.test.ts
        deleted:    src/tests/helpers/mockConfigFetcher.ts
        deleted:    src/tests/helpers/readFile.ts
        deleted:    src/tests/parseSchema.test.ts
        deleted:    src/tests/renderer.test.ts
        deleted:    src/tests/schemas/duplicates/schema.prisma
        deleted:    src/tests/schemas/duplicates/user.prisma
        deleted:    src/tests/schemas/feature-specific/datasource/datasource-env-url.prisma
        deleted:    src/tests/schemas/feature-specific/datasource/datasource-url.prisma
        deleted:    src/tests/schemas/feature-specific/enums/enum-single-letter.prisma
        deleted:    src/tests/schemas/feature-specific/enums/enum.prisma
        deleted:    src/tests/schemas/feature-specific/generators/generator-binary-env.prisma
        deleted:    src/tests/schemas/feature-specific/generators/generator-custom.prisma
        deleted:    src/tests/schemas/feature-specific/generators/generator-dupe-1.prisma
        deleted:    src/tests/schemas/feature-specific/generators/generator-dupe-2.prisma
        deleted:    src/tests/schemas/feature-specific/generators/generator.prisma
        deleted:    src/tests/schemas/feature-specific/generators/multipleGenerators.prisma
        deleted:    src/tests/schemas/feature-specific/generators/noGenerators.prisma
        deleted:    src/tests/schemas/feature-specific/model-fields/model-field-?.prisma
        deleted:    src/tests/schemas/feature-specific/model-fields/[email protected]
        deleted:    src/tests/schemas/feature-specific/model-fields/[email protected]
        deleted:    src/tests/schemas/feature-specific/model-fields/[email protected]
        deleted:    src/tests/schemas/feature-specific/model-fields/[email protected]
        deleted:    src/tests/schemas/feature-specific/model-fields/[email protected]
        deleted:    src/tests/schemas/feature-specific/model-fields/[email protected]
        deleted:    src/tests/schemas/feature-specific/model-fields/[email protected]
        deleted:    src/tests/schemas/feature-specific/model-fields/[email protected]
        deleted:    src/tests/schemas/feature-specific/model-fields/[email protected]
        deleted:    src/tests/schemas/feature-specific/model-fields/[email protected]
        deleted:    src/tests/schemas/feature-specific/model-fields/[email protected]
        deleted:    src/tests/schemas/feature-specific/model-fields/[email protected]
        deleted:    src/tests/schemas/feature-specific/model-fields/[email protected]
        deleted:    src/tests/schemas/feature-specific/model-fields/[email protected]
        deleted:    src/tests/schemas/feature-specific/model-fields/[email protected]
        deleted:    src/tests/schemas/feature-specific/model-fields/[email protected]
        deleted:    src/tests/schemas/feature-specific/model-fields/[email protected]
        deleted:    src/tests/schemas/feature-specific/model-fields/[email protected]
        deleted:    src/tests/schemas/feature-specific/model-fields/[email protected]
        deleted:    src/tests/schemas/feature-specific/model-fields/[email protected]
        deleted:    src/tests/schemas/feature-specific/model-fields/[email protected]
        deleted:    src/tests/schemas/feature-specific/model-fields/[email protected]
        deleted:    src/tests/schemas/feature-specific/model-fields/[email protected]
        deleted:    src/tests/schemas/feature-specific/model-fields/model-field-[].prisma
        deleted:    src/tests/schemas/feature-specific/models/model-@@fulltext.prisma
        deleted:    src/tests/schemas/feature-specific/models/model-@@id-fields.prisma
        deleted:    src/tests/schemas/feature-specific/models/model-@@id-map.prisma
        deleted:    src/tests/schemas/feature-specific/models/model-@@id-name.prisma
        deleted:    src/tests/schemas/feature-specific/models/model-@@id.prisma
        deleted:    src/tests/schemas/feature-specific/models/model-@@ignore.prisma
        deleted:    src/tests/schemas/feature-specific/models/model-@@index-fields.prisma
        deleted:    src/tests/schemas/feature-specific/models/model-@@index-map.prisma
        deleted:    src/tests/schemas/feature-specific/models/model-@@index-name.prisma
        deleted:    src/tests/schemas/feature-specific/models/model-@@index.prisma
        deleted:    src/tests/schemas/feature-specific/models/model-@@map-name.prisma
        deleted:    src/tests/schemas/feature-specific/models/model-@@map.prisma
        deleted:    src/tests/schemas/feature-specific/models/model-@@unique-fields.prisma
        deleted:    src/tests/schemas/feature-specific/models/model-@@unique-map.prisma
        deleted:    src/tests/schemas/feature-specific/models/model-@@unique-name.prisma
        deleted:    src/tests/schemas/feature-specific/models/model-@@unique.prisma
        deleted:    src/tests/schemas/feature-specific/models/model.prisma
        deleted:    src/tests/schemas/glob-test/enums/environment.prisma
        deleted:    src/tests/schemas/glob-test/enums/test.prisma
        deleted:    src/tests/schemas/glob-test/models/person.prisma
        deleted:    src/tests/schemas/glob-test/models/user.prisma
        deleted:    src/tests/schemas/glob-test/providers/datasource.prisma
        deleted:    src/tests/schemas/glob-test/providers/generator.prisma
        deleted:    src/tests/schemas/glob-test/providers/secondGenerator.prisma
        deleted:    src/tests/schemas/parseSchema.prisma
        deleted:    src/util/CONSTANTS.ts
        deleted:    tsconfig.json

Desktop

  • Git: Version 2.35.1.windows.2
  • OS: Windows 10 Version 19044.152
  • Latest commit: 13ea9f1

Things I've tried:

  1. Deleting my forked repo and re-forking
  2. Running git restore --source=HEAD :/ I get:
    • error: invalid path 'src/tests/schemas/feature-specific/model-fields/model-field-?.prisma'

I believe this is because ? is an invalid character in file names on windows.

Installation failed

Hi,

After updated the new version [email protected]

It throw me an error :

aurora                        
internal/modules/cjs/loader.js:883
  throw err;
  ^

Error: Cannot find module 'fs-jetpack'
Require stack:
- /usr/local/lib/node_modules/prisma-aurora/node_modules/@prisma/sdk/dist/utils/jestContext.js
- /usr/local/lib/node_modules/prisma-aurora/node_modules/@prisma/sdk/dist/index.js
- /usr/local/lib/node_modules/prisma-aurora/lib/helpers/parseSchema.js
- /usr/local/lib/node_modules/prisma-aurora/lib/helpers/index.js
- /usr/local/lib/node_modules/prisma-aurora/lib/aurora.js
- /usr/local/lib/node_modules/prisma-aurora/lib/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/prisma-aurora/node_modules/@prisma/sdk/dist/utils/jestContext.js:30:36)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/usr/local/lib/node_modules/prisma-aurora/node_modules/@prisma/sdk/dist/utils/jestContext.js',
    '/usr/local/lib/node_modules/prisma-aurora/node_modules/@prisma/sdk/dist/index.js',
    '/usr/local/lib/node_modules/prisma-aurora/lib/helpers/parseSchema.js',
    '/usr/local/lib/node_modules/prisma-aurora/lib/helpers/index.js',
    '/usr/local/lib/node_modules/prisma-aurora/lib/aurora.js',
    '/usr/local/lib/node_modules/prisma-aurora/lib/index.js'
  ]
}

Do you hava this error too ?

Thanks,

@db type attributes resulting in a compilation error

Describe the bug
Putting together a schema and looking to use the @db type annotations results in a compilation error with the message about InvalidNativeType.

This is the case regardless of the @db type annotation used (VarChar, DateTime etc..).

Is this expected behaviour which is on a roadmap to implement or is it a bug that needs addressing ?

To Reproduce

Have a file named connection.prisma as follows:

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["referentialIntegrity"]
  binaryTargets   = ["native", "rhel-openssl-1.0.x", "linux-arm64-openssl-1.0.x"]
}

datasource db {
  provider             = "mysql"
  url                  = env("DATABASE_STAGING_URL")
  shadowDatabaseUrl    = env("DATABASE_SHADOW_URL")
  referentialIntegrity = "prisma"
}

Have a model defined as this in a file named (currency.prisma):

model Currency {
  id              Int               @id @default(autoincrement())
  code            String            @unique
  description     String
  createdAt       DateTime          @default(now()) @db.DateTime(6)
  updatedAt       DateTime          @updatedAt  @db.DateTime(6)
}

And an aurora.config.json file which looks like:

{
  "files": [
    "./connection.prisma",
    "./currency.prisma"
  ],
  "output": "./schema.prisma"
}

Run the aurora command

Expected behavior
A schema file is created which contains the native type annotations

Screenshots
image

Desktop (please complete the following information):

  • macOS 12.1
  • Node 14.18.2
  • Prisma: 3.8.1

onDelete is overwrite

Hi !

When I'm writing :
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)

After running aurora it erase the onDelete: Cascade and generate :
organization Organization? @relation(name: "OrganizationToOrganizationContract", fields: [organizationId], references: [id])

Is it possible to fix it ?

Thanks,

I really like your solution !

Regression: v1.3.7 fails to run ("could not determine executable to run")

Describe the bug
After updating to v1.3.7, aurora fails to run with the following error:

npm ERR! could not determine executable to run

Running the previous version (via npx [email protected]) works as expected.

The same error also occurs when running aurora via npx prisma-aurora or yarn dlx prisma-aurora. Both npx [email protected] and yarn dlx [email protected] work just fine.

I'm guessing this is because the "bin" field was removed from the package.json file in be3b0d2.

To Reproduce
Steps to reproduce the behavior:

  1. Create a new, empty npm project (e.g. via npm init)
  2. Run npm i --save-dev [email protected]
  3. Run npm exec aurora (or add a start script to the package.json ("scripts": { "start": "aurora" }) and run npm start)
  4. The above error is shown

After reverting to v1.3.6 using npm i --save-dev [email protected], the above commands run just fine (well, the actual runs fail, but that's because there's no aurora config available in this example).

Expected behavior
Running npm exec aurora works like normal

Desktop (please complete the following information):

  • OS: Linux (Manjaro)
  • Node: v17.8.0
  • npm: 8.5.5

Db declarations files BUG

Hi,

I have two prisma files:

Post.prisma

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model Post {
  id        Int      @id @default(autoincrement())
  title     String   @db.VarChar(255)
  createdAt DateTime @default(now()) @db.Timestamp(6)
  content   String?
  published Boolean  @default(false)
  authorId  Int
  author    User      @relation(fields: [authorId], references: [id])
}

model User {
    id      Int      @id @default(autoincrement())
    posts     Post[]
}

User.prisma

generator client {
  provider = "prisma-client-js"
  previewFeatures = ["interactiveTransactions"]
  output   = "../src/generated/client"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model Right {
  id        Int      @id @default(autoincrement())
  ruleId  Int?
  rule    Rule?      @relation(fields: [ruleId], references: [id])
  value String
  active Boolean @default(true)
}

model Rule {
  id        Int      @id @default(autoincrement())
  contractId  Int?
  contract    Contract?      @relation(fields: [contractId], references: [id])
  rights Right[]
  value String
  active Boolean @default(true)
}

enum Role {
  USER
  ADMIN
}

model Contract {
  id        Int      @id @default(autoincrement())
  userId  Int
  user    User      @relation(fields: [userId], references: [id])
  rules Rule[]
  role  Role    @default(USER)
}

model ResetPasswordToken {
  id          String      @id @default(uuid())
  createdAt   DateTime    @default(now()) @db.Timestamp(6)
  userId      Int
  user    User      @relation(fields: [userId], references: [id])
}

model User {
  id      Int      @id @default(autoincrement())
  name    String?  @db.VarChar(255)
  email   String   @unique @db.VarChar(255)
  password String
  contract Contract?
  resetPasswordToken ResetPasswordToken[]
}

When I run aurora, it throw me an error:
There were 2 different datasources provided. Make sure all of the datasources are the same. (node:31535) UnhandledPromiseRejectionWarning: Error: There was an issue with at least one of your schemas at /usr/local/lib/node_modules/prisma-aurora/lib/aurora.js:68:31 at step (/usr/local/lib/node_modules/prisma-aurora/lib/aurora.js:33:23) at Object.next (/usr/local/lib/node_modules/prisma-aurora/lib/aurora.js:14:53) at fulfilled (/usr/local/lib/node_modules/prisma-aurora/lib/aurora.js:5:58) at processTicksAndRejections (internal/process/task_queues.js:93:5) (Use node --trace-warnings ...to show where the warning was created) (node:31535) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag--unhandled-rejections=strict(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:31535) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

That is because I have two db {} declaration. But I need it because I'm using @db.VarChar(255) or @db.Timestamp(6)

How can I fix it ?

Running aurora

Hi,

Thanks for this new service that can help a lot !

I don't know how to run aurora, can you please describe more how to run it after download the package ?

Thanks

Bug launch aurora

Hi,

After downloading the new version aurora, it throw me an error :

aurora
internal/modules/cjs/loader.js:1080
      throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath);
      ^

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /usr/local/lib/node_modules/prisma-aurora/node_modules/chalk/source/index.js
require() of ES modules is not supported.
require() of /usr/local/lib/node_modules/prisma-aurora/node_modules/chalk/source/index.js from /usr/local/lib/node_modules/prisma-aurora/lib/index.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename /usr/local/lib/node_modules/prisma-aurora/node_modules/chalk/source/index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /usr/local/lib/node_modules/prisma-aurora/node_modules/chalk/package.json.

    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1080:13)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/prisma-aurora/lib/index.js:26:31)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14) {
  code: 'ERR_REQUIRE_ESM'
}

How to fix it ?

Thanks

Enums aren't overrided

Describe the bug
Enums aren't overrided.

To Reproduce

  1. Create a file with an enum called Example with two values;
  2. Create another file with a model referring the enum Example;
  3. On the file with the model, create another enum called Example with any one value as a placeholder;
  4. Run npx aurora;
  5. There are two enum with the name Example in the output file.

Expected behavior
The output file should have only one enum called Example and its content should be the one on the first folder.

Desktop

  • OS: Ubuntu 20.04.4 LTS

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.