-
Notifications
You must be signed in to change notification settings - Fork 0
SQ-845: Normalize the dimensions table to sample and scaffold FK tables #70
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
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
c2a1349
Normalize dimensions model for samples & scaffolds
brinkdp 0e5064e
Update API CRUD for dimensions model
brinkdp 3b3e54f
Add migrations for the normalized dimensions model
brinkdp 74c74b7
Reimplement CRUD & routes from 9c7baec, d366456
brinkdp 7f69e0c
Reimplement tasks.py log from tsv branch
brinkdp 4794fd3
Reimplement dimensions show CLI as of other branch
brinkdp 0768cf3
Reimplement tests for refactored dimensions code
brinkdp cc8e1eb
Update mock VCF and metadata scripts
brinkdp c50135a
Add fallback re-indexing on incomplete dimensions
brinkdp dbc6393
Improve dimensions show UX command for samples
brinkdp a876c46
Apply suggestions from code review
brinkdp b4d8c2a
Fix typos found by copilot review
brinkdp 1ce6e4d
Add re-indexing test suggested by copilot review
brinkdp 178928d
Use selectinload also work worker CRUD
brinkdp d60c13f
Add sample and scaffold model to model init
brinkdp f2b793f
Drop duplicate datestamp from migration filename¨
brinkdp 4d9d84b
Fix misleading return type annotation
brinkdp b6b1179
Change logger level for stale VCFs to warning
brinkdp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
83 changes: 83 additions & 0 deletions
83
.../divbase-api/src/divbase_api/migrations/versions/2026-02-20_normalize_dimensions_model.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| """2026-02-20_normalize_dimensions_model | ||
|
|
||
| Revision ID: bde261f949a1 | ||
| Revises: faa3d0318fda | ||
| Create Date: 2026-02-20 10:03:40.815406 | ||
|
|
||
| """ | ||
|
|
||
| from typing import Sequence, Union | ||
|
|
||
| import sqlalchemy as sa | ||
| from alembic import op | ||
| from sqlalchemy.dialects import postgresql | ||
|
|
||
| # revision identifiers, used by Alembic. | ||
| revision: str = "bde261f949a1" | ||
| down_revision: Union[str, Sequence[str], None] = "faa3d0318fda" | ||
| branch_labels: Union[str, Sequence[str], None] = None | ||
| depends_on: Union[str, Sequence[str], None] = None | ||
|
|
||
|
|
||
| def upgrade() -> None: | ||
| """Upgrade schema.""" | ||
| # ### commands auto generated by Alembic - please adjust! ### | ||
| op.create_table( | ||
| "vcf_metadata_samples", | ||
| sa.Column("vcf_metadata_id", sa.Integer(), nullable=False), | ||
| sa.Column("sample_name", sa.String(), nullable=False), | ||
| sa.Column("id", sa.Integer(), autoincrement=True, nullable=False), | ||
| sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False), | ||
| sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False), | ||
| sa.ForeignKeyConstraint(["vcf_metadata_id"], ["vcf_metadata.id"], ondelete="CASCADE"), | ||
| sa.PrimaryKeyConstraint("id"), | ||
| ) | ||
| op.create_index(op.f("ix_vcf_metadata_samples_id"), "vcf_metadata_samples", ["id"], unique=False) | ||
| op.create_index(op.f("ix_vcf_metadata_samples_sample_name"), "vcf_metadata_samples", ["sample_name"], unique=False) | ||
| op.create_index( | ||
| op.f("ix_vcf_metadata_samples_vcf_metadata_id"), "vcf_metadata_samples", ["vcf_metadata_id"], unique=False | ||
| ) | ||
| op.create_table( | ||
| "vcf_metadata_scaffolds", | ||
| sa.Column("vcf_metadata_id", sa.Integer(), nullable=False), | ||
| sa.Column("scaffold_name", sa.String(), nullable=False), | ||
| sa.Column("id", sa.Integer(), autoincrement=True, nullable=False), | ||
| sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False), | ||
| sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False), | ||
| sa.ForeignKeyConstraint(["vcf_metadata_id"], ["vcf_metadata.id"], ondelete="CASCADE"), | ||
| sa.PrimaryKeyConstraint("id"), | ||
| ) | ||
| op.create_index(op.f("ix_vcf_metadata_scaffolds_id"), "vcf_metadata_scaffolds", ["id"], unique=False) | ||
| op.create_index( | ||
| op.f("ix_vcf_metadata_scaffolds_scaffold_name"), "vcf_metadata_scaffolds", ["scaffold_name"], unique=False | ||
| ) | ||
| op.create_index( | ||
| op.f("ix_vcf_metadata_scaffolds_vcf_metadata_id"), "vcf_metadata_scaffolds", ["vcf_metadata_id"], unique=False | ||
| ) | ||
| op.drop_index(op.f("ix_vcf_metadata_samples"), table_name="vcf_metadata") | ||
| op.drop_column( | ||
| "vcf_metadata", "scaffolds" | ||
| ) # NOTE! this drops previous data stored in the array column. The migration does not repopulate the FK tables. Run divbase-cli dimensions update instead | ||
| op.drop_column("vcf_metadata", "samples") # NOTE! same here, run divbase-cli dimensions update instead | ||
| # ### end Alembic commands ### | ||
|
|
||
|
|
||
| def downgrade() -> None: | ||
| """Downgrade schema.""" | ||
| # ### commands auto generated by Alembic - please adjust! ### | ||
| op.add_column( | ||
| "vcf_metadata", sa.Column("samples", postgresql.ARRAY(sa.VARCHAR()), autoincrement=False, nullable=False) | ||
| ) | ||
| op.add_column( | ||
| "vcf_metadata", sa.Column("scaffolds", postgresql.ARRAY(sa.VARCHAR()), autoincrement=False, nullable=False) | ||
| ) | ||
| op.create_index(op.f("ix_vcf_metadata_samples"), "vcf_metadata", ["samples"], unique=False) | ||
| op.drop_index(op.f("ix_vcf_metadata_scaffolds_vcf_metadata_id"), table_name="vcf_metadata_scaffolds") | ||
| op.drop_index(op.f("ix_vcf_metadata_scaffolds_scaffold_name"), table_name="vcf_metadata_scaffolds") | ||
| op.drop_index(op.f("ix_vcf_metadata_scaffolds_id"), table_name="vcf_metadata_scaffolds") | ||
| op.drop_table("vcf_metadata_scaffolds") | ||
| op.drop_index(op.f("ix_vcf_metadata_samples_vcf_metadata_id"), table_name="vcf_metadata_samples") | ||
| op.drop_index(op.f("ix_vcf_metadata_samples_sample_name"), table_name="vcf_metadata_samples") | ||
| op.drop_index(op.f("ix_vcf_metadata_samples_id"), table_name="vcf_metadata_samples") | ||
| op.drop_table("vcf_metadata_samples") | ||
| # ### end Alembic commands ### |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,4 +29,6 @@ | |
| "ProjectVersionDB", | ||
| "AnnouncementDB", | ||
| "AnnouncementTarget", | ||
| "VCFMetadataSamplesDB", | ||
| "VCFMetadataScaffoldsDB", | ||
| ] | ||
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.