修复迁移bug

This commit is contained in:
xuejiaming 2022-07-06 15:22:18 +08:00
parent 3c5f9c13fd
commit a42d6b95b5
2 changed files with 7 additions and 7 deletions

View File

@ -164,10 +164,10 @@ namespace Sample.MySql
}
}
Stopwatch sp = Stopwatch.StartNew();
app.ApplicationServices.UseAutoTryCompensateTable();
sp.Stop();
Console.WriteLine("UseAutoTryCompensateTable:"+sp.ElapsedMilliseconds);
// Stopwatch sp = Stopwatch.StartNew();
// app.ApplicationServices.UseAutoTryCompensateTable();
// sp.Stop();
// Console.WriteLine("UseAutoTryCompensateTable:"+sp.ElapsedMilliseconds);
app.UseRouting();
app.UseAuthorization();

View File

@ -48,7 +48,7 @@ namespace ShardingCore.Helpers
addCmds.ForEach(aAddCmd =>
{
var (migrationResult,shardingCmds) = BuildDataSourceShardingCmds(shardingRuntimeContext,currentCurrentDataSourceName,operation, aAddCmd.CommandText, sqlGenerationHelper);
var (migrationResult,shardingCmds) = BuildDataSourceShardingCmds(shardingRuntimeContext,virtualDataSource.DefaultDataSourceName,currentCurrentDataSourceName,operation, aAddCmd.CommandText, sqlGenerationHelper);
if (!migrationResult.InDataSource)
{
if (migrationResult.CommandType == MigrationCommandTypeEnum.TableCommand)
@ -133,7 +133,7 @@ namespace ShardingCore.Helpers
return string.Format("^({0})$|^({0}_.*?)$|^(.*?_{0}_.*?)$|^(.*?_{0})$", absTableName);
}
}
private static (MigrationResult migrationResult,List<string>) BuildDataSourceShardingCmds(IShardingRuntimeContext shardingRuntimeContext,string dataSourceName,MigrationOperation operation, string sourceCmd, ISqlGenerationHelper sqlGenerationHelper)
private static (MigrationResult migrationResult,List<string>) BuildDataSourceShardingCmds(IShardingRuntimeContext shardingRuntimeContext,string defaultDataSourceName,string dataSourceName,MigrationOperation operation, string sourceCmd, ISqlGenerationHelper sqlGenerationHelper)
{
//所有MigrationOperation定义
//https://github.com/dotnet/efcore/tree/b970bf29a46521f40862a01db9e276e6448d3cb0/src/EFCore.Relational/Migrations/Operations
@ -196,7 +196,7 @@ namespace ShardingCore.Helpers
}
else
{
migrationResult.InDataSource = true;
migrationResult.InDataSource = defaultDataSourceName==dataSourceName;
}
//分表