Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix migrations in postgres #247

Closed
wants to merge 3 commits into from
Closed

Conversation

gtfierro
Copy link
Collaborator

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

Copy link
Member

@TShapinsky TShapinsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fine to me. I'd be interested in hearing @haneslinger 's thoughs since she has feelings about migrations. Also see my comment.

- target: 4200
published: 4200
protocol: tcp
mode: host
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we may want to merge our docker-compose fixtures at some point. Then we can have a subset of tests which need to run in that environment. This would allow us to use gh actions to handle uping and building the containers. And we could also do it once instead of redeploying them for every test.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea, though to make each of the tests independent we will probably want to wipe any state anyway. Can you make an issue to handle this in the future?

existing_autoincrement=True,
nullable=False,
)
batch_op.add_column(sa.Column("id", sa.Integer(), primary_key=True))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a non-nullable column without a default value or something for the existing rows typically fails. Did you test to on a db with deps_associations in it?

Copy link
Collaborator Author

@gtfierro gtfierro Jun 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I spent a lot of time yesterday trying to get that set up to test but I could never get it to work. I also don't think there are any existing BuildingMOTIF databases out there that would use this migration --- is it worth just removing this migration and just putting the changes directly into BuildingMOTIF?

Essentially, I think the engineering effort in getting this migration to work properly (and getting it properly tested) is outweighing the benefit of having it in there. Given that there aren't really any existing BuildingMOTIF deployments at this stage, I would much rather take the easy way out :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@gtfierro
Copy link
Collaborator Author

gtfierro commented Jun 13, 2023 via email

@haneslinger haneslinger mentioned this pull request Jun 13, 2023
@TShapinsky TShapinsky closed this Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants