Eric Kidd
09/14/2021, 12:57 PMFOREIGN KEY constraints. But in practice, it's very hard to make them work.
Is there any way to use things like db pull and Prisma joins without actually having FOREIGN KEY constraints? For example, could db pull be convinced to ignore manually-added relations? Or is this basically hopeless? Thank you for any advice you can provide!Ryan
09/14/2021, 1:12 PMEric Kidd
09/14/2021, 1:16 PMdb pull preserve manually added relations. We don't use `migrate`; we have another tool for that.
I'll follow up shortly with the result of trying this. Thanks!Eric Kidd
09/14/2021, 1:38 PMpreviewFeatures = ["planetScaleMode"] set, prisma db pull still removes any relation fields and @relation attributes that I've added manually. š
I could try writing a script to re-insert all of these fields after each db pull, but that would be rather clunky.
The underlying problem is that Citus struggles with FOREIGN KEY relationships on distributed tables. It can be made to work (most of the time!) if the foreign key relationships are carefully created in the right order, but sometimes it's necessary to completely recreate distributed production tables to add a constraint.
Thank you for the suggestion!Eric Kidd
09/14/2021, 1:42 PMdb pull if the underlying database doesn't fully support FOREIGN KEY constraints.Ryan
09/14/2021, 1:44 PMEric Kidd
09/14/2021, 1:45 PMError: Get config: Schema Parsing P1012
error: Preview features are only supported in the generator block. Please move this field to the generator block.
--> schema.prisma:9
|
8 | url = "<postgres://postgres@localhost:15432/postgres>"
9 | previewFeatures = ["planetScaleMode"]
|
Validation Error Count: 1Eric Kidd
09/14/2021, 1:45 PMEric Kidd
09/14/2021, 1:46 PMRyan
09/14/2021, 1:47 PMplanetScaleMode = true to the datasource.Eric Kidd
09/14/2021, 1:49 PMdatasource db {
provider = "postgresql"
url = "<postgres://postgres@localhost:15432/postgres>"
planetScaleMode = true
}
...then db pull deletes the planetScaleMode = true line from the output.Eric Kidd
09/14/2021, 1:50 PMRyan
09/14/2021, 2:02 PMjanpio
janpio
Eric Kidd
09/14/2021, 2:34 PMjanpio
janpio
janpio
Eric Kidd
09/14/2021, 2:36 PMgenerator client {
provider = "prisma-client-js"
previewFeatures = ["planetScaleMode"]
}
datasource db {
provider = "postgresql"
url = "<postgres://postgres@localhost:15432/postgres>"
planetScaleMode = true
}
After `npx prisma db pull`:
generator client {
provider = "prisma-client-js"
previewFeatures = ["planetScaleMode"]
}
datasource db {
provider = "postgresql"
url = "<postgres://postgres@localhost:15432/postgres>"
}Eric Kidd
09/14/2021, 2:47 PMjanpio
janpio
janpio
Eric Kidd
09/14/2021, 2:53 PMjanpio
janpio
janpio
Eric Kidd
09/14/2021, 2:58 PMschema.prisma after every prisma db pull, at least for now. Thank you for looking into this!janpio
janpio