refactor: Encapsulate enum creation logic within a dedicated function in the upgrade process for improved readability and maintainability #36

Merged
mo merged 1 commits from ph4 into prod 2025-06-01 18:15:41 +02:00

View File

@ -26,6 +26,7 @@ chore_frequency_enum = postgresql.ENUM('one_time', 'daily', 'weekly', 'monthly',
chore_type_enum = postgresql.ENUM('personal', 'group', name='choretypeenum', create_type=False) chore_type_enum = postgresql.ENUM('personal', 'group', name='choretypeenum', create_type=False)
def upgrade(context) -> None: def upgrade(context) -> None:
def create_enums():
user_role_enum.create(op.get_bind(), checkfirst=True) user_role_enum.create(op.get_bind(), checkfirst=True)
split_type_enum.create(op.get_bind(), checkfirst=True) split_type_enum.create(op.get_bind(), checkfirst=True)
expense_split_status_enum.create(op.get_bind(), checkfirst=True) expense_split_status_enum.create(op.get_bind(), checkfirst=True)
@ -34,6 +35,8 @@ def upgrade(context) -> None:
chore_frequency_enum.create(op.get_bind(), checkfirst=True) chore_frequency_enum.create(op.get_bind(), checkfirst=True)
chore_type_enum.create(op.get_bind(), checkfirst=True) chore_type_enum.create(op.get_bind(), checkfirst=True)
create_enums()
op.create_table('users', op.create_table('users',
sa.Column('id', sa.Integer(), nullable=False), sa.Column('id', sa.Integer(), nullable=False),
sa.Column('email', sa.String(), nullable=False), sa.Column('email', sa.String(), nullable=False),