-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Epic: Support Native Database Types #3447
Comments
The solution looks really clean ! Adding support for native types in Migrate will come later. => Any chance you could move this to the next steps ? Unplanned sounds a little bit scary. Imo this is one of the most valuable features to have when trying to push for prisma adoption in a project. |
I updated the description from |
@Hebilicious We definitely have plans to support these additional native types in migrate. It's just not our current top priority (that's releasing a production-ready version of migrate), but we definitely want to add this capability sooner rather than later as we consider this really important (could potentially be in scope for the GA release). |
Hey, I'm just wondering if there is a reason, why there is blob support for MySQL but not bytea for Postgres. Is it still on the current roadmap? Or is there any other recommended way, that is better for storing images? Keep up the good work! Cheers |
@chrissisura |
@pantharshit00 Thanks for clearing that up! I was just confused because ByteA hasn't been mentioned on the Type List mentioned in the initial post nor anywhere on this thread and the subPage on ByteType Support page switched over to this one, so I was afraid the focus was heavier on other types. |
Extended native database type support is a preview feature in |
Would this feature include Postgres's native |
{ mode: "insensitive" } query option not working with PostgresQL UUID native type because "function lower(uuid) does not exist", which is really annoying because it means prisma studio relation browsing (opening in new Tab) doesn't work as they always query with mode: "insensitive" on |
@chrissisura Thanks for reporting. I have opened: #5311 We will address that soon. |
In addition to the native types originally in scope and documented here, we are also adding the following types on PostgreSQL:
|
Native types was released in General Availability in 2.17.0. Release notes: https://github.com/prisma/prisma/releases/tag/2.17.0 |
Problem
Today we support the following core data types across databases:
While this is a useful set of data types for getting started, many databases offer a richer set of native database types. For example,
numeric
,date
,varchar
,smallint
, andmoney
.blob
,varbinary
, andset
.These datatypes influence how the data is stored and the operations you can perform on that data. Prisma needs to understand these native database types better across it's tooling.
Int
could map to ainteger
,smallint
orbigint
.bigint
.Int
tointeger
, but we cannot mapInt
tobigint
. We also cannot currently generate text fields from the String type without more granular data types.money
type could be prefixed with$
.Solution
In the last days we looked into this and have reached internal consensus on a proposal.
The proposal is based on the mechanism that a user is decorating a field with an additional attribute that specifies the native data type in the underlying datasource. The attribute is scoped to the underlying datasource by prefixing it with
{datasource_name}.{data_type_name}
. The scoping is intended for future proofing the schema for support for multiple datasources within one schema.Notes
which one in the datasource because the combination is spelled out explicitly.
varchar(x)
on Postgres becomes@myb.VarChar(x)
.String
is compatible with@mydb.VarChar(x)
and@mydb.Text
. ButString
is not compatible with@mydb.XML
. The parser will validate this and error for wrong combinations. The VS Code extension will be to assist with this through auto completion.Status
Unsupported
type: Ensure Prisma Migrate does not drop columns or tables with columns of unsupported types - these columns are also not exposed in Client [Native Types] Ensure that fields of unsupported types aren't dropped #3673dbgenerated(STRING)
: Make it possible to encode raw database defaults in the@default
attribute of fields@@ignore
attribute for models and@ignore
attribute for fields to be managed via Prisma Migrate and introspection but not surfaced in Prisma Client Schema notation to not surface specific models in the Prisma Client API #5217Not planned yet
Related issues
Additional context
The text was updated successfully, but these errors were encountered: