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
Allow many assemblies to contribute IMigrations in the same migrations run #467
Conversation
…otentially) many Assembly instances.
…on, so I refactored how getting a embedded resource from an Assembly works when you pass in multiple assemblies to the Runner.
… used a singular name to plural (assembly -> assemblies)
Exposing @Julian Rooze multiple assemblies support to msbuild task.
I've just had a chance to test this. I have a modular application and this seemed like a good idea. Each assembly/module has a class which implements IVersionTableMetaData. This allows me to have a separate set of migrations per assembly/module and the versions are managed per assembly in a separate version table (ideally this would be within the same table but you would need to store the assembly which run the migration and remove the unique constraint on the version). However if I have a migration within each assembly with the same version number then it throws an error. I know I can get around this by looping over each assembly and running the migrations per assembly but it's quite slow and also the transaction is managed per assembly so if one statement fails in an assembly then it doesn't prevent the remaining assemblies from trying to commit their changes. |
msbuild task: multiple assemblies support
Conflicts: src/FluentMigrator.Runner/ProfileLoader.cs
@JulianRooze How does this work, it's just a runner change for programmatic access ? |
@tommarien Yes, basically, that's how the change is exposed to the outside. We use a console application as our migration runner that scans all loaded assemblies for Internally, places that previously accepted an |
@JulianRooze i would consider merging it in if the code was 100% backwards compatible What i mean is that for instance the msbuild runner should have both options still open : old style 1 assembly and new multiple assemblies for instance Any chance you can create a branch from our source and reincorperate the changes in a backwards compatible way ? |
The MsBuild changes were a contribution by @esakal. I'll take a look if I can make that backwards compatible. How do you suggest I approach keeping the naming backwards compatible while keeping them sensical? I did a lot of renaming in 28d02b8 because naming something typed I suppose I could expose both a property of type |
@JulianRooze i just quickly checked the change by esekal, it already looks backward compatible, i guess all should be fine |
Okay, thanks for the check. Let me know if you need me to make any changes to make this mergeable. |
Build error fixes after merge msbuild multiple assemblies support Renamed every variable/parameter/property of IAssemblyCollection that used a singular name to plural (assembly -> assemblies) Using Assembly.GetCallingAssembly() proved to not be a working solution, so I refactored how getting a embedded resource from an Assembly works when you pass in multiple assemblies to the Runner. Refactored the dependency on a single Assembly for the Runner into (potentially) many Assembly instances. Conflicts: src/FluentMigrator.Runner/MaintenanceLoader.cs
@JulianRooze Thanks Julian, seems to run fine ;) |
See: #463 for the original issue that I created.
In short: not all of our migrations are in the same assembly. This is deliberate as our application is very modular in nature and a module is able to define its own (very specific to its need) tables and other database objects, so migrations are present in several assemblies. Currently, it's only possible to do this through iterating through all your migration assemblies and creating a separate runner for each one, which doesn't necessarily run the migrations in the correct order.
I've made a change that preserves current functionality (you can still pass in a single
Assembly
instance to the runner) but adds the ability to also provide aIAssemblyCollection
instance. The current overloads that accept aAssembly
parameter default to creating a implementation ofIAssemblyCollection
, namelySingleAssembly
.I've tried to keep breaking changes to a minimum, but to preserve sensical naming I've had to rename properties that are part of the public API to "Assemblies" instead of "Assembly".