Skip to content

Commit

Permalink
feat(IPVC-2323): update data type for assocacs added field
Browse files Browse the repository at this point in the history
  • Loading branch information
bsgiles73 committed Apr 5, 2024
1 parent c3f6484 commit bc609ef
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
"""add sqlalchemy model for assocacs
Revision ID: cc51f50ae896
Revises: edadb97f6502
Create Date: 2024-04-05 00:33:40.105587
"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = 'cc51f50ae896'
down_revision: Union[str, None] = 'edadb97f6502'
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.alter_column('associated_accessions', 'tx_ac',
existing_type=sa.TEXT(),
nullable=False,
schema='uta')
op.alter_column('associated_accessions', 'pro_ac',
existing_type=sa.TEXT(),
nullable=False,
schema='uta')
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('associated_accessions', 'pro_ac',
existing_type=sa.TEXT(),
nullable=True,
schema='uta')
op.alter_column('associated_accessions', 'tx_ac',
existing_type=sa.TEXT(),
nullable=True,
schema='uta')
# ### end Alembic commands ###
3 changes: 2 additions & 1 deletion src/alembic/versions/edadb97f6502_initial_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql


# revision identifiers, used by Alembic.
Expand Down Expand Up @@ -134,7 +135,7 @@ def upgrade() -> None:
sa.Column('tx_ac', sa.Text(), nullable=True),
sa.Column('pro_ac', sa.Text(), nullable=True),
sa.Column('origin', sa.Text(), nullable=False),
sa.Column('added', sa.TIMESTAMP(), server_default=sa.text('now()'), nullable=False),
sa.Column('added', postgresql.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
sa.PrimaryKeyConstraint('associated_accession_id'),
schema='uta'
)
Expand Down
3 changes: 2 additions & 1 deletion src/uta/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import sqlalchemy.types
import sqlalchemy.sql.functions
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.dialects import postgresql


############################################################################
Expand Down Expand Up @@ -235,7 +236,7 @@ class AssociatedAccessions(Base):
pro_ac = sa.Column(sa.Text, nullable=False)
origin = sa.Column(sa.Text, nullable=False)
added = sa.Column(
sqlalchemy.types.TIMESTAMP,
postgresql.TIMESTAMP(timezone=True),
server_default=sqlalchemy.sql.functions.now(),
nullable=False,
)
Expand Down

0 comments on commit bc609ef

Please sign in to comment.