-
Notifications
You must be signed in to change notification settings - Fork 1
consolidate-backfill-transfers #371
New issue
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,6 +50,18 @@ def upgrade() -> None: | |
| ondelete="CASCADE", | ||
| ) | ||
|
|
||
| # Ensure SamplePtID is uniquely constrained for downstream FK usage. | ||
| pk = inspector.get_pk_constraint("NMA_Chemistry_SampleInfo") | ||
| pk_columns = pk.get("constrained_columns") or [] | ||
| unique_constraints = inspector.get_unique_constraints("NMA_Chemistry_SampleInfo") | ||
| unique_columns = {tuple(uc.get("column_names") or []) for uc in unique_constraints} | ||
| if pk_columns != ["SamplePtID"] and ("SamplePtID",) not in unique_columns: | ||
| op.create_unique_constraint( | ||
| "NMA_Chemistry_SampleInfo_SamplePtID_key", | ||
| "NMA_Chemistry_SampleInfo", | ||
| ["SamplePtID"], | ||
|
Comment on lines
+58
to
+62
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The upgrade adds a new unique constraint on Useful? React with 👍 / 👎. |
||
| ) | ||
|
|
||
| # Create NMA_MinorTraceChemistry table | ||
| op.create_table( | ||
| "NMA_MinorTraceChemistry", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The primary key check uses exact equality (
pk_columns != ['SamplePtID']) which will fail ifSamplePtIDis part of a composite primary key. The condition should check ifSamplePtIDis in the primary key columns using'SamplePtID' not in pk_columnsinstead ofpk_columns != ['SamplePtID'].