-
-
Notifications
You must be signed in to change notification settings - Fork 47
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
Extendable database_consistency #196
Comments
Hi @toydestroyer, This is a great idea! I'm so happy your team is leveraging the gem so deep that you create custom checkers. I like the feature, but I have a question. Would we support adding such through DatabaseConsistency.configure do
add_checkers CustomChecker1, CustomChecker2
add_writers SimpleWriter1, AutofixWriter1
end How would those Something like this? class CustomChecker < DatabaseConsistency::Checkers::ColumnChecker
...
end
DatabaseConsistency.add_checker(CustomChecker) P.S. Do you have any suggestions for problem one? |
I don't have a strong opinion here. Yaml is neater, and this is what rubocop is doing (here's how). Rubocop rules are self-contained. You do checks, reporting, and autocorrections in the same class (example). Rubocop does have a registry and register new rules upon inheritance. But in the case of DatabaseConsistency gem, we need to register the checker, simple writer, error slug (?), and sometimes autofix. I'll think more about the topic this week. For now, I want to share my findings and thoughts and hear your thoughts as well @djezzzl.
This definitely should be a separate gem that overrides autofix writers. We don't need to duplicate their code, we just need to generate migration files that don't violate strong_migrrations' recommendations. |
I don't see any issues with doing the same.
Excellent, we can do the same 👍
We may have some logic to ensure that everything (or minimal requirement) is provided, but my main idea was to avoid being bound to any of the writers (TODO/Simple/Autofix, etc.). But I understand if there is none provided, how would the consumer know something needs to be added to make it fully work? We may start with good guidance or additional "code" that validates custom classes if they have everything/something to be written.
Please share once you foresee some vision; I like the idea and want to help you and your team leverage the gem as much as possible.
Agree; let's let
Now, I'm kind of confused. How can we write good migrations without "duplicating the strong_recommendations"? It would require us to maintain and support all recent changes, and I wonder if we should do this. I agree that What do you think, @toydestroyer? |
Sorry for the confusion, let me clarify. I meant there should be a gem called
You personally shouldn't do anything as long as Also, maintenance shouldn't be a big issue because there are not many changes in how you write safe migrations. For example, last time there was a change in how you safely add
In that case, they just use pure |
I have a feeling that "simple writer" should be replaced by the concept of "formatter". This is something RSpec does. Take a look at the progress and documentation formatters for example. The idea is that the checker should report all the information anyone might need to render the result. And if you think about it, In order to make this happen, we need to move the Once again, this opens an opportunity for extensions (rspec_junit_formatter as an example of such an extension for RSpec). Like, what if I want to generate the report in an HTML file? I just do
How does this sound to you @djezzzl? |
Hey everyone! 👋
I have a feature request.
Problem 1: Compatibility with
strong_migrations
Our to-do list is quite long, and we're solving problems in batches. For some problems (like missing
NOT NULL
constraints or foreign keys), the autofix feature automatically generates a migration file for us.However, we're also using the strong_migrations gem, which complains about the autogenerated migration files. For instance, to add a
NOT NULL
constraint, we need 2 migration files:Instead of the one being generated:
Problem 2: Custom checkers
We have some ideas for checkers that are very specific to our internal conventions, and making them public doesn't make sense. We also have WIP checkers that are not ready to be merged yet (like enum one) but can internally benefit us a lot.
Proposed Solution
Allow users to extend checkers/writers with custom ones similar to RuboCop's approach:
Looking forward to your suggestions and feedback. Thank you!
The text was updated successfully, but these errors were encountered: