updated migration script

This commit is contained in:
Jun-te Kim 2025-08-14 14:45:12 +00:00
parent 03c03d79ca
commit afb7b92d17
3 changed files with 49 additions and 4 deletions

View file

@ -0,0 +1,45 @@
"""add new uploaded file table
Revision ID: a6e4562797e4
Revises:
Create Date: 2025-08-14 14:44:40.992608
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = 'a6e4562797e4'
down_revision: Union[str, None] = None
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('uploaded_files',
sa.Column('id', sa.Uuid(), nullable=False),
sa.Column('s3_json_uri', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
sa.Column('s3_file_uri', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('doc_type', sa.Enum('QUIDOS_PRESITE_NOTE', 'CHARTED_SURVEYOR_REPORT', 'U_VALUE_CALCULATOR_REPORT', 'OVERWRITING_U_VALUE_DECLARATION_FORM', 'ECO_CONDITION_REPORT', 'WARM_HOMES_CONDITION_REPORT', 'ENERGY_PERFORMANCE_REPORT_WITH_DATA', 'ENERGY_PERFORMANCE_REPORT_SUMMARY_INFORMATION', 'LIG_XML', 'RDSAP_XML', 'FULLSAP_XML', name='reporttype'), nullable=False),
sa.Column('s3_file_upload_timestamp', sa.DateTime(), nullable=False),
sa.Column('s3_json_upload_timestamp', sa.DateTime(), nullable=True),
sa.Column('uprn', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_uploaded_files_s3_file_uri'), 'uploaded_files', ['s3_file_uri'], unique=False)
op.create_index(op.f('ix_uploaded_files_uprn'), 'uploaded_files', ['uprn'], unique=False)
# ### end Alembic commands ###
def downgrade() -> None:
"""Downgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f('ix_uploaded_files_uprn'), table_name='uploaded_files')
op.drop_index(op.f('ix_uploaded_files_s3_file_uri'), table_name='uploaded_files')
op.drop_table('uploaded_files')
# ### end Alembic commands ###

View file

@ -63,5 +63,5 @@ class uploaded_files(BaseModel, table=True):
# UPRN
uprn: str = Field(index=True)
Documents.update_forward_refs()
# Documents.update_forward_refs()

View file

@ -1,9 +1,9 @@
#poetry run alembic revision --autogenerate -m "add new uploaded file table"
#poetry run alembic revision --autogenerate -m "add new uploaded file table "
poetry run alembic upgrade head
#poetry run alembic upgrade head
# See which hash I'm at
#poetry run alembic current
poetry run alembic current
# downgrade one version
#poetry run alembic upgrade head