针对时间分表的StarJob替换成AutoCreateTableByTime并且默认强制重写,发布x.3.1.49
This commit is contained in:
parent
b64829636b
commit
993bfecb5d
|
@ -1,9 +1,9 @@
|
|||
:start
|
||||
::定义版本
|
||||
set EFCORE2=2.3.1.48
|
||||
set EFCORE3=3.3.1.48
|
||||
set EFCORE5=5.3.1.48
|
||||
set EFCORE6=6.3.1.48
|
||||
set EFCORE2=2.3.1.49
|
||||
set EFCORE3=3.3.1.49
|
||||
set EFCORE5=5.3.1.49
|
||||
set EFCORE6=6.3.1.49
|
||||
|
||||
::删除所有bin与obj下的文件
|
||||
@echo off
|
||||
|
|
|
@ -28,5 +28,10 @@ namespace Sample.BulkConsole
|
|||
{
|
||||
return new OrderPaginationConfiguration();
|
||||
}
|
||||
|
||||
public override bool AutoCreateTableByTime()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,5 +36,10 @@ namespace Sample.Migrations.EFCores
|
|||
{
|
||||
builder.ShardingProperty(o => o.CreateTime);
|
||||
}
|
||||
|
||||
public override bool AutoCreateTableByTime()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,5 +13,10 @@ namespace Sample.MySql.Shardings
|
|||
{
|
||||
return new DateTime(2021, 1, 01);
|
||||
}
|
||||
|
||||
public override bool AutoCreateTableByTime()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,15 +14,16 @@ namespace Sample.SqlServer.Shardings
|
|||
{
|
||||
return new DateTime(2020, 1, 1);
|
||||
}
|
||||
|
||||
public override bool StartJob()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public override void Configure(EntityMetadataTableBuilder<TestYearSharding> builder)
|
||||
{
|
||||
builder.ShardingProperty(o => o.CreateTIme);
|
||||
}
|
||||
|
||||
public override bool AutoCreateTableByTime()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,5 +16,10 @@ namespace Sample.SqlServerShardingAll.VirtualTableRoutes
|
|||
{
|
||||
builder.ShardingProperty(o => o.CreationTime);
|
||||
}
|
||||
|
||||
public override bool AutoCreateTableByTime()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,5 +16,10 @@ namespace Sample.SqlServerShardingTable.VirtualRoutes
|
|||
{
|
||||
builder.ShardingProperty(o => o.CreationTime);
|
||||
}
|
||||
|
||||
public override bool AutoCreateTableByTime()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,5 +19,10 @@ namespace Samples.AutoByDate.SqlServer.Shardings
|
|||
//如果返回动态值会导致程序重新启动这个值就会变动导致无法获取之前的表
|
||||
return DateTime.Now.AddDays(-2);
|
||||
}
|
||||
|
||||
public override bool AutoCreateTableByTime()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -14,5 +14,10 @@ namespace Samples.AutoByDate.SqlServer.Shardings
|
|||
{
|
||||
return new DateTime(2021, 8, 1);
|
||||
}
|
||||
|
||||
public override bool AutoCreateTableByTime()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -110,7 +110,7 @@ namespace ShardingCore.Bootstrapers
|
|||
//检测校验分表分库对象元数据
|
||||
entityMetadata.CheckShardingTableMetadata();
|
||||
//添加任务
|
||||
if (virtualTableRoute is IJob routeJob && routeJob.StartJob())
|
||||
if (virtualTableRoute is IJob routeJob && routeJob.AutoCreateTableByTime())
|
||||
{
|
||||
var jobManager = ShardingContainer.GetService<IJobManager>();
|
||||
var jobEntry = JobEntryFactory.Create(routeJob);
|
||||
|
|
|
@ -72,6 +72,10 @@ namespace ShardingCore.Core.VirtualRoutes.TableRoutes.Abstractions
|
|||
/// <returns></returns>
|
||||
public abstract List<string> GetAllTails();
|
||||
|
||||
/// <summary>
|
||||
/// 配置分表信息
|
||||
/// </summary>
|
||||
/// <param name="builder"></param>
|
||||
public virtual void Configure(EntityMetadataTableBuilder<T> builder)
|
||||
{
|
||||
|
||||
|
|
|
@ -8,6 +8,6 @@ namespace ShardingCore.Jobs.Abstaractions
|
|||
string JobName { get; }
|
||||
string[] GetCronExpressions();
|
||||
Task ExecuteAsync();
|
||||
bool StartJob();
|
||||
bool AutoCreateTableByTime();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,14 +32,15 @@ namespace ShardingCore.VirtualRoutes.Abstractions
|
|||
public virtual string JobName =>
|
||||
$"{EntityMetadata?.ShardingDbContextType?.Name}:{EntityMetadata?.EntityType?.Name}";
|
||||
|
||||
public virtual bool StartJob()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
/// <summary>
|
||||
/// 是否需要自动创建按时间分表的路由
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public abstract bool AutoCreateTableByTime();
|
||||
/// <summary>
|
||||
/// 显示错误日志
|
||||
/// </summary>
|
||||
public virtual bool ShowErrorLog => false;
|
||||
public virtual bool DoLogError => false;
|
||||
|
||||
public abstract string[] GetCronExpressions();
|
||||
|
||||
|
@ -84,7 +85,7 @@ namespace ShardingCore.VirtualRoutes.Abstractions
|
|||
{
|
||||
//ignore
|
||||
_logger.LogInformation($"warning table tail:[{tail}],entity:[{typeof(TEntity).Name}]");
|
||||
if (ShowErrorLog)
|
||||
if (DoLogError)
|
||||
_logger.LogError(e, $"{dataSource} {typeof(TEntity).Name}'s create table error ");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,11 +16,6 @@ namespace ShardingCore.Test2x.Shardings
|
|||
return new DateTime(2021, 1, 1);
|
||||
}
|
||||
|
||||
public override bool StartJob()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Configure(EntityMetadataTableBuilder<LogDay> builder)
|
||||
{
|
||||
builder.ShardingProperty(o => o.LogTime);
|
||||
|
@ -31,5 +26,10 @@ namespace ShardingCore.Test2x.Shardings
|
|||
{
|
||||
return new LogDayPaginationConfiguration();
|
||||
}
|
||||
|
||||
public override bool AutoCreateTableByTime()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,15 +13,15 @@ namespace ShardingCore.Test2x.Shardings
|
|||
return new DateTime(2021, 1, 1);
|
||||
}
|
||||
|
||||
public override bool StartJob()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override IPaginationConfiguration<Order> CreatePaginationConfiguration()
|
||||
{
|
||||
return new OrderCreateTimePaginationConfiguration();
|
||||
}
|
||||
|
||||
public override bool AutoCreateTableByTime()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class OrderCreateTimePaginationConfiguration : IPaginationConfiguration<Order>
|
||||
|
|
|
@ -16,11 +16,6 @@ namespace ShardingCore.Test3x.Shardings
|
|||
return new DateTime(2021, 1, 1);
|
||||
}
|
||||
|
||||
public override bool StartJob()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Configure(EntityMetadataTableBuilder<LogDay> builder)
|
||||
{
|
||||
builder.ShardingProperty(o => o.LogTime);
|
||||
|
@ -31,5 +26,10 @@ namespace ShardingCore.Test3x.Shardings
|
|||
{
|
||||
return new LogDayPaginationConfiguration();
|
||||
}
|
||||
|
||||
public override bool AutoCreateTableByTime()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,16 +12,17 @@ namespace ShardingCore.Test3x.Shardings
|
|||
{
|
||||
return new DateTime(2021, 1, 1);
|
||||
}
|
||||
|
||||
public override bool StartJob()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public override IPaginationConfiguration<Order> CreatePaginationConfiguration()
|
||||
{
|
||||
return new OrderCreateTimePaginationConfiguration();
|
||||
}
|
||||
|
||||
public override bool AutoCreateTableByTime()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class OrderCreateTimePaginationConfiguration : IPaginationConfiguration<Order>
|
||||
|
|
|
@ -16,11 +16,7 @@ namespace ShardingCore.Test5x.Shardings
|
|||
{
|
||||
return new DateTime(2021, 1, 1);
|
||||
}
|
||||
|
||||
public override bool StartJob()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public override void Configure(EntityMetadataTableBuilder<LogDay> builder)
|
||||
{
|
||||
|
@ -32,5 +28,10 @@ namespace ShardingCore.Test5x.Shardings
|
|||
{
|
||||
return new LogDayPaginationConfiguration();
|
||||
}
|
||||
|
||||
public override bool AutoCreateTableByTime()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,15 +13,16 @@ namespace ShardingCore.Test5x.Shardings
|
|||
return new DateTime(2021, 1, 1);
|
||||
}
|
||||
|
||||
public override bool StartJob()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override IPaginationConfiguration<Order> CreatePaginationConfiguration()
|
||||
{
|
||||
return new OrderCreateTimePaginationConfiguration();
|
||||
}
|
||||
|
||||
public override bool AutoCreateTableByTime()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class OrderCreateTimePaginationConfiguration : IPaginationConfiguration<Order>
|
||||
|
|
|
@ -19,11 +19,7 @@ namespace ShardingCore.Test6x.Shardings
|
|||
{
|
||||
return new DateTime(2021, 1, 1);
|
||||
}
|
||||
|
||||
public override bool StartJob()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public override void Configure(EntityMetadataTableBuilder<LogDay> builder)
|
||||
{
|
||||
|
@ -35,5 +31,10 @@ namespace ShardingCore.Test6x.Shardings
|
|||
{
|
||||
return new LogDayPaginationConfiguration();
|
||||
}
|
||||
|
||||
public override bool AutoCreateTableByTime()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,15 +16,16 @@ namespace ShardingCore.Test6x.Shardings
|
|||
return new DateTime(2021, 1, 1);
|
||||
}
|
||||
|
||||
public override bool StartJob()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override IPaginationConfiguration<Order> CreatePaginationConfiguration()
|
||||
{
|
||||
return new OrderCreateTimePaginationConfiguration();
|
||||
}
|
||||
|
||||
public override bool AutoCreateTableByTime()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class OrderCreateTimePaginationConfiguration : IPaginationConfiguration<Order>
|
||||
|
|
|
@ -12,7 +12,9 @@ namespace ShardingCore.Test6x.Shardings.PaginationConfigs
|
|||
{
|
||||
public void Configure(PaginationBuilder<LogDay> builder)
|
||||
{
|
||||
builder.PaginationSequence(o => o.LogTime).UseQueryMatch(PaginationMatchEnum.Named|PaginationMatchEnum.Owner|PaginationMatchEnum.PrimaryMatch);
|
||||
builder.PaginationSequence(o => o.LogTime)
|
||||
.UseQueryMatch(PaginationMatchEnum.Named | PaginationMatchEnum.Owner |
|
||||
PaginationMatchEnum.PrimaryMatch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue