-
Notifications
You must be signed in to change notification settings - Fork 700
Use database function to set the value of AppliedOn
#1847
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
Use database function to set the value of AppliedOn
#1847
Conversation
|
The extension method to GetQuoter would not work for all generators. I don't want to support that. Why do you need it on the first place? |
|
In general, I agree we need to support this but wanted to suggest some changes.
|
|
Thanks for taking the time to go through this. Yesterday I wrote a lengthy comment responding to your feedback and it seems to have disappeared.
The extension method is necessary because of 2 reasons:
You can see that this is the case by looking at the code of fluentmigrator/src/FluentMigrator.Runner.Core/FluentMigratorServiceCollectionExtensions.cs Lines 52 to 180 in 4026fc1
and the builders of the database providers: fluentmigrator/src/FluentMigrator.Runner.SqlServer/SqlServerRunnerBuilderExtensions.cs Lines 40 to 52 in 4026fc1
fluentmigrator/src/FluentMigrator.Runner.Postgres/PostgresRunnerBuilderExtensions.cs Lines 118 to 130 in 4026fc1
fluentmigrator/src/FluentMigrator.Runner.Oracle/OracleRunnerBuilderExtensions.cs Lines 37 to 47 in 4026fc1
This means that there are no registrations of This can be tested out quickly by running the example console application: What I originally wanted to do, was add a property to I did not wish to add any new references between projects, so I settled on the extension method.
I see this as a bug fix since the scripts were not being generated correctly. However, I understand that users might have relied on the previous behaviour. Could this new behaviour be based on a configuration option in
Based on the database providers in the code, all fluentmigrator/src/FluentMigrator.Runner.Core/Generators/Generic/GenericQuoter.cs Lines 114 to 117 in 4026fc1
|
|
That's a really good reason why you did it this way. I am trying to think of a way we can just inject it. I made each generator take an explicit dependency on purpose for this and type maps. Injecting it likely has other unforeseen benefits. What we really (probably) want is a tiny service locator that can get all generator dependencies as a GeneratorContext. (I'm almost done with a tiny PR to add an ISeparator interface to formalize the concepts of statements and batches, which will further help offline scripting) I need to think about this more. If I can't arrive at a better solution, I guess we will use your approach. |
|
I'm going to try to merge this tonight. Just released 6.0, will put this in 6.1. Thanks for your patience. Just had a newborn baby boy in August and just starting to get good nights sleep for the first time in about two months. |
|
Congrats on the baby! Absolutely not an issue. Take all the time that you need. I worked around the issue in my own project so there is no rush on my side. The change request was a means for me to contribute something to the library that others might be able to make use of. |
|
@nathanpovo As an update and late change request, I believe there is already infrastructure to get the generator easily - see IGeneratorAccessor. Can you use that? |
3dcb863 to
b4c0e29
Compare
I checked what code would need to be modified for this to be done, and the constructors of the Is it fine to modify the constructors? I have done the modification, we can reset it back if the constructors should not be modified. |
483b060 to
bac5b1c
Compare
|
I think this change makes sense, even if by some opinion its technical debt. We can always obsolete those constructors later when a better design comes along. |
|
@nathanpovo It looks like some tests failed - can you take a look? |
bac5b1c to
6c8531c
Compare
6c8531c to
9ddaf40
Compare
|
Sorry, didn't notice the failing tests. They have been fixed. |
|
Looks great. I will do one last read through the code this weekend and then merge it for 6.3.0 assuming I dont catch anything, which I doubt I will. |
|
@nathanpovo One last thought - should IMigrationGenerator expose the IQuoter directly? I am trying to think of a reason not to and can't think of one. I'd prefer that to the cast to GeneratorBase, as someone could in theory write their own Generator without that. |
|
That's kind of what I had wanted to do originally (but have Unfortunately, it's not possible because Or move Both of which are breaking changes. |
|
Right, sorry, new parent brain, forgot we discussed this. I'll merge this and add a ticket to clean this up. |



Use a database function to set the value of the
AppliedOncolumn of theVersionInfotable whenever the version info is updated.Previously, the value of
AppliedOnwould be decided when the migrations are generated and then hardcoded into the SQL script.This is not an issue when the database is updated directly but it is a problem when updating the database through SQL scripts.
Before
After
Fixes #1846