Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
qe: fix implicit many-to-many relations in multiSchema context
We did not add any schema prefix there. We now add the correct one (the schema of the first model). closes prisma/prisma#16761
- Loading branch information
Showing
3 changed files
with
103 additions
and
2 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
...ts/postgres/multi_schema_implicit_many_to_many_join_table_is_in_first_model_schema.prisma
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,64 @@ | ||
// tags=postgres | ||
// exclude=cockroachdb | ||
|
||
datasource testds { | ||
provider = "postgresql" | ||
url = env("TEST_DATABASE_URL") | ||
schemas = ["veggies", "roots"] | ||
} | ||
|
||
generator js { | ||
provider = "prisma-client-js" | ||
previewFeatures = ["multiSchema"] | ||
} | ||
|
||
model zoodles { | ||
id Int @id | ||
shiratakies shirataki[] | ||
@@schema("veggies") | ||
} | ||
|
||
model shirataki { | ||
id Int @id | ||
zoodles zoodles[] | ||
@@schema("roots") | ||
} | ||
|
||
// Expected Migration: | ||
// -- CreateSchema | ||
// CREATE SCHEMA IF NOT EXISTS "roots"; | ||
// | ||
// -- CreateSchema | ||
// CREATE SCHEMA IF NOT EXISTS "veggies"; | ||
// | ||
// -- CreateTable | ||
// CREATE TABLE "veggies"."zoodles" ( | ||
// "id" INTEGER NOT NULL, | ||
// | ||
// CONSTRAINT "zoodles_pkey" PRIMARY KEY ("id") | ||
// ); | ||
// | ||
// -- CreateTable | ||
// CREATE TABLE "roots"."shirataki" ( | ||
// "id" INTEGER NOT NULL, | ||
// | ||
// CONSTRAINT "shirataki_pkey" PRIMARY KEY ("id") | ||
// ); | ||
// | ||
// -- CreateTable | ||
// CREATE TABLE "roots"."_shiratakiTozoodles" ( | ||
// "A" INTEGER NOT NULL, | ||
// "B" INTEGER NOT NULL | ||
// ); | ||
// | ||
// -- CreateIndex | ||
// CREATE UNIQUE INDEX "_shiratakiTozoodles_AB_unique" ON "roots"."_shiratakiTozoodles"("A", "B"); | ||
// | ||
// -- CreateIndex | ||
// CREATE INDEX "_shiratakiTozoodles_B_index" ON "roots"."_shiratakiTozoodles"("B"); | ||
// | ||
// -- AddForeignKey | ||
// ALTER TABLE "roots"."_shiratakiTozoodles" ADD CONSTRAINT "_shiratakiTozoodles_A_fkey" FOREIGN KEY ("A") REFERENCES "roots"."shirataki"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
// | ||
// -- AddForeignKey | ||
// ALTER TABLE "roots"."_shiratakiTozoodles" ADD CONSTRAINT "_shiratakiTozoodles_B_fkey" FOREIGN KEY ("B") REFERENCES "veggies"."zoodles"("id") ON DELETE CASCADE ON UPDATE CASCADE; |
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