We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi !
When using a schema on a table A, but not on table B, an incorrect SQL is generated for migrations.
To Reproduce
Entity one.ts (with a schema):
one.ts
import { Entity, PrimaryKey, ManyToOne, type Rel } from "@mikro-orm/postgresql"; import { Two } from "./two.js"; @Entity({ tableName: 'one', schema: 'test' }) export class One { @PrimaryKey() id: string = crypto.randomUUID(); @ManyToOne(() => Two, { deleteRule: 'cascade' }) two!: Rel<Two>; }
Entity two.ts (without schema):
two.ts
import { Entity, PrimaryKey } from "@mikro-orm/postgresql"; @Entity({ tableName: 'two' }) export class Two { @PrimaryKey() id: string = crypto.randomUUID(); }
Generated migration:
import { Migration } from '@mikro-orm/migrations'; export class Migration20231111090839 extends Migration { async up(): Promise<void> { this.addSql('create schema if not exists "test";'); this.addSql('create table "two" ("id" varchar(255) not null, constraint "two_pkey" primary key ("id"));'); this.addSql('create table "test"."one" ("id" varchar(255) not null, "two_id" varchar(255) not null, constraint "one_pkey" primary key ("id"));'); this.addSql('alter table "test"."one" add constraint "one_two_id_foreign" foreign key ("two_id") references "test"."two" ("id") on update cascade on delete cascade;'); } async down(): Promise<void> { this.addSql('drop table if exists "two" cascade;'); this.addSql('drop table if exists "test"."one" cascade;'); this.addSql('drop schema "test";'); } }
It tries to create a foreign key referencing "test.two", which does not exist (two does not have any schema).
two
Versions
| node | 20 | | mikro-orm | 6.0-rc0 | | your-driver | postgresql |
The text was updated successfully, but these errors were encountered:
aa2e889
fix(schema): do not inherit schema for FKs if not a wildcard entity
cc7fed9
Closes #4918
No branches or pull requests
Hi !
When using a schema on a table A, but not on table B, an incorrect SQL is generated for migrations.
To Reproduce
Entity
one.ts
(with a schema):Entity
two.ts
(without schema):Generated migration:
It tries to create a foreign key referencing "test.two", which does not exist (
two
does not have any schema).Versions
| node | 20 |
| mikro-orm | 6.0-rc0 |
| your-driver | postgresql |
The text was updated successfully, but these errors were encountered: