Skip to content

Commit

Permalink
DESENG-452: Inserted initial data for Staff user table
Browse files Browse the repository at this point in the history
  • Loading branch information
ratheesh-aot committed Feb 10, 2024
1 parent 70285d3 commit 95666f1
Showing 1 changed file with 72 additions and 35 deletions.
107 changes: 72 additions & 35 deletions met-api/migrations/versions/37176ea4708d_data_until_feb_09_2024.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

def upgrade():
# ### commands auto generated by Alembic - please adjust! ###

# Set tenant id as 1
tenant_id = 1 # ID of the default Tenant

# Create an ad-hoc table for 'tenant'
tenant_table = table(
Expand Down Expand Up @@ -52,6 +55,74 @@ def upgrade():

# Perform bulk insert
op.bulk_insert(tenant_table, tenant_data)

# Create an ad-hoc table for 'user_status'
user_status_table = table(
'user_status',
column('id', Integer),
column('created_date', DateTime),
column('updated_date', DateTime),
column('status_name', String(50)),
column('description', String(50)),
column('created_by', String(50)),
column('updated_by', String(50)),
)

# Data for bulk insert
user_status_data = [
{
'id': 1,
'status_name': 'ACTIVE',
'description': 'Active User',
'created_date': datetime.utcnow(),
'updated_date': datetime.utcnow(),
},
{
'id': 2,
'status_name': 'INACTIVE',
'description': 'Inactive User',
'created_date': datetime.utcnow(),
'updated_date': datetime.utcnow(),
},
]

# Perform bulk insert
op.bulk_insert(user_status_table, user_status_data)

# Create an ad-hoc table for 'staff_users'
staff_users_table = table(
'staff_users',
column('id', Integer),
column('created_date', DateTime),
column('updated_date', DateTime),
column('first_name', String(50)),
column('middle_name', String(50)),
column('last_name', String(50)),
column('username', String(100)),
column('email_address', String(100)),
column('contact_number', String(50)),
column('external_id', String(50)),
column('status_id', Integer),
column('tenant_id', Integer),
column('created_by', String(50)),
column('updated_by', String(50))
)

# Sample data for insertion
sample_data = {
'first_name': 'MET',
'middle_name': '',
'last_name': 'System',
'external_id': '1', # Replace with actual external_id value
'status_id': 1,
'contact_number': '1',
'tenant_id': tenant_id,
'created_date': datetime.utcnow(),
'updated_date': datetime.utcnow(),
}

# Perform insert with sample data
op.bulk_insert(staff_users_table, [sample_data])

# Create an ad-hoc table for 'widget_type'
widget_type_table = table(
Expand Down Expand Up @@ -144,8 +215,7 @@ def upgrade():
column('updated_by', String(50)),
)

# Prepare Tenant data for bulk insert
tenant_id = 1 # ID of the default Tenant


# Data to be inserted
taxa_data = [
Expand Down Expand Up @@ -232,39 +302,6 @@ def upgrade():
# Perform bulk insert
op.bulk_insert(engagement_metadata_taxa_table, taxa_data)

# Create an ad-hoc table for 'user_status'
user_status_table = table(
'user_status',
column('id', Integer),
column('created_date', DateTime),
column('updated_date', DateTime),
column('status_name', String(50)),
column('description', String(50)),
column('created_by', String(50)),
column('updated_by', String(50)),
)

# Data for bulk insert
user_status_data = [
{
'id': 1,
'status_name': 'ACTIVE',
'description': 'Active User',
'created_date': datetime.utcnow(),
'updated_date': datetime.utcnow(),
},
{
'id': 2,
'status_name': 'INACTIVE',
'description': 'Inactive User',
'created_date': datetime.utcnow(),
'updated_date': datetime.utcnow(),
},
]

# Perform bulk insert
op.bulk_insert(user_status_table, user_status_data)

# Create an ad-hoc table for 'generated_document_type'
generated_document_type_table = table(
'generated_document_type',
Expand Down

0 comments on commit 95666f1

Please sign in to comment.