From 22172da57e4d51eeee573e49e4c4246696880a33 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Mon, 24 Jun 2024 20:14:15 +0100 Subject: [PATCH] Fix migration when title is more than 30 chars --- migrations/versions/daa040b727b2_.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/migrations/versions/daa040b727b2_.py b/migrations/versions/daa040b727b2_.py index 50895dff..dfae9897 100644 --- a/migrations/versions/daa040b727b2_.py +++ b/migrations/versions/daa040b727b2_.py @@ -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("release_notes", sa.UnicodeText(), nullable=True)) 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():