Skip to content

Commit 00a4f25

Browse files
authored
fix database upgrade of data (ITISFoundation#3167)
1 parent e31fd4e commit 00a4f25

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

packages/postgres-database/src/simcore_postgres_database/migration/versions/2cc556e5c52d_file_meta_data_remove_unused_columns_.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616

1717

1818
def upgrade():
19+
# copy entries in file_uuid to file_id
20+
conn = op.get_bind()
21+
conn.execute(sa.DDL("UPDATE file_meta_data SET file_id = file_uuid"))
22+
1923
# ### commands auto generated by Alembic - please adjust! ###
2024
op.add_column(
2125
"file_meta_data", sa.Column("upload_expires_at", sa.DateTime(), nullable=True)
@@ -73,15 +77,5 @@ def downgrade():
7377
op.drop_column("file_meta_data", "upload_expires_at")
7478
# ### end Alembic commands ###
7579
conn = op.get_bind()
76-
for row in conn.execute(sa.DDL("SELECT file_id FROM file_meta_data")):
77-
file_id = row["file_id"]
78-
conn.execute(
79-
sa.DDL(
80-
f"""
81-
UPDATE file_meta_data
82-
SET file_uuid = '{file_id}'
83-
WHERE file_id = '{file_id}'
84-
"""
85-
)
86-
)
80+
conn.execute(sa.DDL("UPDATE file_meta_data SET file_uuid = file_id"))
8781
op.create_primary_key("pk_file_meta_data", "file_meta_data", ["file_uuid"])

0 commit comments

Comments
 (0)