Skip to content

Remove migration to change production model#105

Open
klappradla wants to merge 3 commits intomainfrom
fix/ex-137-update-production-model
Open

Remove migration to change production model#105
klappradla wants to merge 3 commits intomainfrom
fix/ex-137-update-production-model

Conversation

@klappradla
Copy link
Member

@klappradla klappradla commented Dec 11, 2025

This removes the migration to update the production model. The migration
only includes INSERT statements and a conditional to check for the
current environment. Both are anti-patterns and will make our lives
harder…

So I opted for some raw SQL juggle instead and added the new model to
the large SQL statement, more as a way to document it.

Also: Remove env specific insert statements from migrations

The env-specific condition was added after the migrations ran on
staging/production, so it did not occur as a problem for the deployment
(yet).

I completely removed the statements, as they mess with the test database
if we skip the conditional. For the dev environment, the seeds are
already run with mix ecto.setup, so the state of the database should
be fine.

This removes the migration to update the production model. The migration
only includes INSERT statements and a conditional to check for the
current environment. Both are anti-patterns and will make our lives
harder…

So I opted for some raw SQL juggle instead and added the new model to
the large SQL statement, more as a way to document it.
The env-specific condition was added after the migrations ran on
staging/production, so it did not occur as a problem for the deployment
(yet).

I completely removed the statements, as they mess with the test database
if we skip the conditional. For the dev environment, the seeds are
already run with `mix ecto.setup`, so the state of the database should
be fine.
@andreasknoepfle
Copy link
Member

Looks good to me.
Is that priv/repo/insert_model_configs.sql meant to be executed in prod?
If so and there are unique constraints set right it might be nice to write them with ON CONFLICT DO NOTHING, so that the script can be run more than once.

@klappradla
Copy link
Member Author

Looks good to me. Is that priv/repo/insert_model_configs.sql meant to be executed in prod? If so and there are unique constraints set right it might be nice to write them with ON CONFLICT DO NOTHING, so that the script can be run more than once.

Hey @andreasknoepfle 👋

Sorry, I completely forgot about this PR for the last month 😂 I added the on conflict statements! Should I merge it like this?

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