Skip to content

Commit

Permalink
Scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
RickiJay-WMDE committed Oct 30, 2024
1 parent df0e672 commit 87a1759
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions alembic/versions/0833cb54870f_software_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ def upgrade() -> None:
batch_op.create_foreign_key(
"software", "wikibase_software", ["wikibase_software_id"], ["id"]
)
with op.get_bind() as conn:
conn.execute(sa.text("""INSERT INTO wikibase_software (software_type, software_name)
SELECT DISTINCT software_type, software_name
FROM wikibase_software_version
ORDER BY software_type, software_name"""))
conn.execute(sa.text("""UPDATE wikibase_software_version
SET wikibase_software_id = wikibase_software.id
FROM wikibase_software
WHERE wikibase_software_version.software_name = wikibase_software.software_name AND wikibase_software_version.software_type = wikibase_software.software_type"""))
conn.commit()
# ### end Alembic commands ###


Expand Down

0 comments on commit 87a1759

Please sign in to comment.