Skip to content
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

feat: clean tables and rename table/schema #151

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/alembic/versions/730f5251b9dd_tables_clean_and_rename.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""tables_clean_and_rename

Revision ID: 730f5251b9dd
Revises: 4e912be8a176
Create Date: 2024-04-05 15:00:40.225950

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '730f5251b9dd'
down_revision = '4e912be8a176'
branch_labels = None
depends_on = None


def upgrade() -> None:
op.rename_table('spire_ais_data', 'stg_spire_ais_data')
# rename mpa_fr_with_mn with drop to manually drop it
op.rename_table('mpa_fr_with_mn', 'drop_mpa_fr_with_mn')
pass


def downgrade() -> None:
# nothing to do if drop_mpa_fr_with_mn has been manually dropped
op.execute('ALTER TABLE IF EXISTS drop_mpa_fr_with_mn RENAME TO mpa_fr_with_mn')
op.rename_table('stg_spire_ais_data', 'spire_ais_data')
pass
2 changes: 1 addition & 1 deletion src/bloom/infra/database/sql_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class Port(Base):


class SpireAisData(Base):
__tablename__ = "spire_ais_data"
__tablename__ = "stg_spire_ais_data"

id = Column("id", Integer, primary_key=True)
spire_update_statement = Column("spire_update_statement", DateTime(timezone=True))
Expand Down
Loading