Coverage for opt/mealie/lib/python3.12/site-packages/mealie/alembic/versions/2023-02-22-21.45.52_38514b39a824_add_auth_method_to_user_table.py: 65%
19 statements
« prev ^ index » next coverage.py v7.10.6, created at 2025-12-05 13:45 +0000
« prev ^ index » next coverage.py v7.10.6, created at 2025-12-05 13:45 +0000
1"""add auth_method to user table
3Revision ID: 38514b39a824
4Revises: b04a08da2108
5Create Date: 2023-02-22 21:45:52.900964
7"""
9import sqlalchemy as sa 1a
11from alembic import op 1a
13# revision identifiers, used by Alembic.
14revision = "38514b39a824" 1a
15down_revision = "b04a08da2108" 1a
16branch_labels: str | tuple[str, ...] | None = None 1a
17depends_on: str | tuple[str, ...] | None = None 1a
20def is_postgres(): 1a
21 return op.get_context().dialect.name == "postgresql" 1a
24authMethod = sa.Enum("MEALIE", "LDAP", name="authmethod") 1a
27def upgrade(): 1a
28 if is_postgres(): 28 ↛ 29line 28 didn't jump to line 29 because the condition on line 28 was never true1a
29 authMethod.create(op.get_bind())
31 op.add_column( 1a
32 "users",
33 sa.Column("auth_method", authMethod, nullable=False, server_default="MEALIE"),
34 )
35 op.execute("UPDATE users SET auth_method = 'LDAP' WHERE password = 'LDAP'") 1a
38def downgrade(): 1a
39 with op.batch_alter_table("users", schema=None) as batch_op:
40 batch_op.drop_column("auth_method")
42 if is_postgres():
43 authMethod.drop(op.get_bind())