From cc8fd28e5d1c37f8bdb4ac66c5c6f7f35d5f4b74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Fri, 11 Oct 2019 15:04:19 +0300 Subject: [PATCH] Db table prefix revision for the identity module #1429 --- .../Volo/Abp/BackgroundJobs/BackgroundJobsConsts.cs | 11 ----------- .../BackgroundJobs/BackgroundJobsDbProperties.cs | 13 +++++++++++++ .../EntityFrameworkCore/BackgroundJobsDbContext.cs | 12 ++---------- ...ackgroundJobsDbContextModelCreatingExtensions.cs | 5 ++++- ...ackgroundJobsModelBuilderConfigurationOptions.cs | 4 ++-- .../EntityFrameworkCore/IBackgroundJobsDbContext.cs | 2 +- .../MongoDB/BackgroundJobsMongoDbContext.cs | 9 ++------- .../BackgroundJobsMongoDbContextExtensions.cs | 4 +++- ...oundJobsMongoModelBuilderConfigurationOptions.cs | 4 ++-- .../MongoDB/IBackgroundJobsMongoDbContext.cs | 2 +- 10 files changed, 30 insertions(+), 36 deletions(-) delete mode 100644 modules/background-jobs/src/Volo.Abp.BackgroundJobs.Domain/Volo/Abp/BackgroundJobs/BackgroundJobsConsts.cs create mode 100644 modules/background-jobs/src/Volo.Abp.BackgroundJobs.Domain/Volo/Abp/BackgroundJobs/BackgroundJobsDbProperties.cs diff --git a/modules/background-jobs/src/Volo.Abp.BackgroundJobs.Domain/Volo/Abp/BackgroundJobs/BackgroundJobsConsts.cs b/modules/background-jobs/src/Volo.Abp.BackgroundJobs.Domain/Volo/Abp/BackgroundJobs/BackgroundJobsConsts.cs deleted file mode 100644 index a4a2e5ab94..0000000000 --- a/modules/background-jobs/src/Volo.Abp.BackgroundJobs.Domain/Volo/Abp/BackgroundJobs/BackgroundJobsConsts.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Volo.Abp.BackgroundJobs -{ - public static class BackgroundJobsConsts - { - public const string DefaultDbTablePrefix = "Abp"; - - public const string DefaultDbSchema = null; - - public const string ConnectionStringName = "AbpBackgroundJobs"; - } -} diff --git a/modules/background-jobs/src/Volo.Abp.BackgroundJobs.Domain/Volo/Abp/BackgroundJobs/BackgroundJobsDbProperties.cs b/modules/background-jobs/src/Volo.Abp.BackgroundJobs.Domain/Volo/Abp/BackgroundJobs/BackgroundJobsDbProperties.cs new file mode 100644 index 0000000000..48bd5701a1 --- /dev/null +++ b/modules/background-jobs/src/Volo.Abp.BackgroundJobs.Domain/Volo/Abp/BackgroundJobs/BackgroundJobsDbProperties.cs @@ -0,0 +1,13 @@ +using Volo.Abp.Data; + +namespace Volo.Abp.BackgroundJobs +{ + public static class BackgroundJobsDbProperties + { + public static string DbTablePrefix { get; } = AbpCommonDbProperties.DbTablePrefix; + + public static string DbSchema { get; } = AbpCommonDbProperties.DbSchema; + + public const string ConnectionStringName = "AbpBackgroundJobs"; + } +} diff --git a/modules/background-jobs/src/Volo.Abp.BackgroundJobs.EntityFrameworkCore/Volo/Abp/BackgroundJobs/EntityFrameworkCore/BackgroundJobsDbContext.cs b/modules/background-jobs/src/Volo.Abp.BackgroundJobs.EntityFrameworkCore/Volo/Abp/BackgroundJobs/EntityFrameworkCore/BackgroundJobsDbContext.cs index d2885ac35f..d879803677 100644 --- a/modules/background-jobs/src/Volo.Abp.BackgroundJobs.EntityFrameworkCore/Volo/Abp/BackgroundJobs/EntityFrameworkCore/BackgroundJobsDbContext.cs +++ b/modules/background-jobs/src/Volo.Abp.BackgroundJobs.EntityFrameworkCore/Volo/Abp/BackgroundJobs/EntityFrameworkCore/BackgroundJobsDbContext.cs @@ -4,13 +4,9 @@ using Volo.Abp.EntityFrameworkCore; namespace Volo.Abp.BackgroundJobs.EntityFrameworkCore { - [ConnectionStringName(BackgroundJobsConsts.ConnectionStringName)] + [ConnectionStringName(BackgroundJobsDbProperties.ConnectionStringName)] public class BackgroundJobsDbContext : AbpDbContext, IBackgroundJobsDbContext { - public static string TablePrefix { get; set; } = BackgroundJobsConsts.DefaultDbTablePrefix; - - public static string Schema { get; set; } = BackgroundJobsConsts.DefaultDbSchema; - public DbSet BackgroundJobs { get; set; } public BackgroundJobsDbContext(DbContextOptions options) @@ -23,11 +19,7 @@ namespace Volo.Abp.BackgroundJobs.EntityFrameworkCore { base.OnModelCreating(builder); - builder.ConfigureBackgroundJobs(options => - { - options.TablePrefix = TablePrefix; - options.Schema = Schema; - }); + builder.ConfigureBackgroundJobs(); } } } \ No newline at end of file diff --git a/modules/background-jobs/src/Volo.Abp.BackgroundJobs.EntityFrameworkCore/Volo/Abp/BackgroundJobs/EntityFrameworkCore/BackgroundJobsDbContextModelCreatingExtensions.cs b/modules/background-jobs/src/Volo.Abp.BackgroundJobs.EntityFrameworkCore/Volo/Abp/BackgroundJobs/EntityFrameworkCore/BackgroundJobsDbContextModelCreatingExtensions.cs index 191b0bd8ee..8a3e4b126a 100644 --- a/modules/background-jobs/src/Volo.Abp.BackgroundJobs.EntityFrameworkCore/Volo/Abp/BackgroundJobs/EntityFrameworkCore/BackgroundJobsDbContextModelCreatingExtensions.cs +++ b/modules/background-jobs/src/Volo.Abp.BackgroundJobs.EntityFrameworkCore/Volo/Abp/BackgroundJobs/EntityFrameworkCore/BackgroundJobsDbContextModelCreatingExtensions.cs @@ -12,7 +12,10 @@ namespace Volo.Abp.BackgroundJobs.EntityFrameworkCore { Check.NotNull(builder, nameof(builder)); - var options = new BackgroundJobsModelBuilderConfigurationOptions(); + var options = new BackgroundJobsModelBuilderConfigurationOptions( + BackgroundJobsDbProperties.DbTablePrefix, + BackgroundJobsDbProperties.DbSchema + ); optionsAction?.Invoke(options); diff --git a/modules/background-jobs/src/Volo.Abp.BackgroundJobs.EntityFrameworkCore/Volo/Abp/BackgroundJobs/EntityFrameworkCore/BackgroundJobsModelBuilderConfigurationOptions.cs b/modules/background-jobs/src/Volo.Abp.BackgroundJobs.EntityFrameworkCore/Volo/Abp/BackgroundJobs/EntityFrameworkCore/BackgroundJobsModelBuilderConfigurationOptions.cs index 43cd847ea2..0f59572d6e 100644 --- a/modules/background-jobs/src/Volo.Abp.BackgroundJobs.EntityFrameworkCore/Volo/Abp/BackgroundJobs/EntityFrameworkCore/BackgroundJobsModelBuilderConfigurationOptions.cs +++ b/modules/background-jobs/src/Volo.Abp.BackgroundJobs.EntityFrameworkCore/Volo/Abp/BackgroundJobs/EntityFrameworkCore/BackgroundJobsModelBuilderConfigurationOptions.cs @@ -6,8 +6,8 @@ namespace Volo.Abp.BackgroundJobs.EntityFrameworkCore public class BackgroundJobsModelBuilderConfigurationOptions : ModelBuilderConfigurationOptions { public BackgroundJobsModelBuilderConfigurationOptions( - [NotNull] string tablePrefix = BackgroundJobsConsts.DefaultDbTablePrefix, - [CanBeNull] string schema = BackgroundJobsConsts.DefaultDbSchema) + [NotNull] string tablePrefix = "", + [CanBeNull] string schema = null) : base( tablePrefix, schema) diff --git a/modules/background-jobs/src/Volo.Abp.BackgroundJobs.EntityFrameworkCore/Volo/Abp/BackgroundJobs/EntityFrameworkCore/IBackgroundJobsDbContext.cs b/modules/background-jobs/src/Volo.Abp.BackgroundJobs.EntityFrameworkCore/Volo/Abp/BackgroundJobs/EntityFrameworkCore/IBackgroundJobsDbContext.cs index e46f60f22b..cc70b6543a 100644 --- a/modules/background-jobs/src/Volo.Abp.BackgroundJobs.EntityFrameworkCore/Volo/Abp/BackgroundJobs/EntityFrameworkCore/IBackgroundJobsDbContext.cs +++ b/modules/background-jobs/src/Volo.Abp.BackgroundJobs.EntityFrameworkCore/Volo/Abp/BackgroundJobs/EntityFrameworkCore/IBackgroundJobsDbContext.cs @@ -4,7 +4,7 @@ using Volo.Abp.EntityFrameworkCore; namespace Volo.Abp.BackgroundJobs.EntityFrameworkCore { - [ConnectionStringName(BackgroundJobsConsts.ConnectionStringName)] + [ConnectionStringName(BackgroundJobsDbProperties.ConnectionStringName)] public interface IBackgroundJobsDbContext : IEfCoreDbContext { DbSet BackgroundJobs { get; } diff --git a/modules/background-jobs/src/Volo.Abp.BackgroundJobs.MongoDB/Volo/Abp/BackgroundJobs/MongoDB/BackgroundJobsMongoDbContext.cs b/modules/background-jobs/src/Volo.Abp.BackgroundJobs.MongoDB/Volo/Abp/BackgroundJobs/MongoDB/BackgroundJobsMongoDbContext.cs index ffcd7fbe9f..745903cae7 100644 --- a/modules/background-jobs/src/Volo.Abp.BackgroundJobs.MongoDB/Volo/Abp/BackgroundJobs/MongoDB/BackgroundJobsMongoDbContext.cs +++ b/modules/background-jobs/src/Volo.Abp.BackgroundJobs.MongoDB/Volo/Abp/BackgroundJobs/MongoDB/BackgroundJobsMongoDbContext.cs @@ -4,21 +4,16 @@ using Volo.Abp.MongoDB; namespace Volo.Abp.BackgroundJobs.MongoDB { - [ConnectionStringName(BackgroundJobsConsts.ConnectionStringName)] + [ConnectionStringName(BackgroundJobsDbProperties.ConnectionStringName)] public class BackgroundJobsMongoDbContext : AbpMongoDbContext, IBackgroundJobsMongoDbContext { - public static string CollectionPrefix { get; set; } = BackgroundJobsConsts.DefaultDbTablePrefix; - public IMongoCollection BackgroundJobs { get; set; } protected override void CreateModel(IMongoModelBuilder modelBuilder) { base.CreateModel(modelBuilder); - modelBuilder.ConfigureBackgroundJobs(options => - { - options.CollectionPrefix = CollectionPrefix; - }); + modelBuilder.ConfigureBackgroundJobs(); } } } \ No newline at end of file diff --git a/modules/background-jobs/src/Volo.Abp.BackgroundJobs.MongoDB/Volo/Abp/BackgroundJobs/MongoDB/BackgroundJobsMongoDbContextExtensions.cs b/modules/background-jobs/src/Volo.Abp.BackgroundJobs.MongoDB/Volo/Abp/BackgroundJobs/MongoDB/BackgroundJobsMongoDbContextExtensions.cs index 637d17a9d2..a16def3668 100644 --- a/modules/background-jobs/src/Volo.Abp.BackgroundJobs.MongoDB/Volo/Abp/BackgroundJobs/MongoDB/BackgroundJobsMongoDbContextExtensions.cs +++ b/modules/background-jobs/src/Volo.Abp.BackgroundJobs.MongoDB/Volo/Abp/BackgroundJobs/MongoDB/BackgroundJobsMongoDbContextExtensions.cs @@ -11,7 +11,9 @@ namespace Volo.Abp.BackgroundJobs.MongoDB { Check.NotNull(builder, nameof(builder)); - var options = new BackgroundJobsMongoModelBuilderConfigurationOptions(); + var options = new BackgroundJobsMongoModelBuilderConfigurationOptions( + BackgroundJobsDbProperties.DbTablePrefix + ); optionsAction?.Invoke(options); diff --git a/modules/background-jobs/src/Volo.Abp.BackgroundJobs.MongoDB/Volo/Abp/BackgroundJobs/MongoDB/BackgroundJobsMongoModelBuilderConfigurationOptions.cs b/modules/background-jobs/src/Volo.Abp.BackgroundJobs.MongoDB/Volo/Abp/BackgroundJobs/MongoDB/BackgroundJobsMongoModelBuilderConfigurationOptions.cs index 1dfa33ed69..3833841b9f 100644 --- a/modules/background-jobs/src/Volo.Abp.BackgroundJobs.MongoDB/Volo/Abp/BackgroundJobs/MongoDB/BackgroundJobsMongoModelBuilderConfigurationOptions.cs +++ b/modules/background-jobs/src/Volo.Abp.BackgroundJobs.MongoDB/Volo/Abp/BackgroundJobs/MongoDB/BackgroundJobsMongoModelBuilderConfigurationOptions.cs @@ -6,8 +6,8 @@ namespace Volo.Abp.BackgroundJobs.MongoDB public class BackgroundJobsMongoModelBuilderConfigurationOptions : MongoModelBuilderConfigurationOptions { public BackgroundJobsMongoModelBuilderConfigurationOptions( - [NotNull] string tablePrefix = BackgroundJobsConsts.DefaultDbTablePrefix) - : base(tablePrefix) + [NotNull] string collectionPrefix = "") + : base(collectionPrefix) { } } diff --git a/modules/background-jobs/src/Volo.Abp.BackgroundJobs.MongoDB/Volo/Abp/BackgroundJobs/MongoDB/IBackgroundJobsMongoDbContext.cs b/modules/background-jobs/src/Volo.Abp.BackgroundJobs.MongoDB/Volo/Abp/BackgroundJobs/MongoDB/IBackgroundJobsMongoDbContext.cs index e771c3461a..8e2d11869d 100644 --- a/modules/background-jobs/src/Volo.Abp.BackgroundJobs.MongoDB/Volo/Abp/BackgroundJobs/MongoDB/IBackgroundJobsMongoDbContext.cs +++ b/modules/background-jobs/src/Volo.Abp.BackgroundJobs.MongoDB/Volo/Abp/BackgroundJobs/MongoDB/IBackgroundJobsMongoDbContext.cs @@ -4,7 +4,7 @@ using Volo.Abp.MongoDB; namespace Volo.Abp.BackgroundJobs.MongoDB { - [ConnectionStringName(BackgroundJobsConsts.ConnectionStringName)] + [ConnectionStringName(BackgroundJobsDbProperties.ConnectionStringName)] public interface IBackgroundJobsMongoDbContext : IAbpMongoDbContext { IMongoCollection BackgroundJobs { get; }