diff --git a/alembic/versions/a6e4562797e4_add_new_uploaded_file_table.py b/alembic/versions/a6e4562797e4_add_new_uploaded_file_table.py new file mode 100644 index 0000000..4693808 --- /dev/null +++ b/alembic/versions/a6e4562797e4_add_new_uploaded_file_table.py @@ -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 ### diff --git a/etl/models/topLevel.py b/etl/models/topLevel.py index 94ad7e9..45f13ef 100644 --- a/etl/models/topLevel.py +++ b/etl/models/topLevel.py @@ -63,5 +63,5 @@ class uploaded_files(BaseModel, table=True): # UPRN uprn: str = Field(index=True) -Documents.update_forward_refs() +# Documents.update_forward_refs() diff --git a/migration_db.sh b/migration_db.sh index 6538789..e6fd4a6 100644 --- a/migration_db.sh +++ b/migration_db.sh @@ -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