Skip to content
Snippets Groups Projects

fix: KeyError at profile creation

Merged f00wl requested to merge 145-keyerror-a-la-creation-d-un-nouveau-profile into dev
1 file
+ 46
0
Compare changes
  • Side-by-side
  • Inline
""" update and set empty service.profile_format to server_default 'lowercase'
Revision ID: 0147b747696e
Revises: f9130c1a10f7
Create Date: 2024-09-30 18:10:42.200989
"""
from alembic import op
import sqlalchemy as sa
import hiboo
revision = "0147b747696e"
down_revision = "f9130c1a10f7"
branch_labels = None
depends_on = None
service_table = sa.Table(
"service", sa.MetaData(), sa.Column("profile_format", sa.String(length=255))
)
def upgrade():
with op.batch_alter_table("service") as batch_op:
batch_op.alter_column(
"profile_format",
existing_type=sa.String(length=255),
server_default="lowercase",
nullable=False,
)
connection = op.get_bind()
connection.execute(
service_table.update()
.where(service_table.c.profile_format == "")
.values(profile_format="lowercase")
)
def downgrade():
with op.batch_alter_table("service") as batch_op:
batch_op.alter_column(
"profile_format",
existing_type=sa.String(length=255),
server_default=None,
nullable=True,
)
Loading