Skip to content
Snippets Groups Projects
130f47ff65a4_rename_attribut_username_to_name.py 1.73 KiB
Newer Older
""" rename attribut username to name

Revision ID: 130f47ff65a4
Revises: 46ae534e284f
Create Date: 2025-02-27 15:08:43.767378
"""

from alembic import op
import sqlalchemy as sa
import hiboo


revision = "130f47ff65a4"
down_revision = "46ae534e284f"
branch_labels = None
depends_on = None


def upgrade():
    with op.batch_alter_table("user") as batch_op:
        batch_op.alter_column(
            "username",
            new_column_name="name",
            existing_type=sa.String(length=255),
            existing_nullable=False,
        )
    with op.batch_alter_table("profile") as batch_op:
        batch_op.alter_column(
            "username",
            new_column_name="name",
            existing_type=sa.String(length=255),
            existing_nullable=False,
        )
    with op.batch_alter_table("claimname") as batch_op:
        batch_op.alter_column(
            "username",
            new_column_name="name",
            existing_type=sa.String(length=255),
            existing_nullable=False,
        )


def downgrade():
    with op.batch_alter_table("user") as batch_op:
        batch_op.alter_column(
            "name",
            new_column_name="username",
            existing_type=sa.String(length=255),
            existing_nullable=False,
        )
    with op.batch_alter_table("profile") as batch_op:
        batch_op.alter_column(
            "name",
            new_column_name="username",
            existing_type=sa.String(length=255),
            existing_nullable=False,
        )
    with op.batch_alter_table("claimname") as batch_op:
        batch_op.alter_column(
            "name",
            new_column_name="username",
            existing_type=sa.String(length=255),
            existing_nullable=False,
        )