Fix migration when title is more than 30 chars

This commit is contained in:
rubenwardy 2024-06-24 20:14:15 +01:00
parent a134d21b79
commit 22172da57e

@ -20,7 +20,11 @@ def upgrade():
batch_op.add_column(sa.Column("name", sa.String(length=30), nullable=False, server_default="")) batch_op.add_column(sa.Column("name", sa.String(length=30), nullable=False, server_default=""))
batch_op.add_column(sa.Column("release_notes", sa.UnicodeText(), nullable=True)) batch_op.add_column(sa.Column("release_notes", sa.UnicodeText(), nullable=True))
batch_op.alter_column("releaseDate", nullable=False, new_column_name="created_at") batch_op.alter_column("releaseDate", nullable=False, new_column_name="created_at")
batch_op.execute("UPDATE pacakge_release SET name = title;") batch_op.execute("""
UPDATE package_release SET name = title WHERE length(title) <= 30;
UPDATE package_release SET name = TO_CHAR(created_at, 'YYYY-MM-DD') WHERE name = '';
""")
def downgrade(): def downgrade():