Apply migration to every database in a shard using Elastic Database?
See original GitHub issueI have a project which uses the Elastic Database client library to work with a multi-tenant application. Each database belongs to a single tenant.
I would like to use FluentMigrator to manage the schema of every database in the shard.
Ideally, I’d like to configure a runner with multiple connection strings (which I get from the Elastic Database client).
private static IServiceProvider CreateServices()
{
return new ServiceCollection()
// Add common FluentMigrator services
.AddFluentMigratorCore()
.ConfigureRunner(rb => rb
// Add SQLite support to FluentMigrator
.AddSQLite()
// Set the connection string
.WithGlobalConnectionString("Data Source=test.db") // add multiple?
// Define the assembly containing the migrations
.ScanIn(typeof(AddLogTable).Assembly).For.Migrations())
// Enable logging to console in the FluentMigrator way
.AddLogging(lb => lb.AddFluentMigratorConsole())
// Build the service provider
.BuildServiceProvider(false);
}
Is there a supported way to do this? Or do I need to explicitly create and execute one runner per database?
Issue Analytics
- State:
- Created 4 years ago
- Comments:13 (3 by maintainers)
Top Results From Across the Web
Migrate existing databases to scale out - Azure SQL ...
To migrate an existing sharded database: Prepare the shard map manager database. Create the shard map. Prepare the individual shards.
Read more >Migrate data between shards
The database I'm working on works with Guids, so we can't use the example code. I've created a Move/Merge management tool myself, but...
Read more >Migrating data | Elasticsearch Service Documentation
Use the steps on this page to reindex the internal indices from a remote cluster. The steps for reindexing internal indices and regular,...
Read more >Using Oracle Sharding
You can migrate data from a non-sharded database to an Oracle Sharding sharded database using the methods described here.
Read more >What is Database Sharding? - Shard DB Explained
Database sharding overcomes this limitation by splitting data into smaller chunks, called shards, and storing them across several database servers. All database ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You have two options:
IConnectionStringAccessor
implementation and run the migrator multiple times where yourIConnectionStringAccessor
implementation returns a different connection string on each run (static variable?)@c17r Thanks for the detailed use case layout. Very helpful.
WithGlobalConnectionString is per service provider. So, if you’re only referencing FluentMigrator objects within your DI scope, you can just create multiple service providers and dispose of them when you’re done. The “Global” is really per ServiceCollection at the point you call
BuildServiceProvider();
It’s when you want to mix in outside objects not native to FluentMigrator that things get hairy, because then you’re mixing type universes and potentially lifetime scopes, and an “external” object you’re injecting might not exist at run-time because it’s been disposed.