Skip to content
This repository was archived by the owner on Oct 21, 2020. It is now read-only.

Conversation

sorenbs
Copy link
Member

@sorenbs sorenbs commented Feb 10, 2020

No description provided.

@sorenbs sorenbs requested a review from schickling as a code owner February 10, 2020 21:14

- add the `@updatedAt` attribute to all fields called updatedAt or updated_at
- add the `@createdAt` attribute to all fields called createdAt
- add `@id` and `@default(cuid)` attributes to all fields that end with _id.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- add `@id` and `@default(cuid)` attributes to all fields that end with _id.
- add `@id` and `@default(cuid)` attributes to all fields that end with ´_id`.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of my tables use uppercase ID ending for keys, maybe match all that begins or ends with /id/i

- **fieldPatterns**: Add attributes to a field by matching on its name
- **modelPatterns**: Add attributes to a model by matching on its name

The configuration is stored in a `prismarc.json` file next to the `schema.prisma` file. The following example will
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this filename? Wouldn't a introspection-config.json be clearer in the prisma folder?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree rc ending does not evoke anything to me.


The configuration is stored in a `prismarc.json` file next to the `schema.prisma` file. The following example will

- add the `@updatedAt` attribute to all fields called updatedAt or updated_at
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- add the `@updatedAt` attribute to all fields called updatedAt or updated_at
- add the `@updatedAt` attribute to all fields called `updatedAt` or `updated_at`

The configuration is stored in a `prismarc.json` file next to the `schema.prisma` file. The following example will

- add the `@updatedAt` attribute to all fields called updatedAt or updated_at
- add the `@createdAt` attribute to all fields called createdAt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- add the `@createdAt` attribute to all fields called createdAt
- add the `@createdAt` attribute to all fields called `createdAt`

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this also include created_at same as ˙updated_at˙ does?


> Note: I am not wild about the format itself, but it can be changed in the future
See the full Prisma Config spec for more details
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?


> Note: This list should be moved to a separate introspection spec
**Variations of updatedAt fields**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
**Variations of updatedAt fields**
**Variations of `updatedAt` fields**

"@updatedAt": "/^updatedAt|updated_at|updated_on|updated|updateDate|updatedDate|lastModifiedDate$/",
```

**Variations of createdAt fields**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
**Variations of createdAt fields**
**Variations of `createdAt` fields**

- **fieldPatterns**: Add attributes to a field by matching on its name
- **modelPatterns**: Add attributes to a model by matching on its name

The configuration is stored in a `prismarc.json` file next to the `schema.prisma` file. The following example will
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree rc ending does not evoke anything to me.

The configuration is stored in a `prismarc.json` file next to the `schema.prisma` file. The following example will

- add the `@updatedAt` attribute to all fields called updatedAt or updated_at
- add the `@createdAt` attribute to all fields called createdAt
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this also include created_at same as ˙updated_at˙ does?


- add the `@updatedAt` attribute to all fields called updatedAt or updated_at
- add the `@createdAt` attribute to all fields called createdAt
- add `@id` and `@default(cuid)` attributes to all fields that end with _id.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of my tables use uppercase ID ending for keys, maybe match all that begins or ends with /id/i


### Considerations for the first-run experience

When a user first approaches Prisma, they will rin `prisma generate` immediadtely after running `prisma init`. As such, there will be no `prismarc.json` file, an the Inferred Introspection Configuration is triggered.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"they will run prisma generate" typo.

I would like to mention first thing I ran after init was prisma introspect, as this was the biggest selling point for me.

Shoudnt the prisma init generate the configuration file too?

Comment on lines +245 to +253
{
"introspection": {
fieldPatterns: {
"@updatedAt": "/^updatedAt|updated_at$/",
"@createdAt": "/^createdAt$/",
"@id @default(cuid())": "/_id$/",
}
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to be able to set how columns name should be mapped when invalid key is encountered.

{
  invalidCharactersReplacements: {
    caseInsensitive: {
      "€": ["eur"],
      "a": ["á"],
      "c": ["č"],
      "e": ["é", "ě"],
      "i": ["í"],
      ...
    },
    caseSensitive: { ... }
  },
}

Possibly use https://stackoverflow.com/a/18391901/3001856 (It is easier to write, and

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants