-
Notifications
You must be signed in to change notification settings - Fork 16
Introspection Configuration #408
base: master
Are you sure you want to change the base?
Conversation
|
||
- 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 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`. |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- add the `@createdAt` attribute to all fields called createdAt | |
- add the `@createdAt` attribute to all fields called `createdAt` |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
**Variations of updatedAt fields** | |
**Variations of `updatedAt` fields** |
"@updatedAt": "/^updatedAt|updated_at|updated_on|updated|updateDate|updatedDate|lastModifiedDate$/", | ||
``` | ||
|
||
**Variations of createdAt fields** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
**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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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?
{ | ||
"introspection": { | ||
fieldPatterns: { | ||
"@updatedAt": "/^updatedAt|updated_at$/", | ||
"@createdAt": "/^createdAt$/", | ||
"@id @default(cuid())": "/_id$/", | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
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
No description provided.