From 339ca7f717e4a785651216a070e138024f107e18 Mon Sep 17 00:00:00 2001 From: Philippe Date: Wed, 1 May 2019 22:03:15 +0200 Subject: [PATCH] Multi provider support for EF (SQL and Sqlite) - Do not add the DbContext in DataAccess.EF any more - Add projects for MsSql and Sqlite which add the DbContext - Use the config value Database.Provider to determine which provider will be added - Delete all existing migrations - Generate migrations for each provider separately - Manually add trigger creation for concurrent modifications with the BaseEntity.Version field to Sqlite migration (https://github.com/aspnet/EntityFrameworkCore/issues/12260#issuecomment-395509124) - Use Sqlite for integration and api tests --- .../20190501062329_Initial.Designer.cs} | 10 +- .../Migrations/20190501062329_Initial.cs} | 80 ++- .../TeamTunerContextMsSqlModelSnapshot.cs} | 8 +- ....Infrastructure.DataAccess.EF.MsSql.csproj | 16 + .../StartupRegistrator.cs | 40 ++ .../TeamTunerContextMsSql.cs | 22 + .../20190501061552_Initial.Designer.cs} | 17 +- .../Migrations/20190501061552_Initial.cs | 561 ++++++++++++++++++ .../TeamTunerContextSqliteModelSnapshot.cs} | 23 +- ...Infrastructure.DataAccess.EF.Sqlite.csproj | 16 + .../StartupRegistrator.cs | 40 ++ .../TeamTunerContextSqlite.cs | 22 + .../Config/DatabaseConfig.cs | 7 +- .../Config/SeedMode.cs | 2 +- .../Extensions/ServiceProviderExtensions.cs | 2 +- .../20190408110255_Initial.Designer.cs | 398 ------------- ...0190412140837_SoftDeleteFilter.Designer.cs | 402 ------------- .../20190412140837_SoftDeleteFilter.cs | 97 --- ...190413070900_OptimisticLocking.Designer.cs | 426 ------------- .../20190413070900_OptimisticLocking.cs | 94 --- ...20190414081444_TeamJoinRequest.Designer.cs | 482 --------------- .../20190414081444_TeamJoinRequest.cs | 65 -- .../Migrations/20190420130358_Membership.cs | 116 ---- .../20190422085433_UniqueCardLevel.cs | 33 -- .../20190430123341_UserProfileVisibility.cs | 23 - ...mTuner.Infrastructure.DataAccess.EF.csproj | 7 +- .../StartupRegistrator.cs | 9 - .../TeamTunerContext.EntityConfigurations.cs | 3 +- .../TeamTunerContext.cs | 9 +- Backend/Sppd.TeamTuner.sln | 13 + Backend/Sppd.TeamTuner.sln.DotSettings | 3 + .../Sppd.TeamTuner/Config/appsettings.json | 7 +- Backend/Sppd.TeamTuner/Sppd.TeamTuner.csproj | 2 + .../Config/appsettings.json | 3 +- ...ppd.TeamTuner.Tests.Integration.Api.csproj | 2 + .../Config/appsettings.json | 3 +- .../RepositoryTestsBase.cs | 12 +- .../Sppd.TeamTuner.Tests.Integration.csproj | 2 + 38 files changed, 872 insertions(+), 2205 deletions(-) rename Backend/{Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190430123341_UserProfileVisibility.Designer.cs => Sppd.TeamTuner.Infrastructure.DataAccess.EF.MsSql/Migrations/20190501062329_Initial.Designer.cs} (98%) rename Backend/{Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190408110255_Initial.cs => Sppd.TeamTuner.Infrastructure.DataAccess.EF.MsSql/Migrations/20190501062329_Initial.cs} (79%) rename Backend/{Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/TeamTunerContextModelSnapshot.cs => Sppd.TeamTuner.Infrastructure.DataAccess.EF.MsSql/Migrations/TeamTunerContextMsSqlModelSnapshot.cs} (98%) create mode 100644 Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF.MsSql/Sppd.TeamTuner.Infrastructure.DataAccess.EF.MsSql.csproj create mode 100644 Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF.MsSql/StartupRegistrator.cs create mode 100644 Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF.MsSql/TeamTunerContextMsSql.cs rename Backend/{Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190422085433_UniqueCardLevel.Designer.cs => Sppd.TeamTuner.Infrastructure.DataAccess.EF.Sqlite/Migrations/20190501061552_Initial.Designer.cs} (96%) create mode 100644 Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF.Sqlite/Migrations/20190501061552_Initial.cs rename Backend/{Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190420130358_Membership.Designer.cs => Sppd.TeamTuner.Infrastructure.DataAccess.EF.Sqlite/Migrations/TeamTunerContextSqliteModelSnapshot.cs} (95%) create mode 100644 Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF.Sqlite/Sppd.TeamTuner.Infrastructure.DataAccess.EF.Sqlite.csproj create mode 100644 Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF.Sqlite/StartupRegistrator.cs create mode 100644 Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF.Sqlite/TeamTunerContextSqlite.cs delete mode 100644 Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190408110255_Initial.Designer.cs delete mode 100644 Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190412140837_SoftDeleteFilter.Designer.cs delete mode 100644 Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190412140837_SoftDeleteFilter.cs delete mode 100644 Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190413070900_OptimisticLocking.Designer.cs delete mode 100644 Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190413070900_OptimisticLocking.cs delete mode 100644 Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190414081444_TeamJoinRequest.Designer.cs delete mode 100644 Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190414081444_TeamJoinRequest.cs delete mode 100644 Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190420130358_Membership.cs delete mode 100644 Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190422085433_UniqueCardLevel.cs delete mode 100644 Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190430123341_UserProfileVisibility.cs diff --git a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190430123341_UserProfileVisibility.Designer.cs b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF.MsSql/Migrations/20190501062329_Initial.Designer.cs similarity index 98% rename from Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190430123341_UserProfileVisibility.Designer.cs rename to Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF.MsSql/Migrations/20190501062329_Initial.Designer.cs index b7ef07b..a0b8dde 100644 --- a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190430123341_UserProfileVisibility.Designer.cs +++ b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF.MsSql/Migrations/20190501062329_Initial.Designer.cs @@ -5,13 +5,13 @@ using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Sppd.TeamTuner.Infrastructure.DataAccess.EF; +using Sppd.TeamTuner.Infrastructure.DataAccess.EF.MsSql; -namespace Sppd.TeamTuner.Infrastructure.DataAccess.EF.Migrations +namespace Sppd.TeamTuner.Infrastructure.DataAccess.EF.MsSql.Migrations { - [DbContext(typeof(TeamTunerContext))] - [Migration("20190430123341_UserProfileVisibility")] - partial class UserProfileVisibility + [DbContext(typeof(TeamTunerContextMsSql))] + [Migration("20190501062329_Initial")] + partial class Initial { protected override void BuildTargetModel(ModelBuilder modelBuilder) { diff --git a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190408110255_Initial.cs b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF.MsSql/Migrations/20190501062329_Initial.cs similarity index 79% rename from Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190408110255_Initial.cs rename to Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF.MsSql/Migrations/20190501062329_Initial.cs index cab7dab..c993b46 100644 --- a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190408110255_Initial.cs +++ b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF.MsSql/Migrations/20190501062329_Initial.cs @@ -1,7 +1,7 @@ using System; using Microsoft.EntityFrameworkCore.Migrations; -namespace Sppd.TeamTuner.Infrastructure.DataAccess.EF.Migrations +namespace Sppd.TeamTuner.Infrastructure.DataAccess.EF.MsSql.Migrations { public partial class Initial : Migration { @@ -19,6 +19,7 @@ protected override void Up(MigrationBuilder migrationBuilder) IsDeleted = table.Column(nullable: false), DeletedOnUtc = table.Column(nullable: true), DeletedById = table.Column(nullable: true), + Version = table.Column(rowVersion: true, nullable: true), Name = table.Column(maxLength: 50, nullable: false) }, constraints: table => @@ -38,6 +39,7 @@ protected override void Up(MigrationBuilder migrationBuilder) IsDeleted = table.Column(nullable: false), DeletedOnUtc = table.Column(nullable: true), DeletedById = table.Column(nullable: true), + Version = table.Column(rowVersion: true, nullable: true), Name = table.Column(maxLength: 50, nullable: false), Avatar = table.Column(nullable: true), Description = table.Column(maxLength: 2000, nullable: true) @@ -59,6 +61,7 @@ protected override void Up(MigrationBuilder migrationBuilder) IsDeleted = table.Column(nullable: false), DeletedOnUtc = table.Column(nullable: true), DeletedById = table.Column(nullable: true), + Version = table.Column(rowVersion: true, nullable: true), Name = table.Column(maxLength: 50, nullable: false), FriendlyLevel = table.Column(nullable: false) }, @@ -79,6 +82,7 @@ protected override void Up(MigrationBuilder migrationBuilder) IsDeleted = table.Column(nullable: false), DeletedOnUtc = table.Column(nullable: true), DeletedById = table.Column(nullable: true), + Version = table.Column(rowVersion: true, nullable: true), Name = table.Column(maxLength: 50, nullable: false) }, constraints: table => @@ -98,6 +102,7 @@ protected override void Up(MigrationBuilder migrationBuilder) IsDeleted = table.Column(nullable: false), DeletedOnUtc = table.Column(nullable: true), DeletedById = table.Column(nullable: true), + Version = table.Column(rowVersion: true, nullable: true), Name = table.Column(maxLength: 50, nullable: false), Avatar = table.Column(nullable: true), Description = table.Column(maxLength: 2000, nullable: true), @@ -126,6 +131,7 @@ protected override void Up(MigrationBuilder migrationBuilder) IsDeleted = table.Column(nullable: false), DeletedOnUtc = table.Column(nullable: true), DeletedById = table.Column(nullable: true), + Version = table.Column(rowVersion: true, nullable: true), Name = table.Column(maxLength: 50, nullable: false), FriendlyName = table.Column(maxLength: 10, nullable: false), ExternalId = table.Column(nullable: false), @@ -168,9 +174,11 @@ protected override void Up(MigrationBuilder migrationBuilder) IsDeleted = table.Column(nullable: false), DeletedOnUtc = table.Column(nullable: true), DeletedById = table.Column(nullable: true), + Version = table.Column(rowVersion: true, nullable: true), Name = table.Column(maxLength: 50, nullable: false), Avatar = table.Column(nullable: true), Description = table.Column(maxLength: 2000, nullable: true), + ProfileVisibility = table.Column(nullable: false), SppdName = table.Column(maxLength: 50, nullable: false), PasswordHash = table.Column(maxLength: 64, nullable: false), PasswordSalt = table.Column(maxLength: 128, nullable: false), @@ -210,6 +218,7 @@ protected override void Up(MigrationBuilder migrationBuilder) IsDeleted = table.Column(nullable: false), DeletedOnUtc = table.Column(nullable: true), DeletedById = table.Column(nullable: true), + Version = table.Column(rowVersion: true, nullable: true), CardId = table.Column(nullable: false), UserId = table.Column(nullable: false), Level = table.Column(nullable: false) @@ -231,11 +240,46 @@ protected override void Up(MigrationBuilder migrationBuilder) onDelete: ReferentialAction.Cascade); }); + migrationBuilder.CreateTable( + name: "TeamMembershipRequest", + columns: table => new + { + Id = table.Column(nullable: false), + CreatedOnUtc = table.Column(nullable: false), + CreatedById = table.Column(nullable: false), + ModifiedOnUtc = table.Column(nullable: false), + ModifiedById = table.Column(nullable: false), + IsDeleted = table.Column(nullable: false), + DeletedOnUtc = table.Column(nullable: true), + DeletedById = table.Column(nullable: true), + Version = table.Column(rowVersion: true, nullable: true), + TeamId = table.Column(nullable: false), + UserId = table.Column(nullable: false), + Comment = table.Column(maxLength: 500, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_TeamMembershipRequest", x => x.Id); + table.ForeignKey( + name: "FK_TeamMembershipRequest_Team_TeamId", + column: x => x.TeamId, + principalTable: "Team", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_TeamMembershipRequest_TeamTunerUser_UserId", + column: x => x.UserId, + principalTable: "TeamTunerUser", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + migrationBuilder.CreateIndex( name: "IX_Card_ExternalId", table: "Card", column: "ExternalId", - unique: true); + unique: true, + filter: "[IsDeleted] = 0"); migrationBuilder.CreateIndex( name: "IX_Card_RarityId", @@ -258,20 +302,37 @@ protected override void Up(MigrationBuilder migrationBuilder) column: "CardId"); migrationBuilder.CreateIndex( - name: "IX_CardLevel_UserId", + name: "IX_CardLevel_UserId_CardId", table: "CardLevel", - column: "UserId"); + columns: new[] { "UserId", "CardId" }, + unique: true, + filter: "[IsDeleted] = 0"); migrationBuilder.CreateIndex( name: "IX_Team_FederationId", table: "Team", column: "FederationId"); + migrationBuilder.CreateIndex( + name: "IX_TeamMembershipRequest_TeamId", + table: "TeamMembershipRequest", + column: "TeamId", + unique: true, + filter: "[IsDeleted] = 0"); + + migrationBuilder.CreateIndex( + name: "IX_TeamMembershipRequest_UserId", + table: "TeamMembershipRequest", + column: "UserId", + unique: true, + filter: "[IsDeleted] = 0"); + migrationBuilder.CreateIndex( name: "IX_TeamTunerUser_Email", table: "TeamTunerUser", column: "Email", - unique: true); + unique: true, + filter: "[IsDeleted] = 0"); migrationBuilder.CreateIndex( name: "IX_TeamTunerUser_FederationId", @@ -282,13 +343,15 @@ protected override void Up(MigrationBuilder migrationBuilder) name: "IX_TeamTunerUser_Name", table: "TeamTunerUser", column: "Name", - unique: true); + unique: true, + filter: "[IsDeleted] = 0"); migrationBuilder.CreateIndex( name: "IX_TeamTunerUser_SppdName", table: "TeamTunerUser", column: "SppdName", - unique: true); + unique: true, + filter: "[IsDeleted] = 0"); migrationBuilder.CreateIndex( name: "IX_TeamTunerUser_TeamId", @@ -301,6 +364,9 @@ protected override void Down(MigrationBuilder migrationBuilder) migrationBuilder.DropTable( name: "CardLevel"); + migrationBuilder.DropTable( + name: "TeamMembershipRequest"); + migrationBuilder.DropTable( name: "Card"); diff --git a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/TeamTunerContextModelSnapshot.cs b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF.MsSql/Migrations/TeamTunerContextMsSqlModelSnapshot.cs similarity index 98% rename from Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/TeamTunerContextModelSnapshot.cs rename to Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF.MsSql/Migrations/TeamTunerContextMsSqlModelSnapshot.cs index a7c641a..6109380 100644 --- a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/TeamTunerContextModelSnapshot.cs +++ b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF.MsSql/Migrations/TeamTunerContextMsSqlModelSnapshot.cs @@ -4,12 +4,12 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Sppd.TeamTuner.Infrastructure.DataAccess.EF; +using Sppd.TeamTuner.Infrastructure.DataAccess.EF.MsSql; -namespace Sppd.TeamTuner.Infrastructure.DataAccess.EF.Migrations +namespace Sppd.TeamTuner.Infrastructure.DataAccess.EF.MsSql.Migrations { - [DbContext(typeof(TeamTunerContext))] - partial class TeamTunerContextModelSnapshot : ModelSnapshot + [DbContext(typeof(TeamTunerContextMsSql))] + partial class TeamTunerContextMsSqlModelSnapshot : ModelSnapshot { protected override void BuildModel(ModelBuilder modelBuilder) { diff --git a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF.MsSql/Sppd.TeamTuner.Infrastructure.DataAccess.EF.MsSql.csproj b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF.MsSql/Sppd.TeamTuner.Infrastructure.DataAccess.EF.MsSql.csproj new file mode 100644 index 0000000..8726e28 --- /dev/null +++ b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF.MsSql/Sppd.TeamTuner.Infrastructure.DataAccess.EF.MsSql.csproj @@ -0,0 +1,16 @@ + + + + netstandard2.0 + + + + + + + + + + + + diff --git a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF.MsSql/StartupRegistrator.cs b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF.MsSql/StartupRegistrator.cs new file mode 100644 index 0000000..00746e0 --- /dev/null +++ b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF.MsSql/StartupRegistrator.cs @@ -0,0 +1,40 @@ +using System; + +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; + +using Sppd.TeamTuner.Core; +using Sppd.TeamTuner.Core.Services; +using Sppd.TeamTuner.Core.Utils.Extensions; +using Sppd.TeamTuner.Infrastructure.DataAccess.EF.Config; + +namespace Sppd.TeamTuner.Infrastructure.DataAccess.EF.MsSql +{ + public class StartupRegistrator : IStartupRegistrator + { + private const string PROVIDER_NAME = "MsSql"; + private const string ID_PLACEHOLDER = "{id}"; + + public int Priority => 90; + + public void Register(IServiceCollection services) + { + var databaseConfig = services.BuildServiceProvider().GetConfig(); + + if (PROVIDER_NAME.Equals(databaseConfig.Provider, StringComparison.InvariantCultureIgnoreCase)) + { + // Add a random string if the {id} specifier is contained in the connection string + var dbId = Guid.NewGuid().ToString("n").Substring(0, 8); + databaseConfig.ConnectionString = databaseConfig.ConnectionString.Replace(ID_PLACEHOLDER, dbId); + + services.AddDbContext(options => options.UseSqlServer(databaseConfig.ConnectionString)) + .AddScoped() + .AddScoped(); + } + } + + public void Configure(IServiceProvider serviceProvider) + { + } + } +} \ No newline at end of file diff --git a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF.MsSql/TeamTunerContextMsSql.cs b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF.MsSql/TeamTunerContextMsSql.cs new file mode 100644 index 0000000..89d2355 --- /dev/null +++ b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF.MsSql/TeamTunerContextMsSql.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; + +using Microsoft.EntityFrameworkCore; + +using Sppd.TeamTuner.Core.Domain.Interfaces; +using Sppd.TeamTuner.Core.Services; + +namespace Sppd.TeamTuner.Infrastructure.DataAccess.EF.MsSql +{ + /// + /// Extends to allow managing migrations in the project. + /// + /// + internal class TeamTunerContextMsSql : TeamTunerContext + { + public TeamTunerContextMsSql(DbContextOptions options, Lazy validationService, IEnumerable> entityMetadataProviders) + : base(options, validationService, entityMetadataProviders) + { + } + } +} \ No newline at end of file diff --git a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190422085433_UniqueCardLevel.Designer.cs b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF.Sqlite/Migrations/20190501061552_Initial.Designer.cs similarity index 96% rename from Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190422085433_UniqueCardLevel.Designer.cs rename to Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF.Sqlite/Migrations/20190501061552_Initial.Designer.cs index b49304c..7a64236 100644 --- a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190422085433_UniqueCardLevel.Designer.cs +++ b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF.Sqlite/Migrations/20190501061552_Initial.Designer.cs @@ -2,24 +2,21 @@ using System; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Sppd.TeamTuner.Infrastructure.DataAccess.EF; +using Sppd.TeamTuner.Infrastructure.DataAccess.EF.Sqlite; -namespace Sppd.TeamTuner.Infrastructure.DataAccess.EF.Migrations +namespace Sppd.TeamTuner.Infrastructure.DataAccess.EF.Sqlite.Migrations { - [DbContext(typeof(TeamTunerContext))] - [Migration("20190422085433_UniqueCardLevel")] - partial class UniqueCardLevel + [DbContext(typeof(TeamTunerContextSqlite))] + [Migration("20190501061552_Initial")] + partial class Initial { protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "2.2.4-servicing-10062") - .HasAnnotation("Relational:MaxIdentifierLength", 128) - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + .HasAnnotation("ProductVersion", "2.2.4-servicing-10062"); modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.Card", b => { @@ -351,6 +348,8 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .IsRequired() .HasMaxLength(128); + b.Property("ProfileVisibility"); + b.Property("SppdName") .IsRequired() .HasMaxLength(50); diff --git a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF.Sqlite/Migrations/20190501061552_Initial.cs b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF.Sqlite/Migrations/20190501061552_Initial.cs new file mode 100644 index 0000000..c968c39 --- /dev/null +++ b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF.Sqlite/Migrations/20190501061552_Initial.cs @@ -0,0 +1,561 @@ +using System; + +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Sppd.TeamTuner.Infrastructure.DataAccess.EF.Sqlite.Migrations +{ + public partial class Initial : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + "CardType", + table => new + { + Id = table.Column(nullable: false), + CreatedOnUtc = table.Column(nullable: false), + CreatedById = table.Column(nullable: false), + ModifiedOnUtc = table.Column(nullable: false), + ModifiedById = table.Column(nullable: false), + IsDeleted = table.Column(nullable: false), + DeletedOnUtc = table.Column(nullable: true), + DeletedById = table.Column(nullable: true), + Version = table.Column(rowVersion: true, nullable: true), + Name = table.Column(maxLength: 50, nullable: false) + }, + constraints: table => { table.PrimaryKey("PK_CardType", x => x.Id); }); + + migrationBuilder.CreateTable( + "Federation", + table => new + { + Id = table.Column(nullable: false), + CreatedOnUtc = table.Column(nullable: false), + CreatedById = table.Column(nullable: false), + ModifiedOnUtc = table.Column(nullable: false), + ModifiedById = table.Column(nullable: false), + IsDeleted = table.Column(nullable: false), + DeletedOnUtc = table.Column(nullable: true), + DeletedById = table.Column(nullable: true), + Version = table.Column(rowVersion: true, nullable: true), + Name = table.Column(maxLength: 50, nullable: false), + Avatar = table.Column(nullable: true), + Description = table.Column(maxLength: 2000, nullable: true) + }, + constraints: table => { table.PrimaryKey("PK_Federation", x => x.Id); }); + + migrationBuilder.CreateTable( + "Rarity", + table => new + { + Id = table.Column(nullable: false), + CreatedOnUtc = table.Column(nullable: false), + CreatedById = table.Column(nullable: false), + ModifiedOnUtc = table.Column(nullable: false), + ModifiedById = table.Column(nullable: false), + IsDeleted = table.Column(nullable: false), + DeletedOnUtc = table.Column(nullable: true), + DeletedById = table.Column(nullable: true), + Version = table.Column(rowVersion: true, nullable: true), + Name = table.Column(maxLength: 50, nullable: false), + FriendlyLevel = table.Column(nullable: false) + }, + constraints: table => { table.PrimaryKey("PK_Rarity", x => x.Id); }); + + migrationBuilder.CreateTable( + "Theme", + table => new + { + Id = table.Column(nullable: false), + CreatedOnUtc = table.Column(nullable: false), + CreatedById = table.Column(nullable: false), + ModifiedOnUtc = table.Column(nullable: false), + ModifiedById = table.Column(nullable: false), + IsDeleted = table.Column(nullable: false), + DeletedOnUtc = table.Column(nullable: true), + DeletedById = table.Column(nullable: true), + Version = table.Column(rowVersion: true, nullable: true), + Name = table.Column(maxLength: 50, nullable: false) + }, + constraints: table => { table.PrimaryKey("PK_Theme", x => x.Id); }); + + migrationBuilder.CreateTable( + "Team", + table => new + { + Id = table.Column(nullable: false), + CreatedOnUtc = table.Column(nullable: false), + CreatedById = table.Column(nullable: false), + ModifiedOnUtc = table.Column(nullable: false), + ModifiedById = table.Column(nullable: false), + IsDeleted = table.Column(nullable: false), + DeletedOnUtc = table.Column(nullable: true), + DeletedById = table.Column(nullable: true), + Version = table.Column(rowVersion: true, nullable: true), + Name = table.Column(maxLength: 50, nullable: false), + Avatar = table.Column(nullable: true), + Description = table.Column(maxLength: 2000, nullable: true), + FederationId = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Team", x => x.Id); + table.ForeignKey( + "FK_Team_Federation_FederationId", + x => x.FederationId, + "Federation", + "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + "Card", + table => new + { + Id = table.Column(nullable: false), + CreatedOnUtc = table.Column(nullable: false), + CreatedById = table.Column(nullable: false), + ModifiedOnUtc = table.Column(nullable: false), + ModifiedById = table.Column(nullable: false), + IsDeleted = table.Column(nullable: false), + DeletedOnUtc = table.Column(nullable: true), + DeletedById = table.Column(nullable: true), + Version = table.Column(rowVersion: true, nullable: true), + Name = table.Column(maxLength: 50, nullable: false), + FriendlyName = table.Column(maxLength: 10, nullable: false), + ExternalId = table.Column(nullable: false), + ThemeId = table.Column(nullable: false), + RarityId = table.Column(nullable: false), + TypeId = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Card", x => x.Id); + table.ForeignKey( + "FK_Card_Rarity_RarityId", + x => x.RarityId, + "Rarity", + "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + "FK_Card_Theme_ThemeId", + x => x.ThemeId, + "Theme", + "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + "FK_Card_CardType_TypeId", + x => x.TypeId, + "CardType", + "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + "TeamTunerUser", + table => new + { + Id = table.Column(nullable: false), + CreatedOnUtc = table.Column(nullable: false), + CreatedById = table.Column(nullable: false), + ModifiedOnUtc = table.Column(nullable: false), + ModifiedById = table.Column(nullable: false), + IsDeleted = table.Column(nullable: false), + DeletedOnUtc = table.Column(nullable: true), + DeletedById = table.Column(nullable: true), + Version = table.Column(rowVersion: true, nullable: true), + Name = table.Column(maxLength: 50, nullable: false), + Avatar = table.Column(nullable: true), + Description = table.Column(maxLength: 2000, nullable: true), + ProfileVisibility = table.Column(nullable: false), + SppdName = table.Column(maxLength: 50, nullable: false), + PasswordHash = table.Column(maxLength: 64, nullable: false), + PasswordSalt = table.Column(maxLength: 128, nullable: false), + Email = table.Column(maxLength: 200, nullable: false), + ApplicationRole = table.Column(maxLength: 20, nullable: false), + TeamId = table.Column(nullable: true), + TeamRole = table.Column(maxLength: 20, nullable: true), + FederationId = table.Column(nullable: true), + FederationRole = table.Column(maxLength: 20, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_TeamTunerUser", x => x.Id); + table.ForeignKey( + "FK_TeamTunerUser_Federation_FederationId", + x => x.FederationId, + "Federation", + "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + "FK_TeamTunerUser_Team_TeamId", + x => x.TeamId, + "Team", + "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + "CardLevel", + table => new + { + Id = table.Column(nullable: false), + CreatedOnUtc = table.Column(nullable: false), + CreatedById = table.Column(nullable: false), + ModifiedOnUtc = table.Column(nullable: false), + ModifiedById = table.Column(nullable: false), + IsDeleted = table.Column(nullable: false), + DeletedOnUtc = table.Column(nullable: true), + DeletedById = table.Column(nullable: true), + Version = table.Column(rowVersion: true, nullable: true), + CardId = table.Column(nullable: false), + UserId = table.Column(nullable: false), + Level = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_CardLevel", x => x.Id); + table.ForeignKey( + "FK_CardLevel_Card_CardId", + x => x.CardId, + "Card", + "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + "FK_CardLevel_TeamTunerUser_UserId", + x => x.UserId, + "TeamTunerUser", + "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + "TeamMembershipRequest", + table => new + { + Id = table.Column(nullable: false), + CreatedOnUtc = table.Column(nullable: false), + CreatedById = table.Column(nullable: false), + ModifiedOnUtc = table.Column(nullable: false), + ModifiedById = table.Column(nullable: false), + IsDeleted = table.Column(nullable: false), + DeletedOnUtc = table.Column(nullable: true), + DeletedById = table.Column(nullable: true), + Version = table.Column(rowVersion: true, nullable: true), + TeamId = table.Column(nullable: false), + UserId = table.Column(nullable: false), + Comment = table.Column(maxLength: 500, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_TeamMembershipRequest", x => x.Id); + table.ForeignKey( + "FK_TeamMembershipRequest_Team_TeamId", + x => x.TeamId, + "Team", + "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + "FK_TeamMembershipRequest_TeamTunerUser_UserId", + x => x.UserId, + "TeamTunerUser", + "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + "IX_Card_ExternalId", + "Card", + "ExternalId", + unique: true, + filter: "[IsDeleted] = 0"); + + migrationBuilder.CreateIndex( + "IX_Card_RarityId", + "Card", + "RarityId"); + + migrationBuilder.CreateIndex( + "IX_Card_ThemeId", + "Card", + "ThemeId"); + + migrationBuilder.CreateIndex( + "IX_Card_TypeId", + "Card", + "TypeId"); + + migrationBuilder.CreateIndex( + "IX_CardLevel_CardId", + "CardLevel", + "CardId"); + + migrationBuilder.CreateIndex( + "IX_CardLevel_UserId_CardId", + "CardLevel", + new[] {"UserId", "CardId"}, + unique: true, + filter: "[IsDeleted] = 0"); + + migrationBuilder.CreateIndex( + "IX_Team_FederationId", + "Team", + "FederationId"); + + migrationBuilder.CreateIndex( + "IX_TeamMembershipRequest_TeamId", + "TeamMembershipRequest", + "TeamId", + unique: true, + filter: "[IsDeleted] = 0"); + + migrationBuilder.CreateIndex( + "IX_TeamMembershipRequest_UserId", + "TeamMembershipRequest", + "UserId", + unique: true, + filter: "[IsDeleted] = 0"); + + migrationBuilder.CreateIndex( + "IX_TeamTunerUser_Email", + "TeamTunerUser", + "Email", + unique: true, + filter: "[IsDeleted] = 0"); + + migrationBuilder.CreateIndex( + "IX_TeamTunerUser_FederationId", + "TeamTunerUser", + "FederationId"); + + migrationBuilder.CreateIndex( + "IX_TeamTunerUser_Name", + "TeamTunerUser", + "Name", + unique: true, + filter: "[IsDeleted] = 0"); + + migrationBuilder.CreateIndex( + "IX_TeamTunerUser_SppdName", + "TeamTunerUser", + "SppdName", + unique: true, + filter: "[IsDeleted] = 0"); + + migrationBuilder.CreateIndex( + "IX_TeamTunerUser_TeamId", + "TeamTunerUser", + "TeamId"); + + #region Manual additions + + migrationBuilder.Sql( + @"CREATE TRIGGER SetCardVersionOnUpdate + AFTER UPDATE ON Card + BEGIN + UPDATE Card + SET Version = randomblob(8) + WHERE rowid = NEW.rowid; + END"); + migrationBuilder.Sql( + @"CREATE TRIGGER SetCardVersionOnInsert + AFTER INSERT ON Card + BEGIN + UPDATE Card + SET Version = randomblob(8) + WHERE rowid = NEW.rowid; + END"); + + migrationBuilder.Sql( + @"CREATE TRIGGER SetCardLevelVersionOnUpdate + AFTER UPDATE ON CardLevel + BEGIN + UPDATE CardLevel + SET Version = randomblob(8) + WHERE rowid = NEW.rowid; + END"); + migrationBuilder.Sql( + @"CREATE TRIGGER SetCardLevelVersionOnInsert + AFTER INSERT ON CardLevel + BEGIN + UPDATE CardLevel + SET Version = randomblob(8) + WHERE rowid = NEW.rowid; + END"); + + migrationBuilder.Sql( + @"CREATE TRIGGER SetCardTypeVersionOnUpdate + AFTER UPDATE ON CardType + BEGIN + UPDATE CardType + SET Version = randomblob(8) + WHERE rowid = NEW.rowid; + END"); + migrationBuilder.Sql( + @"CREATE TRIGGER SetCardTypeVersionOnInsert + AFTER INSERT ON CardType + BEGIN + UPDATE CardType + SET Version = randomblob(8) + WHERE rowid = NEW.rowid; + END"); + + migrationBuilder.Sql( + @"CREATE TRIGGER SetFederationVersionOnUpdate + AFTER UPDATE ON Federation + BEGIN + UPDATE Federation + SET Version = randomblob(8) + WHERE rowid = NEW.rowid; + END"); + migrationBuilder.Sql( + @"CREATE TRIGGER SetFederationVersionOnInsert + AFTER INSERT ON Federation + BEGIN + UPDATE Federation + SET Version = randomblob(8) + WHERE rowid = NEW.rowid; + END"); + + migrationBuilder.Sql( + @"CREATE TRIGGER SetRarityVersionOnUpdate + AFTER UPDATE ON Rarity + BEGIN + UPDATE Rarity + SET Version = randomblob(8) + WHERE rowid = NEW.rowid; + END"); + migrationBuilder.Sql( + @"CREATE TRIGGER SetRarityVersionOnInsert + AFTER INSERT ON Rarity + BEGIN + UPDATE Rarity + SET Version = randomblob(8) + WHERE rowid = NEW.rowid; + END"); + + migrationBuilder.Sql( + @"CREATE TRIGGER SetTeamVersionOnUpdate + AFTER UPDATE ON Team + BEGIN + UPDATE Team + SET Version = randomblob(8) + WHERE rowid = NEW.rowid; + END"); + migrationBuilder.Sql( + @"CREATE TRIGGER SetTeamVersionOnInsert + AFTER INSERT ON Team + BEGIN + UPDATE Team + SET Version = randomblob(8) + WHERE rowid = NEW.rowid; + END"); + + migrationBuilder.Sql( + @"CREATE TRIGGER SetTeamMembershipRequestVersionOnUpdate + AFTER UPDATE ON TeamMembershipRequest + BEGIN + UPDATE TeamMembershipRequest + SET Version = randomblob(8) + WHERE rowid = NEW.rowid; + END"); + migrationBuilder.Sql( + @"CREATE TRIGGER SetTeamMembershipRequestVersionOnInsert + AFTER INSERT ON TeamMembershipRequest + BEGIN + UPDATE TeamMembershipRequest + SET Version = randomblob(8) + WHERE rowid = NEW.rowid; + END"); + + migrationBuilder.Sql( + @"CREATE TRIGGER SetTeamTunerUserVersionOnUpdate + AFTER UPDATE ON TeamTunerUser + BEGIN + UPDATE TeamTunerUser + SET Version = randomblob(8) + WHERE rowid = NEW.rowid; + END"); + migrationBuilder.Sql( + @"CREATE TRIGGER SetTeamTunerUserVersionOnInsert + AFTER INSERT ON TeamTunerUser + BEGIN + UPDATE TeamTunerUser + SET Version = randomblob(8) + WHERE rowid = NEW.rowid; + END"); + + migrationBuilder.Sql( + @"CREATE TRIGGER SetThemeVersionOnUpdate + AFTER UPDATE ON Theme + BEGIN + UPDATE Theme + SET Version = randomblob(8) + WHERE rowid = NEW.rowid; + END"); + migrationBuilder.Sql( + @"CREATE TRIGGER SetThemeVersionOnInsert + AFTER INSERT ON Theme + BEGIN + UPDATE Theme + SET Version = randomblob(8) + WHERE rowid = NEW.rowid; + END"); + + #endregion + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + #region Manual additions + + migrationBuilder.Sql("DROP TRIGGER SetCardVersionOnUpdate"); + migrationBuilder.Sql("DROP TRIGGER SetCardVersionOnInsert"); + migrationBuilder.Sql("DROP TRIGGER SetCardLevelVersionOnUpdate"); + migrationBuilder.Sql("DROP TRIGGER SetCardLevelVersionOnInsert"); + migrationBuilder.Sql("DROP TRIGGER SetCardTypeVersionOnUpdate"); + migrationBuilder.Sql("DROP TRIGGER SetCardTypeVersionOnInsert"); + migrationBuilder.Sql("DROP TRIGGER SetFederationVersionOnUpdate"); + migrationBuilder.Sql("DROP TRIGGER SetFederationVersionOnInsert"); + migrationBuilder.Sql("DROP TRIGGER SetRarityVersionOnUpdate"); + migrationBuilder.Sql("DROP TRIGGER SetRarityVersionOnInsert"); + migrationBuilder.Sql("DROP TRIGGER SetTeamVersionOnUpdate"); + migrationBuilder.Sql("DROP TRIGGER SetTeamVersionOnInsert"); + migrationBuilder.Sql("DROP TRIGGER SetTeamMembershipRequestVersionOnUpdate"); + migrationBuilder.Sql("DROP TRIGGER SetTeamMembershipRequestVersionOnInsert"); + migrationBuilder.Sql("DROP TRIGGER SetTeamTunerUserVersionOnUpdate"); + migrationBuilder.Sql("DROP TRIGGER SetTeamTunerUserVersionOnInsert"); + migrationBuilder.Sql("DROP TRIGGER SetThemeVersionOnUpdate"); + migrationBuilder.Sql("DROP TRIGGER SetThemeVersionOnInsert"); + + #endregion + + migrationBuilder.DropTable( + "CardLevel"); + + migrationBuilder.DropTable( + "TeamMembershipRequest"); + + migrationBuilder.DropTable( + "Card"); + + migrationBuilder.DropTable( + "TeamTunerUser"); + + migrationBuilder.DropTable( + "Rarity"); + + migrationBuilder.DropTable( + "Theme"); + + migrationBuilder.DropTable( + "CardType"); + + migrationBuilder.DropTable( + "Team"); + + migrationBuilder.DropTable( + "Federation"); + } + } +} \ No newline at end of file diff --git a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190420130358_Membership.Designer.cs b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF.Sqlite/Migrations/TeamTunerContextSqliteModelSnapshot.cs similarity index 95% rename from Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190420130358_Membership.Designer.cs rename to Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF.Sqlite/Migrations/TeamTunerContextSqliteModelSnapshot.cs index 910de04..2164d96 100644 --- a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190420130358_Membership.Designer.cs +++ b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF.Sqlite/Migrations/TeamTunerContextSqliteModelSnapshot.cs @@ -2,24 +2,19 @@ using System; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Sppd.TeamTuner.Infrastructure.DataAccess.EF; +using Sppd.TeamTuner.Infrastructure.DataAccess.EF.Sqlite; -namespace Sppd.TeamTuner.Infrastructure.DataAccess.EF.Migrations +namespace Sppd.TeamTuner.Infrastructure.DataAccess.EF.Sqlite.Migrations { - [DbContext(typeof(TeamTunerContext))] - [Migration("20190420130358_Membership")] - partial class Membership + [DbContext(typeof(TeamTunerContextSqlite))] + partial class TeamTunerContextSqliteModelSnapshot : ModelSnapshot { - protected override void BuildTargetModel(ModelBuilder modelBuilder) + protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "2.2.4-servicing-10062") - .HasAnnotation("Relational:MaxIdentifierLength", 128) - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + .HasAnnotation("ProductVersion", "2.2.4-servicing-10062"); modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.Card", b => { @@ -108,7 +103,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.HasIndex("CardId"); - b.HasIndex("UserId"); + b.HasIndex("UserId", "CardId") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); b.ToTable("CardLevel"); }); @@ -349,6 +346,8 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .IsRequired() .HasMaxLength(128); + b.Property("ProfileVisibility"); + b.Property("SppdName") .IsRequired() .HasMaxLength(50); diff --git a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF.Sqlite/Sppd.TeamTuner.Infrastructure.DataAccess.EF.Sqlite.csproj b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF.Sqlite/Sppd.TeamTuner.Infrastructure.DataAccess.EF.Sqlite.csproj new file mode 100644 index 0000000..6680e01 --- /dev/null +++ b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF.Sqlite/Sppd.TeamTuner.Infrastructure.DataAccess.EF.Sqlite.csproj @@ -0,0 +1,16 @@ + + + + netstandard2.0 + + + + + + + + + + + + diff --git a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF.Sqlite/StartupRegistrator.cs b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF.Sqlite/StartupRegistrator.cs new file mode 100644 index 0000000..ba02298 --- /dev/null +++ b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF.Sqlite/StartupRegistrator.cs @@ -0,0 +1,40 @@ +using System; + +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; + +using Sppd.TeamTuner.Core; +using Sppd.TeamTuner.Core.Services; +using Sppd.TeamTuner.Core.Utils.Extensions; +using Sppd.TeamTuner.Infrastructure.DataAccess.EF.Config; + +namespace Sppd.TeamTuner.Infrastructure.DataAccess.EF.Sqlite +{ + public class StartupRegistrator : IStartupRegistrator + { + private const string PROVIDER_NAME = "Sqlite"; + private const string ID_PLACEHOLDER = "{id}"; + + public int Priority => 90; + + public void Register(IServiceCollection services) + { + var databaseConfig = services.BuildServiceProvider().GetConfig(); + + if (PROVIDER_NAME.Equals(databaseConfig.Provider, StringComparison.InvariantCultureIgnoreCase)) + { + // Add a random string if the {id} specifier is contained in the connection string + var dbId = Guid.NewGuid().ToString("n").Substring(0, 8); + databaseConfig.ConnectionString = databaseConfig.ConnectionString.Replace(ID_PLACEHOLDER, dbId); + + services.AddDbContext(options => options.UseSqlite(databaseConfig.ConnectionString)) + .AddScoped() + .AddScoped(); + } + } + + public void Configure(IServiceProvider serviceProvider) + { + } + } +} \ No newline at end of file diff --git a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF.Sqlite/TeamTunerContextSqlite.cs b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF.Sqlite/TeamTunerContextSqlite.cs new file mode 100644 index 0000000..1c0218a --- /dev/null +++ b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF.Sqlite/TeamTunerContextSqlite.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; + +using Microsoft.EntityFrameworkCore; + +using Sppd.TeamTuner.Core.Domain.Interfaces; +using Sppd.TeamTuner.Core.Services; + +namespace Sppd.TeamTuner.Infrastructure.DataAccess.EF.Sqlite +{ + /// + /// Extends to allow managing migrations in the project. + /// + /// + internal class TeamTunerContextSqlite : TeamTunerContext + { + public TeamTunerContextSqlite(DbContextOptions options, Lazy validationService, IEnumerable> entityMetadataProviders) + : base(options, validationService, entityMetadataProviders) + { + } + } +} \ No newline at end of file diff --git a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Config/DatabaseConfig.cs b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Config/DatabaseConfig.cs index 7d1b2e6..a913289 100644 --- a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Config/DatabaseConfig.cs +++ b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Config/DatabaseConfig.cs @@ -6,8 +6,13 @@ namespace Sppd.TeamTuner.Infrastructure.DataAccess.EF.Config /// Defines configuration properties related to the database /// /// - internal class DatabaseConfig : IConfig + public class DatabaseConfig : IConfig { + /// + /// DB provider to use. + /// + public string Provider { get; set; } = "MsSql"; + /// /// ConnectionString used for database connection. /// diff --git a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Config/SeedMode.cs b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Config/SeedMode.cs index c466ae9..3e43833 100644 --- a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Config/SeedMode.cs +++ b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Config/SeedMode.cs @@ -1,6 +1,6 @@ namespace Sppd.TeamTuner.Infrastructure.DataAccess.EF.Config { - internal enum SeedMode : byte + public enum SeedMode : byte { None = 0, Required = 1, diff --git a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Extensions/ServiceProviderExtensions.cs b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Extensions/ServiceProviderExtensions.cs index b0239e0..e25ee5d 100644 --- a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Extensions/ServiceProviderExtensions.cs +++ b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Extensions/ServiceProviderExtensions.cs @@ -32,7 +32,7 @@ public static void InitializeDatabase(this IServiceProvider serviceProvider) var userProvider = scope.ServiceProvider.GetService(); userProvider.CurrentUser = new SystemUser(); - var context = scope.ServiceProvider.GetRequiredService(); + var context = scope.ServiceProvider.GetService(); if (databaseConfig.DeleteOnStartup) { diff --git a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190408110255_Initial.Designer.cs b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190408110255_Initial.Designer.cs deleted file mode 100644 index 5b46776..0000000 --- a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190408110255_Initial.Designer.cs +++ /dev/null @@ -1,398 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Sppd.TeamTuner.Infrastructure.DataAccess.EF; - -namespace Sppd.TeamTuner.Infrastructure.DataAccess.EF.Migrations -{ - [DbContext(typeof(TeamTunerContext))] - [Migration("20190408110255_Initial")] - partial class Initial - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "2.2.3-servicing-35854") - .HasAnnotation("Relational:MaxIdentifierLength", 128) - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.Card", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("CreatedById"); - - b.Property("CreatedOnUtc"); - - b.Property("DeletedById"); - - b.Property("DeletedOnUtc"); - - b.Property("ExternalId"); - - b.Property("FriendlyName") - .IsRequired() - .HasMaxLength(10); - - b.Property("IsDeleted"); - - b.Property("ModifiedById"); - - b.Property("ModifiedOnUtc") - .IsConcurrencyToken(); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50); - - b.Property("RarityId"); - - b.Property("ThemeId"); - - b.Property("TypeId"); - - b.HasKey("Id"); - - b.HasIndex("ExternalId") - .IsUnique(); - - b.HasIndex("RarityId"); - - b.HasIndex("ThemeId"); - - b.HasIndex("TypeId"); - - b.ToTable("Card"); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.CardLevel", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("CardId"); - - b.Property("CreatedById"); - - b.Property("CreatedOnUtc"); - - b.Property("DeletedById"); - - b.Property("DeletedOnUtc"); - - b.Property("IsDeleted"); - - b.Property("Level"); - - b.Property("ModifiedById"); - - b.Property("ModifiedOnUtc") - .IsConcurrencyToken(); - - b.Property("UserId"); - - b.HasKey("Id"); - - b.HasIndex("CardId"); - - b.HasIndex("UserId"); - - b.ToTable("CardLevel"); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.CardType", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("CreatedById"); - - b.Property("CreatedOnUtc"); - - b.Property("DeletedById"); - - b.Property("DeletedOnUtc"); - - b.Property("IsDeleted"); - - b.Property("ModifiedById"); - - b.Property("ModifiedOnUtc") - .IsConcurrencyToken(); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50); - - b.HasKey("Id"); - - b.ToTable("CardType"); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.Federation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("Avatar"); - - b.Property("CreatedById"); - - b.Property("CreatedOnUtc"); - - b.Property("DeletedById"); - - b.Property("DeletedOnUtc"); - - b.Property("Description") - .HasMaxLength(2000); - - b.Property("IsDeleted"); - - b.Property("ModifiedById"); - - b.Property("ModifiedOnUtc") - .IsConcurrencyToken(); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50); - - b.HasKey("Id"); - - b.ToTable("Federation"); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.Rarity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("CreatedById"); - - b.Property("CreatedOnUtc"); - - b.Property("DeletedById"); - - b.Property("DeletedOnUtc"); - - b.Property("FriendlyLevel"); - - b.Property("IsDeleted"); - - b.Property("ModifiedById"); - - b.Property("ModifiedOnUtc") - .IsConcurrencyToken(); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50); - - b.HasKey("Id"); - - b.ToTable("Rarity"); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.Team", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("Avatar"); - - b.Property("CreatedById"); - - b.Property("CreatedOnUtc"); - - b.Property("DeletedById"); - - b.Property("DeletedOnUtc"); - - b.Property("Description") - .HasMaxLength(2000); - - b.Property("FederationId"); - - b.Property("IsDeleted"); - - b.Property("ModifiedById"); - - b.Property("ModifiedOnUtc") - .IsConcurrencyToken(); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50); - - b.HasKey("Id"); - - b.HasIndex("FederationId"); - - b.ToTable("Team"); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.TeamTunerUser", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("ApplicationRole") - .IsRequired() - .HasMaxLength(20); - - b.Property("Avatar"); - - b.Property("CreatedById"); - - b.Property("CreatedOnUtc"); - - b.Property("DeletedById"); - - b.Property("DeletedOnUtc"); - - b.Property("Description") - .HasMaxLength(2000); - - b.Property("Email") - .IsRequired() - .HasMaxLength(200); - - b.Property("FederationId"); - - b.Property("FederationRole") - .HasMaxLength(20); - - b.Property("IsDeleted"); - - b.Property("ModifiedById"); - - b.Property("ModifiedOnUtc") - .IsConcurrencyToken(); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50); - - b.Property("PasswordHash") - .IsRequired() - .HasMaxLength(64); - - b.Property("PasswordSalt") - .IsRequired() - .HasMaxLength(128); - - b.Property("SppdName") - .IsRequired() - .HasMaxLength(50); - - b.Property("TeamId"); - - b.Property("TeamRole") - .HasMaxLength(20); - - b.HasKey("Id"); - - b.HasIndex("Email") - .IsUnique(); - - b.HasIndex("FederationId"); - - b.HasIndex("Name") - .IsUnique(); - - b.HasIndex("SppdName") - .IsUnique(); - - b.HasIndex("TeamId"); - - b.ToTable("TeamTunerUser"); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.Theme", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("CreatedById"); - - b.Property("CreatedOnUtc"); - - b.Property("DeletedById"); - - b.Property("DeletedOnUtc"); - - b.Property("IsDeleted"); - - b.Property("ModifiedById"); - - b.Property("ModifiedOnUtc") - .IsConcurrencyToken(); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50); - - b.HasKey("Id"); - - b.ToTable("Theme"); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.Card", b => - { - b.HasOne("Sppd.TeamTuner.Core.Domain.Entities.Rarity", "Rarity") - .WithMany() - .HasForeignKey("RarityId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("Sppd.TeamTuner.Core.Domain.Entities.Theme", "Theme") - .WithMany() - .HasForeignKey("ThemeId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("Sppd.TeamTuner.Core.Domain.Entities.CardType", "Type") - .WithMany() - .HasForeignKey("TypeId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.CardLevel", b => - { - b.HasOne("Sppd.TeamTuner.Core.Domain.Entities.Card", "Card") - .WithMany() - .HasForeignKey("CardId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("Sppd.TeamTuner.Core.Domain.Entities.TeamTunerUser", "User") - .WithMany("CardLevels") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.Team", b => - { - b.HasOne("Sppd.TeamTuner.Core.Domain.Entities.Federation", "Federation") - .WithMany("Teams") - .HasForeignKey("FederationId"); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.TeamTunerUser", b => - { - b.HasOne("Sppd.TeamTuner.Core.Domain.Entities.Federation", "Federation") - .WithMany() - .HasForeignKey("FederationId"); - - b.HasOne("Sppd.TeamTuner.Core.Domain.Entities.Team", "Team") - .WithMany("Users") - .HasForeignKey("TeamId"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190412140837_SoftDeleteFilter.Designer.cs b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190412140837_SoftDeleteFilter.Designer.cs deleted file mode 100644 index cf85d62..0000000 --- a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190412140837_SoftDeleteFilter.Designer.cs +++ /dev/null @@ -1,402 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Sppd.TeamTuner.Infrastructure.DataAccess.EF; - -namespace Sppd.TeamTuner.Infrastructure.DataAccess.EF.Migrations -{ - [DbContext(typeof(TeamTunerContext))] - [Migration("20190412140837_SoftDeleteFilter")] - partial class SoftDeleteFilter - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "2.2.4-servicing-10062") - .HasAnnotation("Relational:MaxIdentifierLength", 128) - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.Card", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("CreatedById"); - - b.Property("CreatedOnUtc"); - - b.Property("DeletedById"); - - b.Property("DeletedOnUtc"); - - b.Property("ExternalId"); - - b.Property("FriendlyName") - .IsRequired() - .HasMaxLength(10); - - b.Property("IsDeleted"); - - b.Property("ModifiedById"); - - b.Property("ModifiedOnUtc") - .IsConcurrencyToken(); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50); - - b.Property("RarityId"); - - b.Property("ThemeId"); - - b.Property("TypeId"); - - b.HasKey("Id"); - - b.HasIndex("ExternalId") - .IsUnique() - .HasFilter("[IsDeleted] = 0"); - - b.HasIndex("RarityId"); - - b.HasIndex("ThemeId"); - - b.HasIndex("TypeId"); - - b.ToTable("Card"); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.CardLevel", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("CardId"); - - b.Property("CreatedById"); - - b.Property("CreatedOnUtc"); - - b.Property("DeletedById"); - - b.Property("DeletedOnUtc"); - - b.Property("IsDeleted"); - - b.Property("Level"); - - b.Property("ModifiedById"); - - b.Property("ModifiedOnUtc") - .IsConcurrencyToken(); - - b.Property("UserId"); - - b.HasKey("Id"); - - b.HasIndex("CardId"); - - b.HasIndex("UserId"); - - b.ToTable("CardLevel"); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.CardType", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("CreatedById"); - - b.Property("CreatedOnUtc"); - - b.Property("DeletedById"); - - b.Property("DeletedOnUtc"); - - b.Property("IsDeleted"); - - b.Property("ModifiedById"); - - b.Property("ModifiedOnUtc") - .IsConcurrencyToken(); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50); - - b.HasKey("Id"); - - b.ToTable("CardType"); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.Federation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("Avatar"); - - b.Property("CreatedById"); - - b.Property("CreatedOnUtc"); - - b.Property("DeletedById"); - - b.Property("DeletedOnUtc"); - - b.Property("Description") - .HasMaxLength(2000); - - b.Property("IsDeleted"); - - b.Property("ModifiedById"); - - b.Property("ModifiedOnUtc") - .IsConcurrencyToken(); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50); - - b.HasKey("Id"); - - b.ToTable("Federation"); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.Rarity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("CreatedById"); - - b.Property("CreatedOnUtc"); - - b.Property("DeletedById"); - - b.Property("DeletedOnUtc"); - - b.Property("FriendlyLevel"); - - b.Property("IsDeleted"); - - b.Property("ModifiedById"); - - b.Property("ModifiedOnUtc") - .IsConcurrencyToken(); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50); - - b.HasKey("Id"); - - b.ToTable("Rarity"); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.Team", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("Avatar"); - - b.Property("CreatedById"); - - b.Property("CreatedOnUtc"); - - b.Property("DeletedById"); - - b.Property("DeletedOnUtc"); - - b.Property("Description") - .HasMaxLength(2000); - - b.Property("FederationId"); - - b.Property("IsDeleted"); - - b.Property("ModifiedById"); - - b.Property("ModifiedOnUtc") - .IsConcurrencyToken(); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50); - - b.HasKey("Id"); - - b.HasIndex("FederationId"); - - b.ToTable("Team"); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.TeamTunerUser", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("ApplicationRole") - .IsRequired() - .HasMaxLength(20); - - b.Property("Avatar"); - - b.Property("CreatedById"); - - b.Property("CreatedOnUtc"); - - b.Property("DeletedById"); - - b.Property("DeletedOnUtc"); - - b.Property("Description") - .HasMaxLength(2000); - - b.Property("Email") - .IsRequired() - .HasMaxLength(200); - - b.Property("FederationId"); - - b.Property("FederationRole") - .HasMaxLength(20); - - b.Property("IsDeleted"); - - b.Property("ModifiedById"); - - b.Property("ModifiedOnUtc") - .IsConcurrencyToken(); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50); - - b.Property("PasswordHash") - .IsRequired() - .HasMaxLength(64); - - b.Property("PasswordSalt") - .IsRequired() - .HasMaxLength(128); - - b.Property("SppdName") - .IsRequired() - .HasMaxLength(50); - - b.Property("TeamId"); - - b.Property("TeamRole") - .HasMaxLength(20); - - b.HasKey("Id"); - - b.HasIndex("Email") - .IsUnique() - .HasFilter("[IsDeleted] = 0"); - - b.HasIndex("FederationId"); - - b.HasIndex("Name") - .IsUnique() - .HasFilter("[IsDeleted] = 0"); - - b.HasIndex("SppdName") - .IsUnique() - .HasFilter("[IsDeleted] = 0"); - - b.HasIndex("TeamId"); - - b.ToTable("TeamTunerUser"); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.Theme", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("CreatedById"); - - b.Property("CreatedOnUtc"); - - b.Property("DeletedById"); - - b.Property("DeletedOnUtc"); - - b.Property("IsDeleted"); - - b.Property("ModifiedById"); - - b.Property("ModifiedOnUtc") - .IsConcurrencyToken(); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50); - - b.HasKey("Id"); - - b.ToTable("Theme"); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.Card", b => - { - b.HasOne("Sppd.TeamTuner.Core.Domain.Entities.Rarity", "Rarity") - .WithMany() - .HasForeignKey("RarityId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("Sppd.TeamTuner.Core.Domain.Entities.Theme", "Theme") - .WithMany() - .HasForeignKey("ThemeId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("Sppd.TeamTuner.Core.Domain.Entities.CardType", "Type") - .WithMany() - .HasForeignKey("TypeId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.CardLevel", b => - { - b.HasOne("Sppd.TeamTuner.Core.Domain.Entities.Card", "Card") - .WithMany() - .HasForeignKey("CardId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("Sppd.TeamTuner.Core.Domain.Entities.TeamTunerUser", "User") - .WithMany("CardLevels") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.Team", b => - { - b.HasOne("Sppd.TeamTuner.Core.Domain.Entities.Federation", "Federation") - .WithMany("Teams") - .HasForeignKey("FederationId"); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.TeamTunerUser", b => - { - b.HasOne("Sppd.TeamTuner.Core.Domain.Entities.Federation", "Federation") - .WithMany() - .HasForeignKey("FederationId"); - - b.HasOne("Sppd.TeamTuner.Core.Domain.Entities.Team", "Team") - .WithMany("Users") - .HasForeignKey("TeamId"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190412140837_SoftDeleteFilter.cs b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190412140837_SoftDeleteFilter.cs deleted file mode 100644 index 203085e..0000000 --- a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190412140837_SoftDeleteFilter.cs +++ /dev/null @@ -1,97 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -namespace Sppd.TeamTuner.Infrastructure.DataAccess.EF.Migrations -{ - public partial class SoftDeleteFilter : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropIndex( - name: "IX_TeamTunerUser_Email", - table: "TeamTunerUser"); - - migrationBuilder.DropIndex( - name: "IX_TeamTunerUser_Name", - table: "TeamTunerUser"); - - migrationBuilder.DropIndex( - name: "IX_TeamTunerUser_SppdName", - table: "TeamTunerUser"); - - migrationBuilder.DropIndex( - name: "IX_Card_ExternalId", - table: "Card"); - - migrationBuilder.CreateIndex( - name: "IX_TeamTunerUser_Email", - table: "TeamTunerUser", - column: "Email", - unique: true, - filter: "[IsDeleted] = 0"); - - migrationBuilder.CreateIndex( - name: "IX_TeamTunerUser_Name", - table: "TeamTunerUser", - column: "Name", - unique: true, - filter: "[IsDeleted] = 0"); - - migrationBuilder.CreateIndex( - name: "IX_TeamTunerUser_SppdName", - table: "TeamTunerUser", - column: "SppdName", - unique: true, - filter: "[IsDeleted] = 0"); - - migrationBuilder.CreateIndex( - name: "IX_Card_ExternalId", - table: "Card", - column: "ExternalId", - unique: true, - filter: "[IsDeleted] = 0"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropIndex( - name: "IX_TeamTunerUser_Email", - table: "TeamTunerUser"); - - migrationBuilder.DropIndex( - name: "IX_TeamTunerUser_Name", - table: "TeamTunerUser"); - - migrationBuilder.DropIndex( - name: "IX_TeamTunerUser_SppdName", - table: "TeamTunerUser"); - - migrationBuilder.DropIndex( - name: "IX_Card_ExternalId", - table: "Card"); - - migrationBuilder.CreateIndex( - name: "IX_TeamTunerUser_Email", - table: "TeamTunerUser", - column: "Email", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_TeamTunerUser_Name", - table: "TeamTunerUser", - column: "Name", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_TeamTunerUser_SppdName", - table: "TeamTunerUser", - column: "SppdName", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_Card_ExternalId", - table: "Card", - column: "ExternalId", - unique: true); - } - } -} diff --git a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190413070900_OptimisticLocking.Designer.cs b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190413070900_OptimisticLocking.Designer.cs deleted file mode 100644 index 30768f0..0000000 --- a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190413070900_OptimisticLocking.Designer.cs +++ /dev/null @@ -1,426 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Sppd.TeamTuner.Infrastructure.DataAccess.EF; - -namespace Sppd.TeamTuner.Infrastructure.DataAccess.EF.Migrations -{ - [DbContext(typeof(TeamTunerContext))] - [Migration("20190413070900_OptimisticLocking")] - partial class OptimisticLocking - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "2.2.4-servicing-10062") - .HasAnnotation("Relational:MaxIdentifierLength", 128) - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.Card", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("CreatedById"); - - b.Property("CreatedOnUtc"); - - b.Property("DeletedById"); - - b.Property("DeletedOnUtc"); - - b.Property("ExternalId"); - - b.Property("FriendlyName") - .IsRequired() - .HasMaxLength(10); - - b.Property("IsDeleted"); - - b.Property("ModifiedById"); - - b.Property("ModifiedOnUtc"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50); - - b.Property("RarityId"); - - b.Property("ThemeId"); - - b.Property("TypeId"); - - b.Property("Version") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate(); - - b.HasKey("Id"); - - b.HasIndex("ExternalId") - .IsUnique() - .HasFilter("[IsDeleted] = 0"); - - b.HasIndex("RarityId"); - - b.HasIndex("ThemeId"); - - b.HasIndex("TypeId"); - - b.ToTable("Card"); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.CardLevel", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("CardId"); - - b.Property("CreatedById"); - - b.Property("CreatedOnUtc"); - - b.Property("DeletedById"); - - b.Property("DeletedOnUtc"); - - b.Property("IsDeleted"); - - b.Property("Level"); - - b.Property("ModifiedById"); - - b.Property("ModifiedOnUtc"); - - b.Property("UserId"); - - b.Property("Version") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate(); - - b.HasKey("Id"); - - b.HasIndex("CardId"); - - b.HasIndex("UserId"); - - b.ToTable("CardLevel"); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.CardType", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("CreatedById"); - - b.Property("CreatedOnUtc"); - - b.Property("DeletedById"); - - b.Property("DeletedOnUtc"); - - b.Property("IsDeleted"); - - b.Property("ModifiedById"); - - b.Property("ModifiedOnUtc"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50); - - b.Property("Version") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate(); - - b.HasKey("Id"); - - b.ToTable("CardType"); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.Federation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("Avatar"); - - b.Property("CreatedById"); - - b.Property("CreatedOnUtc"); - - b.Property("DeletedById"); - - b.Property("DeletedOnUtc"); - - b.Property("Description") - .HasMaxLength(2000); - - b.Property("IsDeleted"); - - b.Property("ModifiedById"); - - b.Property("ModifiedOnUtc"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50); - - b.Property("Version") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate(); - - b.HasKey("Id"); - - b.ToTable("Federation"); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.Rarity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("CreatedById"); - - b.Property("CreatedOnUtc"); - - b.Property("DeletedById"); - - b.Property("DeletedOnUtc"); - - b.Property("FriendlyLevel"); - - b.Property("IsDeleted"); - - b.Property("ModifiedById"); - - b.Property("ModifiedOnUtc"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50); - - b.Property("Version") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate(); - - b.HasKey("Id"); - - b.ToTable("Rarity"); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.Team", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("Avatar"); - - b.Property("CreatedById"); - - b.Property("CreatedOnUtc"); - - b.Property("DeletedById"); - - b.Property("DeletedOnUtc"); - - b.Property("Description") - .HasMaxLength(2000); - - b.Property("FederationId"); - - b.Property("IsDeleted"); - - b.Property("ModifiedById"); - - b.Property("ModifiedOnUtc"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50); - - b.Property("Version") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate(); - - b.HasKey("Id"); - - b.HasIndex("FederationId"); - - b.ToTable("Team"); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.TeamTunerUser", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("ApplicationRole") - .IsRequired() - .HasMaxLength(20); - - b.Property("Avatar"); - - b.Property("CreatedById"); - - b.Property("CreatedOnUtc"); - - b.Property("DeletedById"); - - b.Property("DeletedOnUtc"); - - b.Property("Description") - .HasMaxLength(2000); - - b.Property("Email") - .IsRequired() - .HasMaxLength(200); - - b.Property("FederationId"); - - b.Property("FederationRole") - .HasMaxLength(20); - - b.Property("IsDeleted"); - - b.Property("ModifiedById"); - - b.Property("ModifiedOnUtc"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50); - - b.Property("PasswordHash") - .IsRequired() - .HasMaxLength(64); - - b.Property("PasswordSalt") - .IsRequired() - .HasMaxLength(128); - - b.Property("SppdName") - .IsRequired() - .HasMaxLength(50); - - b.Property("TeamId"); - - b.Property("TeamRole") - .HasMaxLength(20); - - b.Property("Version") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate(); - - b.HasKey("Id"); - - b.HasIndex("Email") - .IsUnique() - .HasFilter("[IsDeleted] = 0"); - - b.HasIndex("FederationId"); - - b.HasIndex("Name") - .IsUnique() - .HasFilter("[IsDeleted] = 0"); - - b.HasIndex("SppdName") - .IsUnique() - .HasFilter("[IsDeleted] = 0"); - - b.HasIndex("TeamId"); - - b.ToTable("TeamTunerUser"); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.Theme", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("CreatedById"); - - b.Property("CreatedOnUtc"); - - b.Property("DeletedById"); - - b.Property("DeletedOnUtc"); - - b.Property("IsDeleted"); - - b.Property("ModifiedById"); - - b.Property("ModifiedOnUtc"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50); - - b.Property("Version") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate(); - - b.HasKey("Id"); - - b.ToTable("Theme"); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.Card", b => - { - b.HasOne("Sppd.TeamTuner.Core.Domain.Entities.Rarity", "Rarity") - .WithMany() - .HasForeignKey("RarityId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("Sppd.TeamTuner.Core.Domain.Entities.Theme", "Theme") - .WithMany() - .HasForeignKey("ThemeId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("Sppd.TeamTuner.Core.Domain.Entities.CardType", "Type") - .WithMany() - .HasForeignKey("TypeId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.CardLevel", b => - { - b.HasOne("Sppd.TeamTuner.Core.Domain.Entities.Card", "Card") - .WithMany() - .HasForeignKey("CardId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("Sppd.TeamTuner.Core.Domain.Entities.TeamTunerUser", "User") - .WithMany("CardLevels") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.Team", b => - { - b.HasOne("Sppd.TeamTuner.Core.Domain.Entities.Federation", "Federation") - .WithMany("Teams") - .HasForeignKey("FederationId"); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.TeamTunerUser", b => - { - b.HasOne("Sppd.TeamTuner.Core.Domain.Entities.Federation", "Federation") - .WithMany() - .HasForeignKey("FederationId"); - - b.HasOne("Sppd.TeamTuner.Core.Domain.Entities.Team", "Team") - .WithMany("Users") - .HasForeignKey("TeamId"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190413070900_OptimisticLocking.cs b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190413070900_OptimisticLocking.cs deleted file mode 100644 index 07d0a8b..0000000 --- a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190413070900_OptimisticLocking.cs +++ /dev/null @@ -1,94 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -namespace Sppd.TeamTuner.Infrastructure.DataAccess.EF.Migrations -{ - public partial class OptimisticLocking : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "Version", - table: "Theme", - rowVersion: true, - nullable: true); - - migrationBuilder.AddColumn( - name: "Version", - table: "TeamTunerUser", - rowVersion: true, - nullable: true); - - migrationBuilder.AddColumn( - name: "Version", - table: "Team", - rowVersion: true, - nullable: true); - - migrationBuilder.AddColumn( - name: "Version", - table: "Rarity", - rowVersion: true, - nullable: true); - - migrationBuilder.AddColumn( - name: "Version", - table: "Federation", - rowVersion: true, - nullable: true); - - migrationBuilder.AddColumn( - name: "Version", - table: "CardType", - rowVersion: true, - nullable: true); - - migrationBuilder.AddColumn( - name: "Version", - table: "CardLevel", - rowVersion: true, - nullable: true); - - migrationBuilder.AddColumn( - name: "Version", - table: "Card", - rowVersion: true, - nullable: true); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Version", - table: "Theme"); - - migrationBuilder.DropColumn( - name: "Version", - table: "TeamTunerUser"); - - migrationBuilder.DropColumn( - name: "Version", - table: "Team"); - - migrationBuilder.DropColumn( - name: "Version", - table: "Rarity"); - - migrationBuilder.DropColumn( - name: "Version", - table: "Federation"); - - migrationBuilder.DropColumn( - name: "Version", - table: "CardType"); - - migrationBuilder.DropColumn( - name: "Version", - table: "CardLevel"); - - migrationBuilder.DropColumn( - name: "Version", - table: "Card"); - } - } -} diff --git a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190414081444_TeamJoinRequest.Designer.cs b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190414081444_TeamJoinRequest.Designer.cs deleted file mode 100644 index 76c4219..0000000 --- a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190414081444_TeamJoinRequest.Designer.cs +++ /dev/null @@ -1,482 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Sppd.TeamTuner.Infrastructure.DataAccess.EF; - -namespace Sppd.TeamTuner.Infrastructure.DataAccess.EF.Migrations -{ - [DbContext(typeof(TeamTunerContext))] - [Migration("20190414081444_TeamJoinRequest")] - partial class TeamJoinRequest - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "2.2.4-servicing-10062") - .HasAnnotation("Relational:MaxIdentifierLength", 128) - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.Card", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("CreatedById"); - - b.Property("CreatedOnUtc"); - - b.Property("DeletedById"); - - b.Property("DeletedOnUtc"); - - b.Property("ExternalId"); - - b.Property("FriendlyName") - .IsRequired() - .HasMaxLength(10); - - b.Property("IsDeleted"); - - b.Property("ModifiedById"); - - b.Property("ModifiedOnUtc"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50); - - b.Property("RarityId"); - - b.Property("ThemeId"); - - b.Property("TypeId"); - - b.Property("Version") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate(); - - b.HasKey("Id"); - - b.HasIndex("ExternalId") - .IsUnique() - .HasFilter("[IsDeleted] = 0"); - - b.HasIndex("RarityId"); - - b.HasIndex("ThemeId"); - - b.HasIndex("TypeId"); - - b.ToTable("Card"); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.CardLevel", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("CardId"); - - b.Property("CreatedById"); - - b.Property("CreatedOnUtc"); - - b.Property("DeletedById"); - - b.Property("DeletedOnUtc"); - - b.Property("IsDeleted"); - - b.Property("Level"); - - b.Property("ModifiedById"); - - b.Property("ModifiedOnUtc"); - - b.Property("UserId"); - - b.Property("Version") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate(); - - b.HasKey("Id"); - - b.HasIndex("CardId"); - - b.HasIndex("UserId"); - - b.ToTable("CardLevel"); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.CardType", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("CreatedById"); - - b.Property("CreatedOnUtc"); - - b.Property("DeletedById"); - - b.Property("DeletedOnUtc"); - - b.Property("IsDeleted"); - - b.Property("ModifiedById"); - - b.Property("ModifiedOnUtc"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50); - - b.Property("Version") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate(); - - b.HasKey("Id"); - - b.ToTable("CardType"); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.Federation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("Avatar"); - - b.Property("CreatedById"); - - b.Property("CreatedOnUtc"); - - b.Property("DeletedById"); - - b.Property("DeletedOnUtc"); - - b.Property("Description") - .HasMaxLength(2000); - - b.Property("IsDeleted"); - - b.Property("ModifiedById"); - - b.Property("ModifiedOnUtc"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50); - - b.Property("Version") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate(); - - b.HasKey("Id"); - - b.ToTable("Federation"); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.Rarity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("CreatedById"); - - b.Property("CreatedOnUtc"); - - b.Property("DeletedById"); - - b.Property("DeletedOnUtc"); - - b.Property("FriendlyLevel"); - - b.Property("IsDeleted"); - - b.Property("ModifiedById"); - - b.Property("ModifiedOnUtc"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50); - - b.Property("Version") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate(); - - b.HasKey("Id"); - - b.ToTable("Rarity"); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.Team", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("Avatar"); - - b.Property("CreatedById"); - - b.Property("CreatedOnUtc"); - - b.Property("DeletedById"); - - b.Property("DeletedOnUtc"); - - b.Property("Description") - .HasMaxLength(2000); - - b.Property("FederationId"); - - b.Property("IsDeleted"); - - b.Property("ModifiedById"); - - b.Property("ModifiedOnUtc"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50); - - b.Property("Version") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate(); - - b.HasKey("Id"); - - b.HasIndex("FederationId"); - - b.ToTable("Team"); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.TeamJoinRequest", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("Comment") - .HasMaxLength(500); - - b.Property("CreatedById"); - - b.Property("CreatedOnUtc"); - - b.Property("DeletedById"); - - b.Property("DeletedOnUtc"); - - b.Property("IsDeleted"); - - b.Property("ModifiedById"); - - b.Property("ModifiedOnUtc"); - - b.Property("TeamId"); - - b.Property("UserId"); - - b.Property("Version") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate(); - - b.HasKey("Id"); - - b.HasIndex("TeamId") - .IsUnique() - .HasFilter("[IsDeleted] = 0"); - - b.HasIndex("UserId") - .IsUnique() - .HasFilter("[IsDeleted] = 0"); - - b.ToTable("TeamJoinRequest"); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.TeamTunerUser", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("ApplicationRole") - .IsRequired() - .HasMaxLength(20); - - b.Property("Avatar"); - - b.Property("CreatedById"); - - b.Property("CreatedOnUtc"); - - b.Property("DeletedById"); - - b.Property("DeletedOnUtc"); - - b.Property("Description") - .HasMaxLength(2000); - - b.Property("Email") - .IsRequired() - .HasMaxLength(200); - - b.Property("FederationId"); - - b.Property("FederationRole") - .HasMaxLength(20); - - b.Property("IsDeleted"); - - b.Property("ModifiedById"); - - b.Property("ModifiedOnUtc"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50); - - b.Property("PasswordHash") - .IsRequired() - .HasMaxLength(64); - - b.Property("PasswordSalt") - .IsRequired() - .HasMaxLength(128); - - b.Property("SppdName") - .IsRequired() - .HasMaxLength(50); - - b.Property("TeamId"); - - b.Property("TeamRole") - .HasMaxLength(20); - - b.Property("Version") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate(); - - b.HasKey("Id"); - - b.HasIndex("Email") - .IsUnique() - .HasFilter("[IsDeleted] = 0"); - - b.HasIndex("FederationId"); - - b.HasIndex("Name") - .IsUnique() - .HasFilter("[IsDeleted] = 0"); - - b.HasIndex("SppdName") - .IsUnique() - .HasFilter("[IsDeleted] = 0"); - - b.HasIndex("TeamId"); - - b.ToTable("TeamTunerUser"); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.Theme", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("CreatedById"); - - b.Property("CreatedOnUtc"); - - b.Property("DeletedById"); - - b.Property("DeletedOnUtc"); - - b.Property("IsDeleted"); - - b.Property("ModifiedById"); - - b.Property("ModifiedOnUtc"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50); - - b.Property("Version") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate(); - - b.HasKey("Id"); - - b.ToTable("Theme"); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.Card", b => - { - b.HasOne("Sppd.TeamTuner.Core.Domain.Entities.Rarity", "Rarity") - .WithMany() - .HasForeignKey("RarityId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("Sppd.TeamTuner.Core.Domain.Entities.Theme", "Theme") - .WithMany() - .HasForeignKey("ThemeId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("Sppd.TeamTuner.Core.Domain.Entities.CardType", "Type") - .WithMany() - .HasForeignKey("TypeId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.CardLevel", b => - { - b.HasOne("Sppd.TeamTuner.Core.Domain.Entities.Card", "Card") - .WithMany() - .HasForeignKey("CardId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("Sppd.TeamTuner.Core.Domain.Entities.TeamTunerUser", "User") - .WithMany("CardLevels") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.Team", b => - { - b.HasOne("Sppd.TeamTuner.Core.Domain.Entities.Federation", "Federation") - .WithMany("Teams") - .HasForeignKey("FederationId"); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.TeamJoinRequest", b => - { - b.HasOne("Sppd.TeamTuner.Core.Domain.Entities.Team", "Team") - .WithMany() - .HasForeignKey("TeamId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("Sppd.TeamTuner.Core.Domain.Entities.TeamTunerUser", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("Sppd.TeamTuner.Core.Domain.Entities.TeamTunerUser", b => - { - b.HasOne("Sppd.TeamTuner.Core.Domain.Entities.Federation", "Federation") - .WithMany() - .HasForeignKey("FederationId"); - - b.HasOne("Sppd.TeamTuner.Core.Domain.Entities.Team", "Team") - .WithMany("Users") - .HasForeignKey("TeamId"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190414081444_TeamJoinRequest.cs b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190414081444_TeamJoinRequest.cs deleted file mode 100644 index e419050..0000000 --- a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190414081444_TeamJoinRequest.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -namespace Sppd.TeamTuner.Infrastructure.DataAccess.EF.Migrations -{ - public partial class TeamJoinRequest : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "TeamJoinRequest", - columns: table => new - { - Id = table.Column(nullable: false), - CreatedOnUtc = table.Column(nullable: false), - CreatedById = table.Column(nullable: false), - ModifiedOnUtc = table.Column(nullable: false), - ModifiedById = table.Column(nullable: false), - IsDeleted = table.Column(nullable: false), - DeletedOnUtc = table.Column(nullable: true), - DeletedById = table.Column(nullable: true), - Version = table.Column(rowVersion: true, nullable: true), - TeamId = table.Column(nullable: false), - UserId = table.Column(nullable: false), - Comment = table.Column(maxLength: 500, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_TeamJoinRequest", x => x.Id); - table.ForeignKey( - name: "FK_TeamJoinRequest_Team_TeamId", - column: x => x.TeamId, - principalTable: "Team", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_TeamJoinRequest_TeamTunerUser_UserId", - column: x => x.UserId, - principalTable: "TeamTunerUser", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_TeamJoinRequest_TeamId", - table: "TeamJoinRequest", - column: "TeamId", - unique: true, - filter: "[IsDeleted] = 0"); - - migrationBuilder.CreateIndex( - name: "IX_TeamJoinRequest_UserId", - table: "TeamJoinRequest", - column: "UserId", - unique: true, - filter: "[IsDeleted] = 0"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "TeamJoinRequest"); - } - } -} diff --git a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190420130358_Membership.cs b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190420130358_Membership.cs deleted file mode 100644 index 2f3dc28..0000000 --- a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190420130358_Membership.cs +++ /dev/null @@ -1,116 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -namespace Sppd.TeamTuner.Infrastructure.DataAccess.EF.Migrations -{ - public partial class Membership : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "TeamJoinRequest"); - - migrationBuilder.CreateTable( - name: "TeamMembershipRequest", - columns: table => new - { - Id = table.Column(nullable: false), - CreatedOnUtc = table.Column(nullable: false), - CreatedById = table.Column(nullable: false), - ModifiedOnUtc = table.Column(nullable: false), - ModifiedById = table.Column(nullable: false), - IsDeleted = table.Column(nullable: false), - DeletedOnUtc = table.Column(nullable: true), - DeletedById = table.Column(nullable: true), - Version = table.Column(rowVersion: true, nullable: true), - TeamId = table.Column(nullable: false), - UserId = table.Column(nullable: false), - Comment = table.Column(maxLength: 500, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_TeamMembershipRequest", x => x.Id); - table.ForeignKey( - name: "FK_TeamMembershipRequest_Team_TeamId", - column: x => x.TeamId, - principalTable: "Team", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_TeamMembershipRequest_TeamTunerUser_UserId", - column: x => x.UserId, - principalTable: "TeamTunerUser", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_TeamMembershipRequest_TeamId", - table: "TeamMembershipRequest", - column: "TeamId", - unique: true, - filter: "[IsDeleted] = 0"); - - migrationBuilder.CreateIndex( - name: "IX_TeamMembershipRequest_UserId", - table: "TeamMembershipRequest", - column: "UserId", - unique: true, - filter: "[IsDeleted] = 0"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "TeamMembershipRequest"); - - migrationBuilder.CreateTable( - name: "TeamJoinRequest", - columns: table => new - { - Id = table.Column(nullable: false), - Comment = table.Column(maxLength: 500, nullable: true), - CreatedById = table.Column(nullable: false), - CreatedOnUtc = table.Column(nullable: false), - DeletedById = table.Column(nullable: true), - DeletedOnUtc = table.Column(nullable: true), - IsDeleted = table.Column(nullable: false), - ModifiedById = table.Column(nullable: false), - ModifiedOnUtc = table.Column(nullable: false), - TeamId = table.Column(nullable: false), - UserId = table.Column(nullable: false), - Version = table.Column(rowVersion: true, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_TeamJoinRequest", x => x.Id); - table.ForeignKey( - name: "FK_TeamJoinRequest_Team_TeamId", - column: x => x.TeamId, - principalTable: "Team", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_TeamJoinRequest_TeamTunerUser_UserId", - column: x => x.UserId, - principalTable: "TeamTunerUser", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_TeamJoinRequest_TeamId", - table: "TeamJoinRequest", - column: "TeamId", - unique: true, - filter: "[IsDeleted] = 0"); - - migrationBuilder.CreateIndex( - name: "IX_TeamJoinRequest_UserId", - table: "TeamJoinRequest", - column: "UserId", - unique: true, - filter: "[IsDeleted] = 0"); - } - } -} diff --git a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190422085433_UniqueCardLevel.cs b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190422085433_UniqueCardLevel.cs deleted file mode 100644 index 23bdabc..0000000 --- a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190422085433_UniqueCardLevel.cs +++ /dev/null @@ -1,33 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -namespace Sppd.TeamTuner.Infrastructure.DataAccess.EF.Migrations -{ - public partial class UniqueCardLevel : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropIndex( - name: "IX_CardLevel_UserId", - table: "CardLevel"); - - migrationBuilder.CreateIndex( - name: "IX_CardLevel_UserId_CardId", - table: "CardLevel", - columns: new[] { "UserId", "CardId" }, - unique: true, - filter: "[IsDeleted] = 0"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropIndex( - name: "IX_CardLevel_UserId_CardId", - table: "CardLevel"); - - migrationBuilder.CreateIndex( - name: "IX_CardLevel_UserId", - table: "CardLevel", - column: "UserId"); - } - } -} diff --git a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190430123341_UserProfileVisibility.cs b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190430123341_UserProfileVisibility.cs deleted file mode 100644 index 45d58b3..0000000 --- a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Migrations/20190430123341_UserProfileVisibility.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -namespace Sppd.TeamTuner.Infrastructure.DataAccess.EF.Migrations -{ - public partial class UserProfileVisibility : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "ProfileVisibility", - table: "TeamTunerUser", - nullable: false, - defaultValue: 0); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "ProfileVisibility", - table: "TeamTunerUser"); - } - } -} diff --git a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Sppd.TeamTuner.Infrastructure.DataAccess.EF.csproj b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Sppd.TeamTuner.Infrastructure.DataAccess.EF.csproj index 05d5558..f8aca14 100644 --- a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Sppd.TeamTuner.Infrastructure.DataAccess.EF.csproj +++ b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/Sppd.TeamTuner.Infrastructure.DataAccess.EF.csproj @@ -10,11 +10,8 @@ - - - - - + + diff --git a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/StartupRegistrator.cs b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/StartupRegistrator.cs index 3acf7b9..41939b8 100644 --- a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/StartupRegistrator.cs +++ b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/StartupRegistrator.cs @@ -1,6 +1,5 @@ using System; -using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; using Sppd.TeamTuner.Core; @@ -20,20 +19,12 @@ namespace Sppd.TeamTuner.Infrastructure.DataAccess.EF { public class StartupRegistrator : IStartupRegistrator { - private const string ID_PLACEHOLDER = "{id}"; - public int Priority => 100; public void Register(IServiceCollection services) { var databaseConfig = services.BuildServiceProvider().GetConfig(); - // DB context - var dbId = Guid.NewGuid().ToString("n").Substring(0, 8); - databaseConfig.ConnectionString = databaseConfig.ConnectionString.Replace(ID_PLACEHOLDER, dbId); - services.AddDbContext(options => options.UseSqlServer(databaseConfig.ConnectionString)) - .AddScoped(); - // Repositories services.AddScoped(typeof(IRepository<>), typeof(Repository<>)) .AddScoped() diff --git a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/TeamTunerContext.EntityConfigurations.cs b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/TeamTunerContext.EntityConfigurations.cs index f9114a8..b753e60 100644 --- a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/TeamTunerContext.EntityConfigurations.cs +++ b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/TeamTunerContext.EntityConfigurations.cs @@ -5,12 +5,11 @@ namespace Sppd.TeamTuner.Infrastructure.DataAccess.EF { - /// /// /// Partial class specifying the entity configurations /// /// - internal partial class TeamTunerContext + public partial class TeamTunerContext { private static void ConfigureBaseEntity(EntityTypeBuilder builder) where TEntity : BaseEntity diff --git a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/TeamTunerContext.cs b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/TeamTunerContext.cs index 7415767..54f30dd 100644 --- a/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/TeamTunerContext.cs +++ b/Backend/Sppd.TeamTuner.Infrastructure.DataAccess.EF/TeamTunerContext.cs @@ -5,12 +5,10 @@ using Microsoft.EntityFrameworkCore; -using Sppd.TeamTuner.Core.Config; using Sppd.TeamTuner.Core.Domain.Entities; using Sppd.TeamTuner.Core.Domain.Interfaces; using Sppd.TeamTuner.Core.Exceptions; using Sppd.TeamTuner.Core.Services; -using Sppd.TeamTuner.Infrastructure.DataAccess.EF.Config; namespace Sppd.TeamTuner.Infrastructure.DataAccess.EF { @@ -18,18 +16,15 @@ namespace Sppd.TeamTuner.Infrastructure.DataAccess.EF /// for the application. /// /// - internal partial class TeamTunerContext : DbContext, IDatabaseService + public partial class TeamTunerContext : DbContext, IDatabaseService { - private readonly Lazy _databaseConfig; private readonly Lazy _validationService; private readonly IEnumerable> _entityMetadataProviders; - public TeamTunerContext(DbContextOptions options, Lazy validationService, IConfigProvider databaseConfigProvider, - IEnumerable> entityMetadataProviders) + public TeamTunerContext(DbContextOptions options, Lazy validationService, IEnumerable> entityMetadataProviders) : base(options) { _validationService = validationService; - _databaseConfig = new Lazy(() => databaseConfigProvider.Config); _entityMetadataProviders = entityMetadataProviders; } diff --git a/Backend/Sppd.TeamTuner.sln b/Backend/Sppd.TeamTuner.sln index d421b35..f646fba 100644 --- a/Backend/Sppd.TeamTuner.sln +++ b/Backend/Sppd.TeamTuner.sln @@ -8,6 +8,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sppd.TeamTuner", "Sppd.Team {2104B525-31CF-4AC1-BF49-1B2DB4BA5627} = {2104B525-31CF-4AC1-BF49-1B2DB4BA5627} {EE6B295C-0B6B-4A12-B147-CBB824FCC5D7} = {EE6B295C-0B6B-4A12-B147-CBB824FCC5D7} {1DD6F67D-015D-44F7-AB85-94DB2163BD04} = {1DD6F67D-015D-44F7-AB85-94DB2163BD04} + {37746EA6-BB6F-4857-B5BB-1ACB9A65EC25} = {37746EA6-BB6F-4857-B5BB-1ACB9A65EC25} EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sppd.TeamTuner.Core", "Sppd.TeamTuner.Core\Sppd.TeamTuner.Core.csproj", "{0CA39092-BE21-4E7C-A88F-594649AB635F}" @@ -39,6 +40,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sppd.TeamTuner.Infrastructu EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sppd.TeamTuner.Common", "Sppd.TeamTuner.Common\Sppd.TeamTuner.Common.csproj", "{EE6B295C-0B6B-4A12-B147-CBB824FCC5D7}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sppd.TeamTuner.Infrastructure.DataAccess.EF.MsSql", "Sppd.TeamTuner.Infrastructure.DataAccess.EF.MsSql\Sppd.TeamTuner.Infrastructure.DataAccess.EF.MsSql.csproj", "{37746EA6-BB6F-4857-B5BB-1ACB9A65EC25}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sppd.TeamTuner.Infrastructure.DataAccess.EF.Sqlite", "Sppd.TeamTuner.Infrastructure.DataAccess.EF.Sqlite\Sppd.TeamTuner.Infrastructure.DataAccess.EF.Sqlite.csproj", "{93D69A04-20E5-463B-B3A1-9E2EE518FC7B}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -77,6 +82,14 @@ Global {EE6B295C-0B6B-4A12-B147-CBB824FCC5D7}.Debug|Any CPU.Build.0 = Debug|Any CPU {EE6B295C-0B6B-4A12-B147-CBB824FCC5D7}.Release|Any CPU.ActiveCfg = Release|Any CPU {EE6B295C-0B6B-4A12-B147-CBB824FCC5D7}.Release|Any CPU.Build.0 = Release|Any CPU + {37746EA6-BB6F-4857-B5BB-1ACB9A65EC25}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {37746EA6-BB6F-4857-B5BB-1ACB9A65EC25}.Debug|Any CPU.Build.0 = Debug|Any CPU + {37746EA6-BB6F-4857-B5BB-1ACB9A65EC25}.Release|Any CPU.ActiveCfg = Release|Any CPU + {37746EA6-BB6F-4857-B5BB-1ACB9A65EC25}.Release|Any CPU.Build.0 = Release|Any CPU + {93D69A04-20E5-463B-B3A1-9E2EE518FC7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {93D69A04-20E5-463B-B3A1-9E2EE518FC7B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {93D69A04-20E5-463B-B3A1-9E2EE518FC7B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {93D69A04-20E5-463B-B3A1-9E2EE518FC7B}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Backend/Sppd.TeamTuner.sln.DotSettings b/Backend/Sppd.TeamTuner.sln.DotSettings index a71783d..22e8789 100644 --- a/Backend/Sppd.TeamTuner.sln.DotSettings +++ b/Backend/Sppd.TeamTuner.sln.DotSettings @@ -116,11 +116,14 @@ True True True + True True True True + True True True True + True True True \ No newline at end of file diff --git a/Backend/Sppd.TeamTuner/Config/appsettings.json b/Backend/Sppd.TeamTuner/Config/appsettings.json index 5d867b3..bdc81c9 100644 --- a/Backend/Sppd.TeamTuner/Config/appsettings.json +++ b/Backend/Sppd.TeamTuner/Config/appsettings.json @@ -3,6 +3,10 @@ "EnableSwaggerUI": true }, "Database": { + // Swap comments on below lines to use Sqlite + //"Provider": "Sqlite", + //"ConnectionString": "Data Source=sppd.teamtuner.db", + "Provider": "MsSql", "ConnectionString": "Data Source=.\\SQLEXPRESS; Initial Catalog=Sppd.TeamTuner-DEV; Integrated Security=true; MultipleActiveResultSets=True;", "AutoMigrate": true, "SeedMode": "Test", @@ -15,8 +19,7 @@ "Password": "password" }, "Auth": { - "Secret": - "Shut your fucking face uncle fucker, you're a cock sucking ass licking uncle fucker, your an uncle fucker yes its true. no body fucks uncles quite like you!", + "Secret": "Shut your fucking face uncle fucker, you're a cock sucking ass licking uncle fucker, your an uncle fucker yes its true. no body fucks uncles quite like you!", "TokenExpirationDays": 7 } } \ No newline at end of file diff --git a/Backend/Sppd.TeamTuner/Sppd.TeamTuner.csproj b/Backend/Sppd.TeamTuner/Sppd.TeamTuner.csproj index 346e993..88acbd1 100644 --- a/Backend/Sppd.TeamTuner/Sppd.TeamTuner.csproj +++ b/Backend/Sppd.TeamTuner/Sppd.TeamTuner.csproj @@ -22,6 +22,8 @@ + + diff --git a/Backend/Tests/Sppd.TeamTuner.Tests.Integration.Api/Config/appsettings.json b/Backend/Tests/Sppd.TeamTuner.Tests.Integration.Api/Config/appsettings.json index f2dd661..dff1315 100644 --- a/Backend/Tests/Sppd.TeamTuner.Tests.Integration.Api/Config/appsettings.json +++ b/Backend/Tests/Sppd.TeamTuner.Tests.Integration.Api/Config/appsettings.json @@ -3,7 +3,8 @@ "EnableSwaggerUI": true }, "Database": { - "ConnectionString": "Data Source=.\\SQLEXPRESS; Initial Catalog=Sppd.TeamTuner-TEST-API; Integrated Security=true; MultipleActiveResultSets=True;", + "Provider": "Sqlite", + "ConnectionString": "Data Source=Sppd.TeamTuner-TEST-API.db", "AutoMigrate": true, "SeedMode": "Test", "DeleteOnStartup": true diff --git a/Backend/Tests/Sppd.TeamTuner.Tests.Integration.Api/Sppd.TeamTuner.Tests.Integration.Api.csproj b/Backend/Tests/Sppd.TeamTuner.Tests.Integration.Api/Sppd.TeamTuner.Tests.Integration.Api.csproj index 405eae0..161a970 100644 --- a/Backend/Tests/Sppd.TeamTuner.Tests.Integration.Api/Sppd.TeamTuner.Tests.Integration.Api.csproj +++ b/Backend/Tests/Sppd.TeamTuner.Tests.Integration.Api/Sppd.TeamTuner.Tests.Integration.Api.csproj @@ -47,6 +47,8 @@ + + diff --git a/Backend/Tests/Sppd.TeamTuner.Tests.Integration/Config/appsettings.json b/Backend/Tests/Sppd.TeamTuner.Tests.Integration/Config/appsettings.json index 63d0f70..557fa80 100644 --- a/Backend/Tests/Sppd.TeamTuner.Tests.Integration/Config/appsettings.json +++ b/Backend/Tests/Sppd.TeamTuner.Tests.Integration/Config/appsettings.json @@ -3,7 +3,8 @@ "EnableSwaggerUI": true }, "Database": { - "ConnectionString": "Data Source=.\\SQLEXPRESS; Initial Catalog=Sppd.TeamTuner-TEST-{id}; Integrated Security=true; MultipleActiveResultSets=True;", + "Provider": "Sqlite", + "ConnectionString": "Data Source=Sppd.TeamTuner-{id}.db", "AutoMigrate": true, "SeedMode": "Test", "DeleteOnStartup": true diff --git a/Backend/Tests/Sppd.TeamTuner.Tests.Integration/RepositoryTestsBase.cs b/Backend/Tests/Sppd.TeamTuner.Tests.Integration/RepositoryTestsBase.cs index 8aad01a..43ef2c4 100644 --- a/Backend/Tests/Sppd.TeamTuner.Tests.Integration/RepositoryTestsBase.cs +++ b/Backend/Tests/Sppd.TeamTuner.Tests.Integration/RepositoryTestsBase.cs @@ -29,8 +29,16 @@ protected RepositoryTestsBase() { // Instantiate StartupRegistrators registering required services var dataAccessStartupRegistrator = new StartupRegistrator(); + var msSqlStartupRegistrator = new Infrastructure.DataAccess.EF.MsSql.StartupRegistrator(); + var sqliteStartupRegistrator = new Infrastructure.DataAccess.EF.Sqlite.StartupRegistrator(); var infrastructureStartupRegistrator = new Infrastructure.StartupRegistrator(); - var startupRegistrators = new IStartupRegistrator[] {infrastructureStartupRegistrator, dataAccessStartupRegistrator}; + var startupRegistrators = new IStartupRegistrator[] + { + infrastructureStartupRegistrator, + msSqlStartupRegistrator, + sqliteStartupRegistrator, + dataAccessStartupRegistrator + }; // Register services var services = new ServiceCollection(); @@ -45,7 +53,7 @@ protected RepositoryTestsBase() public void Dispose() { - ServiceProvider.GetService().DeleteDatabase(); + //ServiceProvider.GetService().DeleteDatabase(); } private static IConfiguration BuildConfiguration() diff --git a/Backend/Tests/Sppd.TeamTuner.Tests.Integration/Sppd.TeamTuner.Tests.Integration.csproj b/Backend/Tests/Sppd.TeamTuner.Tests.Integration/Sppd.TeamTuner.Tests.Integration.csproj index 020d6e0..b6535b2 100644 --- a/Backend/Tests/Sppd.TeamTuner.Tests.Integration/Sppd.TeamTuner.Tests.Integration.csproj +++ b/Backend/Tests/Sppd.TeamTuner.Tests.Integration/Sppd.TeamTuner.Tests.Integration.csproj @@ -38,6 +38,8 @@ + +