-
Notifications
You must be signed in to change notification settings - Fork 194
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
Spike out prisma talking directly to Postgres DB #1115
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
generator client { | ||
provider = "prisma-client-js" | ||
} | ||
|
||
datasource db { | ||
provider = "postgresql" | ||
url = env("DATABASE_URL") | ||
} | ||
|
||
model roles { | ||
id Int @id @default(autoincrement()) | ||
name String? @db.VarChar(255) | ||
resource_id Int? | ||
resource_type String? @db.VarChar(255) | ||
created_at DateTime? @db.Timestamp(6) | ||
updated_at DateTime? @db.Timestamp(6) | ||
users_roles users_roles[] @ignore | ||
|
||
@@index([name], map: "index_roles_on_name") | ||
@@index([name, resource_type, resource_id], map: "index_roles_on_name_and_resource_type_and_resource_id") | ||
} | ||
|
||
model users { | ||
id Int @id @default(autoincrement()) | ||
email String @unique(map: "index_users_on_email") @default("") @db.VarChar(255) | ||
created_at DateTime? @db.Timestamp(6) | ||
updated_at DateTime? @db.Timestamp(6) | ||
first_name String? @db.VarChar(255) | ||
last_name String? @db.VarChar(255) | ||
users_roles users_roles[] @ignore | ||
|
||
@@index([id], map: "index_users_on_lower_email_id") | ||
} | ||
|
||
/// The underlying table does not contain a valid unique identifier and can therefore currently not be handled by the Prisma Client. | ||
model users_roles { | ||
user_id Int | ||
role_id Int | ||
roles roles @relation(fields: [role_id], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "fk_rails_eb7b4658f8") | ||
users users @relation(fields: [user_id], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "fk_rails_4a41696df6") | ||
|
||
@@index([role_id], map: "index_users_roles_on_role_id") | ||
@@index([user_id], map: "index_users_roles_on_user_id") | ||
@@index([user_id, role_id], map: "index_users_roles_on_user_id_and_role_id") | ||
@@ignore | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
For the sake of this PoC, I bailed on the standard query syntax and did a raw SQL query below. This only happened here because the
users_roles
table had to be ignored as a model inschema.prisma
because it doesn't have a unique primary key. There are some ways we could work around that, but I didn't want to get into those weeds.Otherwise, we get really nice auto-generated TypeScript types for all of this.