Skip to content

Commit 33fa729

Browse files
committed
Update alembic script to set new identifiers for knowledge assets
1 parent bf0cbe8 commit 33fa729

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

alembic/alembic/versions/42f747800456_knowledge_asset_identifiers.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,11 @@ def upgrade() -> None:
7676
f"ON UPDATE CASCADE;"
7777
)
7878

79-
logger.info(f"Assigning new identifiers to knowledge_asset so they match the publication.")
80-
op.execute(
81-
f"UPDATE knowledge_asset "
82-
f"JOIN (select identifier, knowledge_asset_id from publication) as pubs "
83-
f"ON knowledge_asset.identifier=pubs.knowledge_asset_id "
84-
f"SET knowledge_asset.identifier=pubs.identifier;"
85-
)
79+
# There was a bug which resulted in knowledge asset identifiers not being generated
80+
logger.info("Creating Identifiers of Knowledge Assets")
81+
op.execute("INSERT INTO knowledge_asset SELECT identifier, 'publication' FROM publication; ")
82+
logger.info("Link publications to their parents")
83+
op.execute("UPDATE publication SET knowledge_asset_id=identifier; ")
8684

8785

8886
def downgrade() -> None:

0 commit comments

Comments
 (0)