Skip to content

Commit

Permalink
feat(IPVC-2280): add codon_table to transcript + migration
Browse files Browse the repository at this point in the history
  • Loading branch information
sptaylor committed Apr 8, 2024
1 parent 49e08e9 commit 74d1a22
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -342,3 +342,18 @@ Example:
```
sbin/uta-update $(pwd)/ncbi-data $(pwd)/seqrepo-data $(pwd)/uta-build uta_20210129b 2024-02-20
```

## Migrations
UTA uses alembic to manage database migrations. To auto-generate a migration:
```
alembic -c etc/alembic.ini revision --autogenerate -m "description of the migration"
```
This will create a migration script in the alembic/versions directory.
Adjust the upgrade and downgrade function definitions. To apply the migration:
```
alembic -c etc/alembic.ini upgrade head
```
To reverse a migration, use `downgrade` with the number of steps to reverse. For example, to reverse the last:
```
alembic -c etc/alembic.ini downgrade -1
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""Added codon_table to Transcript
Revision ID: a697b584f699
Revises: cc51f50ae896
Create Date: 2024-04-08 17:27:41.570024
"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = 'a697b584f699'
down_revision: Union[str, None] = 'cc51f50ae896'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('transcript', sa.Column('codon_table', sa.Integer(), server_default='1', nullable=False), schema='uta')
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('transcript', 'codon_table', schema='uta')
# ### end Alembic commands ###
1 change: 1 addition & 0 deletions src/uta/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ class Transcript(Base):
cds_md5 = sa.Column(sa.Text, index=True)
added = sa.Column(
sa.DateTime, default=datetime.datetime.now(), nullable=False)
codon_table = sa.Column(sa.Integer, nullable=False, server_default='1') # 1 = standard, 2 = mitochondrial

# relationships:
origin = sao.relationship("Origin", backref="transcripts")
Expand Down

0 comments on commit 74d1a22

Please sign in to comment.