NREL / BuildingMOTIF

Building Metadata OnTology Interoperability Framework (BuildingMOTIF)
https://buildingmotif.readthedocs.io/
Other
48 stars 6 forks source link

Fix migrations in postgres #247

Closed gtfierro closed 1 year ago

gtfierro commented 1 year ago

In the 542bfbdef624_constrain_dependencies_to_have_no_.py migration, we set autoincrement and primary key properties for the deps_association_table.id field. These should result in autoincrementing primary key behavior in all databases, but due to the way that we add/remove the constraints, the autoincrementing behavior does not get realized in a postgres database. This PR adjusts the migration (I believe this is correct but have not tested it on existing databases) and adds an integration test invoking the docker compose setup and inserting libraries into a migrated database instance

gtfierro commented 1 year ago

Yep! See you soon

--

Dr. Gabe Fierro | https://home.gtf.fyihttps://home.gtf.fyi/

Assistant Professor of Computer Science | Colorado School of Mines

Joint Appointment | National Renewable Energy Laboratory


From: Hannah Eslinger @.> Sent: Tuesday, June 13, 2023 10:25:01 AM To: NREL/BuildingMOTIF @.> Cc: Gabe Fierro @.>; Author @.> Subject: [EXTERNAL] Re: [NREL/BuildingMOTIF] Fix migrations in postgres (PR #247)

CAUTION: This email originated from outside of the Colorado School of Mines organization. Do not click on links or open attachments unless you recognize the sender and know the content is safe.

@haneslinger commented on this pull request.


In migrations/versions/542bfbdef624_constrain_dependencies_to_haveno.pyhttps://github.com/NREL/BuildingMOTIF/pull/247#discussion_r1228402675:

     batch_op.drop_constraint("deps_association_table_pkey", type_="primary")
  • batch_op.create_primary_key("deps_association_pk", columns=["id"])
  • batch_op.alter_column(
  • existing_type=sa.INTEGER(),
  • column_name="id",
  • autoincrement=True,
  • existing_autoincrement=True,
  • nullable=False,
  • )
  • batch_op.add_column(sa.Column("id", sa.Integer(), primary_key=True))

You are coming in this afternoon, right? I figured out the problem, I'd like to explain it to you

— Reply to this email directly, view it on GitHubhttps://github.com/NREL/BuildingMOTIF/pull/247#discussion_r1228402675, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAANRCT26YEWUFIDF3NH4WLXLCH53ANCNFSM6AAAAAAYIYYS4A. You are receiving this because you authored the thread.Message ID: @.***>