From f2903dbdcb74b737c7ba0dc3f22e732e8a45eaf3 Mon Sep 17 00:00:00 2001 From: Nargis Sultani Date: Thu, 19 Oct 2023 09:54:44 -0400 Subject: [PATCH] Inserted data into tables --- ...7dcc6128bc_create_a_baseline_migrations.py | 53 ++++++++++++------- 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/db_revisions/versions/ed7dcc6128bc_create_a_baseline_migrations.py b/db_revisions/versions/ed7dcc6128bc_create_a_baseline_migrations.py index 0da9248..67d75ae 100644 --- a/db_revisions/versions/ed7dcc6128bc_create_a_baseline_migrations.py +++ b/db_revisions/versions/ed7dcc6128bc_create_a_baseline_migrations.py @@ -20,29 +20,46 @@ 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(timezone=True), server_default=sa.text('now()'), nullable=True), - sa.PrimaryKeyConstraint('domain', name='denied_domains_pkey') - ) + denied_domains = op.create_table('denied_domains', + sa.Column('domain', sa.String(), nullable=False), + sa.Column('event_time', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True), + sa.PrimaryKeyConstraint('domain', name='denied_domains_pkey') + ) op.create_index('ix_denied_domains_domain', 'denied_domains', ['domain'], unique=True) - 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(timezone=True), server_default=sa.text('now()'), nullable=True), - sa.PrimaryKeyConstraint('lei', name='financial_institutions_pkey') - ) + op.bulk_insert(denied_domains, + [{'domain': 'gmail.com'}, + {'domain': 'yahoo.com'}, + {'domain': 'aol.com'} + ]) + + financial_institutions = 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(timezone=True), server_default=sa.text('now()'), nullable=True), + sa.PrimaryKeyConstraint('lei', name='financial_institutions_pkey') + ) op.create_index('ix_financial_institutions_lei', 'financial_institutions', ['lei'], unique=True) op.create_index('ix_financial_institutions_name', 'financial_institutions', ['name'], unique=False) - op.create_table('financial_institutions_domains', - sa.Column('domain', sa.String(), nullable=False), - sa.Column('lei', sa.String(), nullable=False), - sa.Column('event_time', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True), - sa.ForeignKeyConstraint(['lei'], ['financial_institutions.lei'], ), - sa.PrimaryKeyConstraint('domain', 'lei', name='financial_institution_domains_pkey') - ) + op.bulk_insert(financial_institutions, + [{'lei': 'TEST1LEI','name': 'Test 1'}, + {'lei': 'TEST2LEI','name': 'Test 2'}, + {'lei': 'TEST3LEI','name': 'Test 3'} + ]) + + financial_institutions_domains = op.create_table('financial_institutions_domains', + sa.Column('domain', sa.String(), nullable=False), + sa.Column('lei', sa.String(), nullable=False), + sa.Column('event_time', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True), + sa.ForeignKeyConstraint(['lei'], ['financial_institutions.lei'], ), + sa.PrimaryKeyConstraint('domain', 'lei', name='financial_institution_domains_pkey') + ) op.create_index('ix_financial_institution_domains_domain', 'financial_institutions_domains', ['domain'], unique=False) op.create_index('ix_financial_institution_domains_lei', 'financial_institutions_domains', ['lei'], unique=False) + op.bulk_insert(financial_institutions_domains, + [{'domain': 'test1.local', 'lei': 'TEST1LEI'}, + {'domain': 'test2.local', 'lei': 'TEST2LEI'}, + {'domain': 'test3.local', 'lei': 'TEST3LEI'} + ]) # ### end Alembic commands ###