Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hotfix: Provide default value to organization_name field in FSE on creation #1447

Merged
merged 2 commits into from
Dec 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,33 @@
Create Date: 2024-12-04 09:59:22.876386

"""

from alembic import op
import sqlalchemy as sa

# revision identifiers, used by Alembic.
revision = '9206124a098b'
down_revision = '26ab15f8ab18'
revision = "9206124a098b"
down_revision = "26ab15f8ab18"
branch_labels = None
depends_on = None


def upgrade():
# Add the column 'organization_name' to 'final_supply_equipment' table
op.add_column("final_supply_equipment", sa.Column("organization_name", sa.String(), nullable=True))
# Add the column 'organization_name' to 'final_supply_equipment' table with a default value
op.add_column(
"final_supply_equipment",
sa.Column("organization_name", sa.String(), nullable=False, server_default=""),
)

# Update existing rows to have the default value
op.execute(
"UPDATE final_supply_equipment SET organization_name = '' WHERE organization_name IS NULL"
)

# Remove the server default to prevent future rows from automatically getting the default value
op.alter_column("final_supply_equipment", "organization_name", server_default=None)


def downgrade():
# Remove the column 'organization_name' from 'final_supply_equipment' table
op.drop_column("final_supply_equipment", "organization_name")
op.drop_column("final_supply_equipment", "organization_name")
Loading