Skip to content

Commit

Permalink
Inserted data into tables
Browse files Browse the repository at this point in the history
  • Loading branch information
Nargis Sultani committed Oct 19, 2023
1 parent 00dfe44 commit f2903db
Showing 1 changed file with 35 additions and 18 deletions.
53 changes: 35 additions & 18 deletions db_revisions/versions/ed7dcc6128bc_create_a_baseline_migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ###


Expand Down

0 comments on commit f2903db

Please sign in to comment.