Fix schema sync not discovering tables in non-default schemas#3016
Open
ouywm wants to merge 3 commits intoSeaQL:masterfrom
Open
Fix schema sync not discovering tables in non-default schemas#3016ouywm wants to merge 3 commits intoSeaQL:masterfrom
ouywm wants to merge 3 commits intoSeaQL:masterfrom
Conversation
5a47cca to
798bc48
Compare
Author
|
Done. The unrelated changes were from make-sync.sh syncing other pending commits into sea-orm-sync/. Already cleaned up — now only the two builder.rs files remain.
… 2026年3月22日 18:57,狐狸 ***@***.***> 写道:
Huliiiiii
left a comment
(SeaQL/sea-orm#3016)
<#3016 (comment)>
Please cleanup unrelated changes.
—
Reply to this email directly, view it on GitHub <#3016?email_source=notifications&email_token=A3ESMEE2R3KR43EAO5RKZS34R7BLPA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTIMJQGYYDAMBXGM42M4TFMFZW63VGMF2XI2DPOKSWK5TFNZ2KYZTPN52GK4S7MNWGSY3L#issuecomment-4106000739>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/A3ESMEC2HZX2H2NBIUWKWUL4R7BLPAVCNFSM6AAAAACW2SUGXSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHM2DCMBWGAYDANZTHE>.
You are receiving this because you authored the thread.
|
798bc48 to
da72401
Compare
Member
|
Could you add a test for this? |
Huliiiiii
approved these changes
Mar 22, 2026
sea-orm-sync/src/schema/builder.rs
Outdated
| } | ||
|
|
||
| let mut tables_by_schema = std::collections::HashMap::new(); | ||
| let mut all_enums = Vec::new(); |
Member
There was a problem hiding this comment.
Enums should be grouped by schema as well.
Member
|
I noticed that the changes in sea-orm-sync and sea-orm are not aligned. I've updated sea-orm-sync. Could you rebase onto master and make sure the changes are consistent between sea-orm and sea-orm-sync? |
Author
|
Good call, thanks — I'll add a regression test for this and update the PR soon. |
da72401 to
845aec0
Compare
845aec0 to
1e278de
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
PR Info
Closes entity sync does not work with postgres when tables have schemas defined #2952
Dependencies:
Dependents:
New Features
Bug Fixes
sync()only ranSchemaDiscoveryagainstCURRENT_SCHEMA()(typicallypublic). Entities with#[sea_orm(schema_name = "sys")]were never discovered, so every syncattempted
CREATE TABLEagain, failing withrelation "xxx" already exists. Root cause has two layers: (1) discovery was hardcoded to a single schema, (2) the table lookupcompared full
TableName(with schema qualifier) against discovered tables (without schema qualifier), so even if the table existed it could never match.Breaking Changes
schema_nameproduce the same single-schema discovery as before.Changes
schema_name: Option<String>field toEntitySchemaInfo, captured fromEntityName::schema_name()DiscoveredSchema.tables: Vec<TableCreateStatement>withtables_by_schema: HashMap<String, Vec<TableCreateStatement>>keyed by schema nameSchemaDiscovery::new_no_exec(schema)for each schema (Postgres & MySQL)DiscoveredSchema::find_table()for schema-aware table lookup — resolves entity's effective schema (explicit orcurrent_schemafallback), then compares bare tablenames within that bucket
sea-orm-syncviamake-sync.sh