Skip to content

Commit

Permalink
migration
Browse files Browse the repository at this point in the history
  • Loading branch information
pcrespov committed Dec 10, 2024
1 parent 63aefa7 commit b50842b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""set privacy_hide_email to false temporarily
Revision ID: 5e27063c3ac9
Revises: 4d007819e61a
Create Date: 2024-12-10 15:50:48.024204+00:00
"""
from alembic import op
from sqlalchemy.sql import expression

# revision identifiers, used by Alembic.
revision = "5e27063c3ac9"
down_revision = "4d007819e61a"
branch_labels = None
depends_on = None


def upgrade():
# Change the server_default of privacy_hide_email to false
with op.batch_alter_table("users") as batch_op:
batch_op.alter_column("privacy_hide_email", server_default=expression.false())

# Reset all to default: Update existing values in the database
op.execute("UPDATE users SET privacy_hide_email = false")


def downgrade():

# Revert the server_default of privacy_hide_email to true
with op.batch_alter_table("users") as batch_op:
batch_op.alter_column("privacy_hide_email", server_default=expression.true())

# Reset all to default: Revert existing values in the database to true
op.execute("UPDATE users SET privacy_hide_email = true")
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class UserStatus(str, Enum):
"privacy_hide_email",
sa.Boolean,
nullable=False,
server_default=expression.true(),
server_default=expression.false(),
doc="If true, it hides users.email to others",
),
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ async def get_associated_group(
user_id: UserID,
group_id: GroupID,
) -> tuple[Group, AccessRightsDict]:
"""
"""NOTE: here it can also be a non-standard group
raises GroupNotFoundError
raises UserInsufficientRightsError: needs READ access
Expand Down

0 comments on commit b50842b

Please sign in to comment.