diff --git a/db_revisions/versions/26556a57a06f_create_a_baseline_migrations.py b/db_revisions/versions/26556a57a06f_create_a_baseline_migrations.py new file mode 100644 index 0000000..4001bc7 --- /dev/null +++ b/db_revisions/versions/26556a57a06f_create_a_baseline_migrations.py @@ -0,0 +1,59 @@ +"""Create a baseline migrations + +Revision ID: 26556a57a06f +Revises: +Create Date: 2023-10-23 04:04:07.722956 + +""" +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision: str = '26556a57a06f' +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: + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('denied_domains', + sa.Column('domain', sa.String(), nullable=False), + sa.Column('event_time', sa.DateTime(), server_default=sa.text('now()'), nullable=False), + sa.PrimaryKeyConstraint('domain') + ) + op.create_index(op.f('ix_denied_domains_domain'), 'denied_domains', ['domain'], unique=False) + op.create_table('financial_institutions', + sa.Column('lei', sa.String(), nullable=False), + sa.Column('name', sa.String(), nullable=False), + sa.Column('event_time', sa.DateTime(), server_default=sa.text('now()'), nullable=False), + sa.PrimaryKeyConstraint('lei') + ) + op.create_index(op.f('ix_financial_institutions_lei'), 'financial_institutions', ['lei'], unique=True) + op.create_index(op.f('ix_financial_institutions_name'), 'financial_institutions', ['name'], unique=False) + op.create_table('financial_institution_domains', + sa.Column('domain', sa.String(), nullable=False), + sa.Column('lei', sa.String(), nullable=False), + sa.Column('event_time', sa.DateTime(), server_default=sa.text('now()'), nullable=False), + sa.ForeignKeyConstraint(['lei'], ['public.financial_institutions.lei'], ), + sa.PrimaryKeyConstraint('domain', 'lei') + ) + op.create_index(op.f('ix_financial_institution_domains_domain'), 'financial_institution_domains', ['domain'], unique=False) + op.create_index(op.f('ix_financial_institution_domains_lei'), 'financial_institution_domains', ['lei'], unique=False) + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.drop_index(op.f('ix_financial_institution_domains_lei'), table_name='financial_institution_domains') + op.drop_index(op.f('ix_financial_institution_domains_domain'), table_name='financial_institution_domains') + op.drop_table('financial_institution_domains') + op.drop_index(op.f('ix_financial_institutions_name'), table_name='financial_institutions') + op.drop_index(op.f('ix_financial_institutions_lei'), table_name='financial_institutions') + op.drop_table('financial_institutions') + op.drop_index(op.f('ix_denied_domains_domain'), table_name='denied_domains') + op.drop_table('denied_domains') + # ### end Alembic commands ### \ No newline at end of file diff --git a/db_revisions/versions/5ef8007003c6_create_a_baseline_migrations.py b/db_revisions/versions/5ef8007003c6_create_a_baseline_migrations.py deleted file mode 100644 index 77c2bc0..0000000 --- a/db_revisions/versions/5ef8007003c6_create_a_baseline_migrations.py +++ /dev/null @@ -1,60 +0,0 @@ -"""Create a baseline migrations - -Revision ID: 5ef8007003c6 -Revises: -Create Date: 2023-10-22 02:43:08.751445 - -""" -from typing import Sequence, Union - -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision: str = "5ef8007003c6" -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: - op.create_table( - "denied_domains", - sa.Column("domain", sa.String(), nullable=False), - sa.Column("event_time", sa.DateTime(), server_default=sa.text("now()"), nullable=False), - sa.PrimaryKeyConstraint("domain"), - ) - op.create_index(op.f("ix_denied_domains_domain"), "denied_domains", ["domain"], unique=False) - op.create_table( - "financial_institutions", - sa.Column("lei", sa.String(), nullable=False), - sa.Column("name", sa.String(), nullable=False), - sa.Column("event_time", sa.DateTime(), server_default=sa.text("now()"), nullable=False), - sa.PrimaryKeyConstraint("lei"), - ) - op.create_index(op.f("ix_financial_institutions_lei"), "financial_institutions", ["lei"], unique=True) - op.create_index(op.f("ix_financial_institutions_name"), "financial_institutions", ["name"], unique=False) - op.create_table( - "financial_institution_domains", - sa.Column("domain", sa.String(), nullable=False), - sa.Column("lei", sa.String(), nullable=False), - sa.Column("event_time", sa.DateTime(), server_default=sa.text("now()"), nullable=False), - sa.ForeignKeyConstraint( - ["lei"], - ["public.financial_institutions.lei"], - ), - sa.PrimaryKeyConstraint("domain", "lei"), - ) - op.create_index( - op.f("ix_financial_institution_domains_domain"), "financial_institution_domains", ["domain"], unique=False - ) - op.create_index( - op.f("ix_financial_institution_domains_lei"), "financial_institution_domains", ["lei"], unique=False - ) - - -def downgrade() -> None: - op.drop_table("financial_institution_domains") - op.drop_table("financial_institutions") - op.drop_table("denied_domains") diff --git a/tests/test_migrations.py b/tests/test_migrations.py index 2db5882..5006479 100644 --- a/tests/test_migrations.py +++ b/tests/test_migrations.py @@ -1,6 +1,6 @@ from pytest_alembic.tests import ( - test_model_definitions_match_ddl, - test_single_head_revision, - test_up_down_consistency, - test_upgrade, + test_model_definitions_match_ddl, # noqa: F401 + test_single_head_revision, # noqa: F401 + test_up_down_consistency, # noqa: F401 + test_upgrade, # noqa: F401 )