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

Configurable migrations path #29

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

kraleppa
Copy link

@kraleppa kraleppa commented Apr 25, 2023

Decided to solve this issue 😄 #6

Let me know if something should be fixed here

Copy link
Owner

@Artur-Sulej Artur-Sulej left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!
I have a comment regarding Application.put_env

@@ -16,6 +16,17 @@ defmodule ExcellentMigrations.CredoCheck.MigrationsSafetyTest do
|> assert_issues()
end

test "it should report code that is defined in user specified directory" do
Application.put_env(:excellent_migrations, :migrations_paths, [
Copy link
Owner

Choose a reason for hiding this comment

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

Using Application.put_env requires restoring the original value after the test is finished (example). Otherwise the new value will stay there and will affect other tests. Maybe the problem isn't manifested in any way now, but in the future that might change.

Also because it means editing global config, it may no longer be possible to run test asynchronously. I don't recommend the approach with Application.put_env. Instead I propose:

  1. Passing migrations_paths to FilesFinder.get_migrations_paths as an argument. This way the test won't need to set the config.
  2. Or wrapping interaction with config in a new module with interface and create mock for tests with different implementation.

I'd go with the first approach – I believe it's fine & simple.

@@ -10,9 +10,12 @@ defmodule ExcellentMigrations.FilesFinder do
end

def relevant_file?(path, start_after) do
migrations_paths =
Application.get_env(:excellent_migrations, :migrations_paths, ["migrations/"])
Copy link
Owner

Choose a reason for hiding this comment

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

I like that a list of user defined paths is passed here (not just a single one) 👍🏻

@Artur-Sulej
Copy link
Owner

@kraleppa Also, if you rebase on fresh master, CI checks should now work.

@Stratus3D
Copy link

This is a nice improvement, I would love to see something like this get merged.

@Gladear
Copy link

Gladear commented Nov 18, 2024

@Artur-Sulej Can I help get this merged? I can create a new PR with the required changes if that's necessary.

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.

4 participants