Skip to content

Fix schema-sync indexes for Postgres schemas#3085

Open
ouywm wants to merge 1 commit into
SeaQL:masterfrom
ouywm:fix/schema-sync-index-non-default-schema-3084
Open

Fix schema-sync indexes for Postgres schemas#3085
ouywm wants to merge 1 commit into
SeaQL:masterfrom
ouywm:fix/schema-sync-index-non-default-schema-3084

Conversation

@ouywm

@ouywm ouywm commented Jun 14, 2026

Copy link
Copy Markdown

PR Info

New Features

  • None

Bug Fixes

  • Fix schema-sync generated indexes for entities in non-default PostgreSQL schemas.

    Schema-sync can already discover and match tables in non-default PostgreSQL schemas after entity sync does not work with postgres when tables have schemas defined #2952 / Fix schema sync not discovering tables in non-default schemas #3016. However, indexes generated from entity attributes still used the unqualified table name.

    For an entity declared with #[sea_orm(schema_name = "sys", table_name = "app_user")], generated index DDL could target ON "app_user" instead of ON "sys"."app_user". When the connection's search_path still resolves unqualified table names in public, sync can fail with relation "app_user" does not exist, or target a same-named table in the wrong schema.

Breaking Changes

  • None. This is backward compatible. MySQL and SQLite index generation keep using unqualified table names.

Changes

  • Use Entity::table_ref() for generated index targets on PostgreSQL, so schema_name is included when present.
  • Keep MySQL and SQLite generated index targets unchanged.
  • Add unit coverage for generated indexes on an entity with an explicit PostgreSQL schema.
  • Add schema-sync regression coverage for #[sea_orm(indexed)] and multi-column #[sea_orm(unique_key = "...")] in a non-default PostgreSQL schema.
  • Mirror the fix and tests in sea-orm-sync.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

schema-sync creates indexes against unqualified table names for entities in non-default PostgreSQL schemas

1 participant