Skip to content

Commit

Permalink
fill empty widget title (#1970)
Browse files Browse the repository at this point in the history
* fill empty widget title

* update names
  • Loading branch information
jadmsaadaot authored Aug 4, 2023
1 parent c4b004f commit d8c482b
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions met-api/migrations/versions/db737a0db061_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
""" Fill empty widget titles
Revision ID: db737a0db061
Revises: df73727dc6d9b7_add_sub_tbl
Create Date: 2023-08-04 14:11:01.993136
"""

from alembic import op

# revision identifiers, used by Alembic.
revision = 'db737a0db061'
down_revision = 'df73727dc6d9b7_add_sub_tbl'
branch_labels = None
depends_on = None

def upgrade():
# ### commands auto generated by Alembic - please adjust! ###

# Execute an UPDATE statement to set 'title' based on 'widget_type_id'
op.execute("""
UPDATE widget
SET title =
CASE
WHEN widget_type_id = 1 THEN 'Who is Listening'
WHEN widget_type_id = 2 THEN 'Documents'
WHEN widget_type_id = 3 THEN 'Environmental Assessment Process'
WHEN widget_type_id = 4 THEN 'Sign Up for Updates'
WHEN widget_type_id = 5 THEN 'Events'
WHEN widget_type_id = 6 THEN 'Map'
WHEN widget_type_id = 7 THEN 'Video'
ELSE 'Default Title' -- This is for any widget_type_id not covered above
END
WHERE title IS NULL;
""")

# ### end Alembic commands ###

def downgrade():
# ### commands auto generated by Alembic - please adjust! ###

# Execute an UPDATE statement to set 'title' to NULL for all rows
op.execute("UPDATE widget SET title = NULL;")

# ### end Alembic commands ###

0 comments on commit d8c482b

Please sign in to comment.