修复迁移bug
This commit is contained in:
parent
3c5f9c13fd
commit
a42d6b95b5
|
@ -164,10 +164,10 @@ namespace Sample.MySql
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Stopwatch sp = Stopwatch.StartNew();
|
// Stopwatch sp = Stopwatch.StartNew();
|
||||||
app.ApplicationServices.UseAutoTryCompensateTable();
|
// app.ApplicationServices.UseAutoTryCompensateTable();
|
||||||
sp.Stop();
|
// sp.Stop();
|
||||||
Console.WriteLine("UseAutoTryCompensateTable:"+sp.ElapsedMilliseconds);
|
// Console.WriteLine("UseAutoTryCompensateTable:"+sp.ElapsedMilliseconds);
|
||||||
app.UseRouting();
|
app.UseRouting();
|
||||||
|
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
|
|
@ -48,7 +48,7 @@ namespace ShardingCore.Helpers
|
||||||
|
|
||||||
addCmds.ForEach(aAddCmd =>
|
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.InDataSource)
|
||||||
{
|
{
|
||||||
if (migrationResult.CommandType == MigrationCommandTypeEnum.TableCommand)
|
if (migrationResult.CommandType == MigrationCommandTypeEnum.TableCommand)
|
||||||
|
@ -133,7 +133,7 @@ namespace ShardingCore.Helpers
|
||||||
return string.Format("^({0})$|^({0}_.*?)$|^(.*?_{0}_.*?)$|^(.*?_{0})$", absTableName);
|
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定义
|
//所有MigrationOperation定义
|
||||||
//https://github.com/dotnet/efcore/tree/b970bf29a46521f40862a01db9e276e6448d3cb0/src/EFCore.Relational/Migrations/Operations
|
//https://github.com/dotnet/efcore/tree/b970bf29a46521f40862a01db9e276e6448d3cb0/src/EFCore.Relational/Migrations/Operations
|
||||||
|
@ -196,7 +196,7 @@ namespace ShardingCore.Helpers
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
migrationResult.InDataSource = true;
|
migrationResult.InDataSource = defaultDataSourceName==dataSourceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
//分表
|
//分表
|
||||||
|
|
Loading…
Reference in New Issue