Use migrations

This commit is contained in:
code liturgy 2022-11-30 15:52:55 +00:00
parent f57ad77aa8
commit fad41d9cd7
17 changed files with 1796 additions and 299 deletions

35
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,35 @@
{
"version": "0.2.0",
"configurations": [
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/CodeLiturgy.Views/bin/Debug/net6.0/CodeLiturgy.Views.dll",
"args": [],
"cwd": "${workspaceFolder}/CodeLiturgy.Views",
"stopAtEntry": false,
// Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
}
]
}

41
.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,41 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/CodeLiturgy.Views/CodeLiturgy.Views.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/CodeLiturgy.Views/CodeLiturgy.Views.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"--project",
"${workspaceFolder}/CodeLiturgy.Views/CodeLiturgy.Views.csproj"
],
"problemMatcher": "$msCompile"
}
]
}

View File

@ -28,8 +28,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeLiturgy.Views", "CodeLi
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sharp.Augeas.Test", "include\Sharp.Augeas\Sharp.Augeas.Test\Sharp.Augeas.Test.csproj", "{03308684-19AC-454B-8CD3-AB1C26B8BBBF}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sharp.Augeas.Test", "include\Sharp.Augeas\Sharp.Augeas.Test\Sharp.Augeas.Test.csproj", "{03308684-19AC-454B-8CD3-AB1C26B8BBBF}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sharp.Augeas", "include\Sharp.Augeas\Sharp.Augeas\Sharp.Augeas.csproj", "{CA0D0B52-FC6A-49B5-A775-A754565BE813}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -64,10 +62,6 @@ Global
{03308684-19AC-454B-8CD3-AB1C26B8BBBF}.Debug|Any CPU.Build.0 = Debug|Any CPU {03308684-19AC-454B-8CD3-AB1C26B8BBBF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{03308684-19AC-454B-8CD3-AB1C26B8BBBF}.Release|Any CPU.ActiveCfg = Release|Any CPU {03308684-19AC-454B-8CD3-AB1C26B8BBBF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{03308684-19AC-454B-8CD3-AB1C26B8BBBF}.Release|Any CPU.Build.0 = Release|Any CPU {03308684-19AC-454B-8CD3-AB1C26B8BBBF}.Release|Any CPU.Build.0 = Release|Any CPU
{CA0D0B52-FC6A-49B5-A775-A754565BE813}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CA0D0B52-FC6A-49B5-A775-A754565BE813}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CA0D0B52-FC6A-49B5-A775-A754565BE813}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CA0D0B52-FC6A-49B5-A775-A754565BE813}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -77,7 +71,6 @@ Global
{08F4484E-5FD8-4590-A8D7-12FBE47120C8} = {A1606EEC-6AC5-4779-B140-F57089F5A05F} {08F4484E-5FD8-4590-A8D7-12FBE47120C8} = {A1606EEC-6AC5-4779-B140-F57089F5A05F}
{BBF5E860-A880-450B-B6C9-EF92F6421B3D} = {A1606EEC-6AC5-4779-B140-F57089F5A05F} {BBF5E860-A880-450B-B6C9-EF92F6421B3D} = {A1606EEC-6AC5-4779-B140-F57089F5A05F}
{03308684-19AC-454B-8CD3-AB1C26B8BBBF} = {A1606EEC-6AC5-4779-B140-F57089F5A05F} {03308684-19AC-454B-8CD3-AB1C26B8BBBF} = {A1606EEC-6AC5-4779-B140-F57089F5A05F}
{CA0D0B52-FC6A-49B5-A775-A754565BE813} = {A1606EEC-6AC5-4779-B140-F57089F5A05F}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F24E44CA-98BA-4B44-A1E1-57912CC5DCC3} SolutionGuid = {F24E44CA-98BA-4B44-A1E1-57912CC5DCC3}

View File

@ -18,5 +18,8 @@ namespace CodeLiturgy.Data.Application.Users
public partial class ApplicationUser : IdentityUser<string> public partial class ApplicationUser : IdentityUser<string>
{ {
public List<SiteEnvironment> Environments { get; set; } public List<SiteEnvironment> Environments { get; set; }
public List<Site> Sites { get; set; }
} }
} }

View File

@ -1,5 +1,6 @@
using System; using System;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using CodeLiturgy.Data.Application.Users;
using MapTo; using MapTo;
namespace CodeLiturgy.Data.Application namespace CodeLiturgy.Data.Application
@ -18,8 +19,11 @@ namespace CodeLiturgy.Data.Application
public SiteEnvironment Environment { get; set; } public SiteEnvironment Environment { get; set; }
public string EnvironmentId { get; set; } public string EnvironmentId { get; set; }
public string Domain { get; set; } public string Domain { get; set; }
public ApplicationUser User { get; set; }
public string UserId { get; set; }
public string UrlAddress { get; set; } public string UrlAddress { get; set; }
public SiteType SiteType { get; set; } public SiteType SiteType { get; set; }
public DateTime CreatedDate { get; set; } public DateTime CreatedDate { get; set; }
public DateTime LastChanged { get; set; } public DateTime LastChanged { get; set; }
} }

View File

@ -44,7 +44,6 @@ namespace CodeLiturgy.Domain
#region Initialization #region Initialization
public ApplicationUserDbContext(DbContextOptions<ApplicationUserDbContext> options) : base(options) public ApplicationUserDbContext(DbContextOptions<ApplicationUserDbContext> options) : base(options)
{ {
Database.EnsureCreated();
} }
@ -55,7 +54,6 @@ namespace CodeLiturgy.Domain
builder.ConfigureCurrentDbModel(); builder.ConfigureCurrentDbModel();
} }
#endregion #endregion

View File

@ -25,7 +25,6 @@ namespace CodeLiturgy.Domain
/// <param name="options"></param> /// <param name="options"></param>
public SiteDbContext(DbContextOptions<SiteDbContext> options) : base(options) public SiteDbContext(DbContextOptions<SiteDbContext> options) : base(options)
{ {
Database.EnsureCreated();
} }
protected override void OnModelCreating(ModelBuilder modelBuilder) protected override void OnModelCreating(ModelBuilder modelBuilder)

View File

@ -0,0 +1,404 @@
// <auto-generated />
using System;
using CodeLiturgy.Domain;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace CodeLiturgy.Views.Migrations
{
[DbContext(typeof(ApplicationUserDbContext))]
[Migration("20221126001445_Init")]
partial class Init
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "6.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("CodeLiturgy.Data.Application.Site", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("text");
b.Property<DateTime>("CreatedDate")
.HasColumnType("timestamp with time zone");
b.Property<string>("Domain")
.HasColumnType("text");
b.Property<string>("EnvironmentId")
.HasColumnType("text");
b.Property<DateTime>("LastChanged")
.HasColumnType("timestamp with time zone");
b.Property<int>("SiteType")
.HasColumnType("integer");
b.Property<string>("UrlAddress")
.HasColumnType("text");
b.Property<string>("UserId")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("EnvironmentId");
b.HasIndex("UserId");
b.ToTable("Site");
});
modelBuilder.Entity("CodeLiturgy.Data.Application.SiteEnvironment", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<string>("UserId")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("SiteEnvironment");
});
modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationRole", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("NormalizedName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasDatabaseName("RoleNameIndex");
b.ToTable("Roles", (string)null);
});
modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationRoleClaim", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ApplicationRoleId")
.HasColumnType("text");
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<string>("RoleId")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ApplicationRoleId");
b.HasIndex("RoleId");
b.ToTable("RoleClaims", (string)null);
});
modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationUser", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<int>("AccessFailedCount")
.HasColumnType("integer");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<string>("Email")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<bool>("EmailConfirmed")
.HasColumnType("boolean");
b.Property<bool>("LockoutEnabled")
.HasColumnType("boolean");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("timestamp with time zone");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("NormalizedUserName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("PasswordHash")
.HasColumnType("text");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("boolean");
b.Property<string>("SecurityStamp")
.HasColumnType("text");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("boolean");
b.Property<string>("UserName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasDatabaseName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasDatabaseName("UserNameIndex");
b.ToTable("ApplicationUser", (string)null);
});
modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationUserClaim", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ApplicationUserId")
.HasColumnType("text");
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ApplicationUserId");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims", (string)null);
});
modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationUserLogin", b =>
{
b.Property<string>("LoginProvider")
.HasColumnType("text");
b.Property<string>("ProviderKey")
.HasColumnType("text");
b.Property<string>("ProviderDisplayName")
.HasColumnType("text");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("text");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins", (string)null);
});
modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationUserRole", b =>
{
b.Property<string>("UserId")
.HasColumnType("text");
b.Property<string>("RoleId")
.HasColumnType("text");
b.Property<string>("ApplicationRoleId")
.HasColumnType("text");
b.HasKey("UserId", "RoleId");
b.HasIndex("ApplicationRoleId");
b.HasIndex("RoleId");
b.ToTable("UserRole", (string)null);
});
modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationUserToken", b =>
{
b.Property<string>("UserId")
.HasColumnType("text");
b.Property<string>("LoginProvider")
.HasColumnType("text");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("Value")
.HasColumnType("text");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens", (string)null);
});
modelBuilder.Entity("CodeLiturgy.Data.Application.Site", b =>
{
b.HasOne("CodeLiturgy.Data.Application.SiteEnvironment", "Environment")
.WithMany("Sites")
.HasForeignKey("EnvironmentId");
b.HasOne("CodeLiturgy.Data.Application.Users.ApplicationUser", "User")
.WithMany("Sites")
.HasForeignKey("UserId");
b.Navigation("Environment");
b.Navigation("User");
});
modelBuilder.Entity("CodeLiturgy.Data.Application.SiteEnvironment", b =>
{
b.HasOne("CodeLiturgy.Data.Application.Users.ApplicationUser", "User")
.WithMany("Environments")
.HasForeignKey("UserId");
b.Navigation("User");
});
modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationRoleClaim", b =>
{
b.HasOne("CodeLiturgy.Data.Application.Users.ApplicationRole", "ApplicationRole")
.WithMany()
.HasForeignKey("ApplicationRoleId");
b.HasOne("CodeLiturgy.Data.Application.Users.ApplicationRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("ApplicationRole");
});
modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationUserClaim", b =>
{
b.HasOne("CodeLiturgy.Data.Application.Users.ApplicationUser", "ApplicationUser")
.WithMany()
.HasForeignKey("ApplicationUserId");
b.HasOne("CodeLiturgy.Data.Application.Users.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("ApplicationUser");
});
modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationUserLogin", b =>
{
b.HasOne("CodeLiturgy.Data.Application.Users.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationUserRole", b =>
{
b.HasOne("CodeLiturgy.Data.Application.Users.ApplicationRole", "ApplicationRole")
.WithMany()
.HasForeignKey("ApplicationRoleId");
b.HasOne("CodeLiturgy.Data.Application.Users.ApplicationRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CodeLiturgy.Data.Application.Users.ApplicationUser", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("ApplicationRole");
b.Navigation("User");
});
modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationUserToken", b =>
{
b.HasOne("CodeLiturgy.Data.Application.Users.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("CodeLiturgy.Data.Application.SiteEnvironment", b =>
{
b.Navigation("Sites");
});
modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationUser", b =>
{
b.Navigation("Environments");
b.Navigation("Sites");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,519 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CodeLiturgy.Views.Migrations
{
public partial class Init : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_AspNetRoleClaims_AspNetRoles_ApplicationRoleId",
table: "AspNetRoleClaims");
migrationBuilder.DropForeignKey(
name: "FK_AspNetRoleClaims_AspNetRoles_RoleId",
table: "AspNetRoleClaims");
migrationBuilder.DropForeignKey(
name: "FK_AspNetUserClaims_AspNetUsers_ApplicationUserId",
table: "AspNetUserClaims");
migrationBuilder.DropForeignKey(
name: "FK_AspNetUserClaims_AspNetUsers_UserId",
table: "AspNetUserClaims");
migrationBuilder.DropForeignKey(
name: "FK_AspNetUserLogins_AspNetUsers_UserId",
table: "AspNetUserLogins");
migrationBuilder.DropForeignKey(
name: "FK_AspNetUserRoles_AspNetRoles_ApplicationRoleId",
table: "AspNetUserRoles");
migrationBuilder.DropForeignKey(
name: "FK_AspNetUserRoles_AspNetRoles_RoleId",
table: "AspNetUserRoles");
migrationBuilder.DropForeignKey(
name: "FK_AspNetUserRoles_AspNetUsers_UserId",
table: "AspNetUserRoles");
migrationBuilder.DropForeignKey(
name: "FK_AspNetUserRoles_AspNetUsers_UserId1",
table: "AspNetUserRoles");
migrationBuilder.DropForeignKey(
name: "FK_AspNetUserTokens_AspNetUsers_UserId",
table: "AspNetUserTokens");
migrationBuilder.DropForeignKey(
name: "FK_Site_site_env_EnvironmentId",
table: "Site");
migrationBuilder.DropForeignKey(
name: "FK_site_env_AspNetUsers_UserId",
table: "site_env");
migrationBuilder.DropPrimaryKey(
name: "PK_site_env",
table: "site_env");
migrationBuilder.DropPrimaryKey(
name: "PK_AspNetUsers",
table: "AspNetUsers");
migrationBuilder.DropPrimaryKey(
name: "PK_AspNetUserRoles",
table: "AspNetUserRoles");
migrationBuilder.DropIndex(
name: "IX_AspNetUserRoles_UserId1",
table: "AspNetUserRoles");
migrationBuilder.DropPrimaryKey(
name: "PK_AspNetRoles",
table: "AspNetRoles");
migrationBuilder.DropPrimaryKey(
name: "PK_AspNetRoleClaims",
table: "AspNetRoleClaims");
migrationBuilder.DropColumn(
name: "UserId1",
table: "AspNetUserRoles");
migrationBuilder.RenameTable(
name: "site_env",
newName: "SiteEnvironment");
migrationBuilder.RenameTable(
name: "AspNetUsers",
newName: "ApplicationUser");
migrationBuilder.RenameTable(
name: "AspNetUserRoles",
newName: "UserRole");
migrationBuilder.RenameTable(
name: "AspNetRoles",
newName: "Roles");
migrationBuilder.RenameTable(
name: "AspNetRoleClaims",
newName: "RoleClaims");
migrationBuilder.RenameColumn(
name: "EnvironmentType",
table: "Site",
newName: "SiteType");
migrationBuilder.RenameIndex(
name: "IX_site_env_UserId",
table: "SiteEnvironment",
newName: "IX_SiteEnvironment_UserId");
migrationBuilder.RenameIndex(
name: "IX_AspNetUserRoles_RoleId",
table: "UserRole",
newName: "IX_UserRole_RoleId");
migrationBuilder.RenameIndex(
name: "IX_AspNetUserRoles_ApplicationRoleId",
table: "UserRole",
newName: "IX_UserRole_ApplicationRoleId");
migrationBuilder.RenameIndex(
name: "IX_AspNetRoleClaims_RoleId",
table: "RoleClaims",
newName: "IX_RoleClaims_RoleId");
migrationBuilder.RenameIndex(
name: "IX_AspNetRoleClaims_ApplicationRoleId",
table: "RoleClaims",
newName: "IX_RoleClaims_ApplicationRoleId");
migrationBuilder.AddColumn<string>(
name: "UserId",
table: "Site",
type: "text",
nullable: true);
migrationBuilder.AddPrimaryKey(
name: "PK_SiteEnvironment",
table: "SiteEnvironment",
column: "Id");
migrationBuilder.AddPrimaryKey(
name: "PK_ApplicationUser",
table: "ApplicationUser",
column: "Id");
migrationBuilder.AddPrimaryKey(
name: "PK_UserRole",
table: "UserRole",
columns: new[] { "UserId", "RoleId" });
migrationBuilder.AddPrimaryKey(
name: "PK_Roles",
table: "Roles",
column: "Id");
migrationBuilder.AddPrimaryKey(
name: "PK_RoleClaims",
table: "RoleClaims",
column: "Id");
migrationBuilder.CreateIndex(
name: "IX_Site_UserId",
table: "Site",
column: "UserId");
migrationBuilder.AddForeignKey(
name: "FK_AspNetUserClaims_ApplicationUser_ApplicationUserId",
table: "AspNetUserClaims",
column: "ApplicationUserId",
principalTable: "ApplicationUser",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_AspNetUserClaims_ApplicationUser_UserId",
table: "AspNetUserClaims",
column: "UserId",
principalTable: "ApplicationUser",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_AspNetUserLogins_ApplicationUser_UserId",
table: "AspNetUserLogins",
column: "UserId",
principalTable: "ApplicationUser",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_AspNetUserTokens_ApplicationUser_UserId",
table: "AspNetUserTokens",
column: "UserId",
principalTable: "ApplicationUser",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_RoleClaims_Roles_ApplicationRoleId",
table: "RoleClaims",
column: "ApplicationRoleId",
principalTable: "Roles",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_RoleClaims_Roles_RoleId",
table: "RoleClaims",
column: "RoleId",
principalTable: "Roles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Site_ApplicationUser_UserId",
table: "Site",
column: "UserId",
principalTable: "ApplicationUser",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Site_SiteEnvironment_EnvironmentId",
table: "Site",
column: "EnvironmentId",
principalTable: "SiteEnvironment",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_SiteEnvironment_ApplicationUser_UserId",
table: "SiteEnvironment",
column: "UserId",
principalTable: "ApplicationUser",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_UserRole_ApplicationUser_UserId",
table: "UserRole",
column: "UserId",
principalTable: "ApplicationUser",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_UserRole_Roles_ApplicationRoleId",
table: "UserRole",
column: "ApplicationRoleId",
principalTable: "Roles",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_UserRole_Roles_RoleId",
table: "UserRole",
column: "RoleId",
principalTable: "Roles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_AspNetUserClaims_ApplicationUser_ApplicationUserId",
table: "AspNetUserClaims");
migrationBuilder.DropForeignKey(
name: "FK_AspNetUserClaims_ApplicationUser_UserId",
table: "AspNetUserClaims");
migrationBuilder.DropForeignKey(
name: "FK_AspNetUserLogins_ApplicationUser_UserId",
table: "AspNetUserLogins");
migrationBuilder.DropForeignKey(
name: "FK_AspNetUserTokens_ApplicationUser_UserId",
table: "AspNetUserTokens");
migrationBuilder.DropForeignKey(
name: "FK_RoleClaims_Roles_ApplicationRoleId",
table: "RoleClaims");
migrationBuilder.DropForeignKey(
name: "FK_RoleClaims_Roles_RoleId",
table: "RoleClaims");
migrationBuilder.DropForeignKey(
name: "FK_Site_ApplicationUser_UserId",
table: "Site");
migrationBuilder.DropForeignKey(
name: "FK_Site_SiteEnvironment_EnvironmentId",
table: "Site");
migrationBuilder.DropForeignKey(
name: "FK_SiteEnvironment_ApplicationUser_UserId",
table: "SiteEnvironment");
migrationBuilder.DropForeignKey(
name: "FK_UserRole_ApplicationUser_UserId",
table: "UserRole");
migrationBuilder.DropForeignKey(
name: "FK_UserRole_Roles_ApplicationRoleId",
table: "UserRole");
migrationBuilder.DropForeignKey(
name: "FK_UserRole_Roles_RoleId",
table: "UserRole");
migrationBuilder.DropIndex(
name: "IX_Site_UserId",
table: "Site");
migrationBuilder.DropPrimaryKey(
name: "PK_UserRole",
table: "UserRole");
migrationBuilder.DropPrimaryKey(
name: "PK_SiteEnvironment",
table: "SiteEnvironment");
migrationBuilder.DropPrimaryKey(
name: "PK_Roles",
table: "Roles");
migrationBuilder.DropPrimaryKey(
name: "PK_RoleClaims",
table: "RoleClaims");
migrationBuilder.DropPrimaryKey(
name: "PK_ApplicationUser",
table: "ApplicationUser");
migrationBuilder.DropColumn(
name: "UserId",
table: "Site");
migrationBuilder.RenameTable(
name: "UserRole",
newName: "AspNetUserRoles");
migrationBuilder.RenameTable(
name: "SiteEnvironment",
newName: "site_env");
migrationBuilder.RenameTable(
name: "Roles",
newName: "AspNetRoles");
migrationBuilder.RenameTable(
name: "RoleClaims",
newName: "AspNetRoleClaims");
migrationBuilder.RenameTable(
name: "ApplicationUser",
newName: "AspNetUsers");
migrationBuilder.RenameColumn(
name: "SiteType",
table: "Site",
newName: "EnvironmentType");
migrationBuilder.RenameIndex(
name: "IX_UserRole_RoleId",
table: "AspNetUserRoles",
newName: "IX_AspNetUserRoles_RoleId");
migrationBuilder.RenameIndex(
name: "IX_UserRole_ApplicationRoleId",
table: "AspNetUserRoles",
newName: "IX_AspNetUserRoles_ApplicationRoleId");
migrationBuilder.RenameIndex(
name: "IX_SiteEnvironment_UserId",
table: "site_env",
newName: "IX_site_env_UserId");
migrationBuilder.RenameIndex(
name: "IX_RoleClaims_RoleId",
table: "AspNetRoleClaims",
newName: "IX_AspNetRoleClaims_RoleId");
migrationBuilder.RenameIndex(
name: "IX_RoleClaims_ApplicationRoleId",
table: "AspNetRoleClaims",
newName: "IX_AspNetRoleClaims_ApplicationRoleId");
migrationBuilder.AddColumn<string>(
name: "UserId1",
table: "AspNetUserRoles",
type: "text",
nullable: true);
migrationBuilder.AddPrimaryKey(
name: "PK_AspNetUserRoles",
table: "AspNetUserRoles",
columns: new[] { "UserId", "RoleId" });
migrationBuilder.AddPrimaryKey(
name: "PK_site_env",
table: "site_env",
column: "Id");
migrationBuilder.AddPrimaryKey(
name: "PK_AspNetRoles",
table: "AspNetRoles",
column: "Id");
migrationBuilder.AddPrimaryKey(
name: "PK_AspNetRoleClaims",
table: "AspNetRoleClaims",
column: "Id");
migrationBuilder.AddPrimaryKey(
name: "PK_AspNetUsers",
table: "AspNetUsers",
column: "Id");
migrationBuilder.CreateIndex(
name: "IX_AspNetUserRoles_UserId1",
table: "AspNetUserRoles",
column: "UserId1");
migrationBuilder.AddForeignKey(
name: "FK_AspNetRoleClaims_AspNetRoles_ApplicationRoleId",
table: "AspNetRoleClaims",
column: "ApplicationRoleId",
principalTable: "AspNetRoles",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_AspNetRoleClaims_AspNetRoles_RoleId",
table: "AspNetRoleClaims",
column: "RoleId",
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_AspNetUserClaims_AspNetUsers_ApplicationUserId",
table: "AspNetUserClaims",
column: "ApplicationUserId",
principalTable: "AspNetUsers",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_AspNetUserClaims_AspNetUsers_UserId",
table: "AspNetUserClaims",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_AspNetUserLogins_AspNetUsers_UserId",
table: "AspNetUserLogins",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_AspNetUserRoles_AspNetRoles_ApplicationRoleId",
table: "AspNetUserRoles",
column: "ApplicationRoleId",
principalTable: "AspNetRoles",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_AspNetUserRoles_AspNetRoles_RoleId",
table: "AspNetUserRoles",
column: "RoleId",
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_AspNetUserRoles_AspNetUsers_UserId",
table: "AspNetUserRoles",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_AspNetUserRoles_AspNetUsers_UserId1",
table: "AspNetUserRoles",
column: "UserId1",
principalTable: "AspNetUsers",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_AspNetUserTokens_AspNetUsers_UserId",
table: "AspNetUserTokens",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Site_site_env_EnvironmentId",
table: "Site",
column: "EnvironmentId",
principalTable: "site_env",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_site_env_AspNetUsers_UserId",
table: "site_env",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id");
}
}
}

View File

@ -17,7 +17,7 @@ namespace CodeLiturgy.Views.Migrations
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.HasAnnotation("ProductVersion", "7.0.0") .HasAnnotation("ProductVersion", "6.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 63); .HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
@ -37,19 +37,24 @@ namespace CodeLiturgy.Views.Migrations
b.Property<string>("EnvironmentId") b.Property<string>("EnvironmentId")
.HasColumnType("text"); .HasColumnType("text");
b.Property<int>("EnvironmentType")
.HasColumnType("integer");
b.Property<DateTime>("LastChanged") b.Property<DateTime>("LastChanged")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp with time zone");
b.Property<int>("SiteType")
.HasColumnType("integer");
b.Property<string>("UrlAddress") b.Property<string>("UrlAddress")
.HasColumnType("text"); .HasColumnType("text");
b.Property<string>("UserId")
.HasColumnType("text");
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("EnvironmentId"); b.HasIndex("EnvironmentId");
b.HasIndex("UserId");
b.ToTable("Site"); b.ToTable("Site");
}); });
@ -68,7 +73,7 @@ namespace CodeLiturgy.Views.Migrations
b.HasIndex("UserId"); b.HasIndex("UserId");
b.ToTable("site_env", (string)null); b.ToTable("SiteEnvironment");
}); });
modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationRole", b => modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationRole", b =>
@ -94,7 +99,7 @@ namespace CodeLiturgy.Views.Migrations
.IsUnique() .IsUnique()
.HasDatabaseName("RoleNameIndex"); .HasDatabaseName("RoleNameIndex");
b.ToTable("AspNetRoles", (string)null); b.ToTable("Roles", (string)null);
}); });
modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationRoleClaim", b => modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationRoleClaim", b =>
@ -124,7 +129,7 @@ namespace CodeLiturgy.Views.Migrations
b.HasIndex("RoleId"); b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims", (string)null); b.ToTable("RoleClaims", (string)null);
}); });
modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationUser", b => modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationUser", b =>
@ -188,7 +193,7 @@ namespace CodeLiturgy.Views.Migrations
.IsUnique() .IsUnique()
.HasDatabaseName("UserNameIndex"); .HasDatabaseName("UserNameIndex");
b.ToTable("AspNetUsers", (string)null); b.ToTable("ApplicationUser", (string)null);
}); });
modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationUserClaim", b => modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationUserClaim", b =>
@ -254,18 +259,13 @@ namespace CodeLiturgy.Views.Migrations
b.Property<string>("ApplicationRoleId") b.Property<string>("ApplicationRoleId")
.HasColumnType("text"); .HasColumnType("text");
b.Property<string>("UserId1")
.HasColumnType("text");
b.HasKey("UserId", "RoleId"); b.HasKey("UserId", "RoleId");
b.HasIndex("ApplicationRoleId"); b.HasIndex("ApplicationRoleId");
b.HasIndex("RoleId"); b.HasIndex("RoleId");
b.HasIndex("UserId1"); b.ToTable("UserRole", (string)null);
b.ToTable("AspNetUserRoles", (string)null);
}); });
modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationUserToken", b => modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationUserToken", b =>
@ -296,7 +296,13 @@ namespace CodeLiturgy.Views.Migrations
.WithMany("Sites") .WithMany("Sites")
.HasForeignKey("EnvironmentId"); .HasForeignKey("EnvironmentId");
b.HasOne("CodeLiturgy.Data.Application.Users.ApplicationUser", "User")
.WithMany("Sites")
.HasForeignKey("UserId");
b.Navigation("Environment"); b.Navigation("Environment");
b.Navigation("User");
}); });
modelBuilder.Entity("CodeLiturgy.Data.Application.SiteEnvironment", b => modelBuilder.Entity("CodeLiturgy.Data.Application.SiteEnvironment", b =>
@ -359,16 +365,12 @@ namespace CodeLiturgy.Views.Migrations
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("CodeLiturgy.Data.Application.Users.ApplicationUser", null) b.HasOne("CodeLiturgy.Data.Application.Users.ApplicationUser", "User")
.WithMany() .WithMany()
.HasForeignKey("UserId") .HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("CodeLiturgy.Data.Application.Users.ApplicationUser", "User")
.WithMany()
.HasForeignKey("UserId1");
b.Navigation("ApplicationRole"); b.Navigation("ApplicationRole");
b.Navigation("User"); b.Navigation("User");
@ -391,6 +393,8 @@ namespace CodeLiturgy.Views.Migrations
modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationUser", b => modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationUser", b =>
{ {
b.Navigation("Environments"); b.Navigation("Environments");
b.Navigation("Sites");
}); });
#pragma warning restore 612, 618 #pragma warning restore 612, 618
} }

View File

@ -1,159 +0,0 @@
// <auto-generated />
using System;
using CodeLiturgy.Domain;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace CodeLiturgy.Views.Migrations.SiteDb
{
[DbContext(typeof(SiteDbContext))]
[Migration("20221118003609_first")]
partial class first
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("CodeLiturgy.Data.Application.Site", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("text");
b.Property<DateTime>("CreatedDate")
.HasColumnType("timestamp with time zone");
b.Property<string>("Domain")
.HasColumnType("text");
b.Property<string>("EnvironmentId")
.HasColumnType("text");
b.Property<int>("EnvironmentType")
.HasColumnType("integer");
b.Property<DateTime>("LastChanged")
.HasColumnType("timestamp with time zone");
b.Property<string>("UrlAddress")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("EnvironmentId");
b.ToTable("Sites");
});
modelBuilder.Entity("CodeLiturgy.Data.Application.SiteEnvironment", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<string>("UserId")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Environments");
});
modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationUser", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<int>("AccessFailedCount")
.HasColumnType("integer");
b.Property<string>("ConcurrencyStamp")
.HasColumnType("text");
b.Property<string>("Email")
.HasColumnType("text");
b.Property<bool>("EmailConfirmed")
.HasColumnType("boolean");
b.Property<bool>("LockoutEnabled")
.HasColumnType("boolean");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("timestamp with time zone");
b.Property<string>("NormalizedEmail")
.HasColumnType("text");
b.Property<string>("NormalizedUserName")
.HasColumnType("text");
b.Property<string>("PasswordHash")
.HasColumnType("text");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("boolean");
b.Property<string>("SecurityStamp")
.HasColumnType("text");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("boolean");
b.Property<string>("UserName")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("ApplicationUser");
});
modelBuilder.Entity("CodeLiturgy.Data.Application.Site", b =>
{
b.HasOne("CodeLiturgy.Data.Application.SiteEnvironment", "Environment")
.WithMany("Sites")
.HasForeignKey("EnvironmentId");
b.Navigation("Environment");
});
modelBuilder.Entity("CodeLiturgy.Data.Application.SiteEnvironment", b =>
{
b.HasOne("CodeLiturgy.Data.Application.Users.ApplicationUser", "User")
.WithMany("Environments")
.HasForeignKey("UserId");
b.Navigation("User");
});
modelBuilder.Entity("CodeLiturgy.Data.Application.SiteEnvironment", b =>
{
b.Navigation("Sites");
});
modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationUser", b =>
{
b.Navigation("Environments");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -1,103 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CodeLiturgy.Views.Migrations.SiteDb
{
/// <inheritdoc />
public partial class first : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "ApplicationUser",
columns: table => new
{
Id = table.Column<string>(type: "text", nullable: false),
UserName = table.Column<string>(type: "text", nullable: true),
NormalizedUserName = table.Column<string>(type: "text", nullable: true),
Email = table.Column<string>(type: "text", nullable: true),
NormalizedEmail = table.Column<string>(type: "text", nullable: true),
EmailConfirmed = table.Column<bool>(type: "boolean", nullable: false),
PasswordHash = table.Column<string>(type: "text", nullable: true),
SecurityStamp = table.Column<string>(type: "text", nullable: true),
ConcurrencyStamp = table.Column<string>(type: "text", nullable: true),
PhoneNumber = table.Column<string>(type: "text", nullable: true),
PhoneNumberConfirmed = table.Column<bool>(type: "boolean", nullable: false),
TwoFactorEnabled = table.Column<bool>(type: "boolean", nullable: false),
LockoutEnd = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
LockoutEnabled = table.Column<bool>(type: "boolean", nullable: false),
AccessFailedCount = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ApplicationUser", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Environments",
columns: table => new
{
Id = table.Column<string>(type: "text", nullable: false),
Name = table.Column<string>(type: "text", nullable: true),
UserId = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Environments", x => x.Id);
table.ForeignKey(
name: "FK_Environments_ApplicationUser_UserId",
column: x => x.UserId,
principalTable: "ApplicationUser",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "Sites",
columns: table => new
{
Id = table.Column<string>(type: "text", nullable: false),
EnvironmentId = table.Column<string>(type: "text", nullable: true),
Domain = table.Column<string>(type: "text", nullable: true),
UrlAddress = table.Column<string>(type: "text", nullable: true),
EnvironmentType = table.Column<int>(type: "integer", nullable: false),
CreatedDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
LastChanged = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Sites", x => x.Id);
table.ForeignKey(
name: "FK_Sites_Environments_EnvironmentId",
column: x => x.EnvironmentId,
principalTable: "Environments",
principalColumn: "Id");
});
migrationBuilder.CreateIndex(
name: "IX_Environments_UserId",
table: "Environments",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_Sites_EnvironmentId",
table: "Sites",
column: "EnvironmentId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Sites");
migrationBuilder.DropTable(
name: "Environments");
migrationBuilder.DropTable(
name: "ApplicationUser");
}
}
}

View File

@ -0,0 +1,321 @@
// <auto-generated />
using System;
using CodeLiturgy.Domain;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace CodeLiturgy.Views.Migrations.SiteDb
{
[DbContext(typeof(SiteDbContext))]
[Migration("20221126003051_Init")]
partial class Init
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "6.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("CodeLiturgy.Data.Application.Site", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("text");
b.Property<DateTime>("CreatedDate")
.HasColumnType("timestamp with time zone");
b.Property<string>("Domain")
.HasColumnType("text");
b.Property<string>("EnvironmentId")
.HasColumnType("text");
b.Property<DateTime>("LastChanged")
.HasColumnType("timestamp with time zone");
b.Property<int>("SiteType")
.HasColumnType("integer");
b.Property<string>("UrlAddress")
.HasColumnType("text");
b.Property<string>("UserId")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("EnvironmentId");
b.HasIndex("UserId");
b.ToTable("Sites");
});
modelBuilder.Entity("CodeLiturgy.Data.Application.SiteEnvironment", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<string>("UserId")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Environments");
});
modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationRole", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("NormalizedName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasDatabaseName("RoleNameIndex");
b.ToTable("Roles", (string)null);
});
modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationRoleClaim", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ApplicationRoleId")
.HasColumnType("text");
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<string>("RoleId")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ApplicationRoleId");
b.HasIndex("RoleId");
b.ToTable("RoleClaims", (string)null);
});
modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationUser", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<int>("AccessFailedCount")
.HasColumnType("integer");
b.Property<string>("ConcurrencyStamp")
.HasColumnType("text");
b.Property<string>("Email")
.HasColumnType("text");
b.Property<bool>("EmailConfirmed")
.HasColumnType("boolean");
b.Property<bool>("LockoutEnabled")
.HasColumnType("boolean");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("timestamp with time zone");
b.Property<string>("NormalizedEmail")
.HasColumnType("text");
b.Property<string>("NormalizedUserName")
.HasColumnType("text");
b.Property<string>("PasswordHash")
.HasColumnType("text");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("boolean");
b.Property<string>("SecurityStamp")
.HasColumnType("text");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("boolean");
b.Property<string>("UserName")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("ApplicationUser", (string)null);
});
modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationUserClaim", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ApplicationUserId")
.HasColumnType("text");
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<string>("UserId")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ApplicationUserId");
b.ToTable("ApplicationUserClaim");
});
modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationUserRole", b =>
{
b.Property<string>("UserId")
.HasColumnType("text");
b.Property<string>("RoleId")
.HasColumnType("text");
b.Property<string>("ApplicationRoleId")
.HasColumnType("text");
b.HasKey("UserId", "RoleId");
b.HasIndex("ApplicationRoleId");
b.HasIndex("RoleId");
b.ToTable("UserRole", (string)null);
});
modelBuilder.Entity("CodeLiturgy.Data.Application.Site", b =>
{
b.HasOne("CodeLiturgy.Data.Application.SiteEnvironment", "Environment")
.WithMany("Sites")
.HasForeignKey("EnvironmentId");
b.HasOne("CodeLiturgy.Data.Application.Users.ApplicationUser", "User")
.WithMany("Sites")
.HasForeignKey("UserId");
b.Navigation("Environment");
b.Navigation("User");
});
modelBuilder.Entity("CodeLiturgy.Data.Application.SiteEnvironment", b =>
{
b.HasOne("CodeLiturgy.Data.Application.Users.ApplicationUser", "User")
.WithMany("Environments")
.HasForeignKey("UserId");
b.Navigation("User");
});
modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationRoleClaim", b =>
{
b.HasOne("CodeLiturgy.Data.Application.Users.ApplicationRole", "ApplicationRole")
.WithMany()
.HasForeignKey("ApplicationRoleId");
b.HasOne("CodeLiturgy.Data.Application.Users.ApplicationRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("ApplicationRole");
});
modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationUserClaim", b =>
{
b.HasOne("CodeLiturgy.Data.Application.Users.ApplicationUser", "ApplicationUser")
.WithMany()
.HasForeignKey("ApplicationUserId");
b.Navigation("ApplicationUser");
});
modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationUserRole", b =>
{
b.HasOne("CodeLiturgy.Data.Application.Users.ApplicationRole", "ApplicationRole")
.WithMany()
.HasForeignKey("ApplicationRoleId");
b.HasOne("CodeLiturgy.Data.Application.Users.ApplicationRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CodeLiturgy.Data.Application.Users.ApplicationUser", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("ApplicationRole");
b.Navigation("User");
});
modelBuilder.Entity("CodeLiturgy.Data.Application.SiteEnvironment", b =>
{
b.Navigation("Sites");
});
modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationUser", b =>
{
b.Navigation("Environments");
b.Navigation("Sites");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,247 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace CodeLiturgy.Views.Migrations.SiteDb
{
public partial class Init : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "ApplicationUser",
columns: table => new
{
Id = table.Column<string>(type: "text", nullable: false),
UserName = table.Column<string>(type: "text", nullable: true),
NormalizedUserName = table.Column<string>(type: "text", nullable: true),
Email = table.Column<string>(type: "text", nullable: true),
NormalizedEmail = table.Column<string>(type: "text", nullable: true),
EmailConfirmed = table.Column<bool>(type: "boolean", nullable: false),
PasswordHash = table.Column<string>(type: "text", nullable: true),
SecurityStamp = table.Column<string>(type: "text", nullable: true),
ConcurrencyStamp = table.Column<string>(type: "text", nullable: true),
PhoneNumber = table.Column<string>(type: "text", nullable: true),
PhoneNumberConfirmed = table.Column<bool>(type: "boolean", nullable: false),
TwoFactorEnabled = table.Column<bool>(type: "boolean", nullable: false),
LockoutEnd = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
LockoutEnabled = table.Column<bool>(type: "boolean", nullable: false),
AccessFailedCount = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ApplicationUser", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Roles",
columns: table => new
{
Id = table.Column<string>(type: "text", nullable: false),
Name = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
NormalizedName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
ConcurrencyStamp = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Roles", x => x.Id);
});
migrationBuilder.CreateTable(
name: "ApplicationUserClaim",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
UserId = table.Column<string>(type: "text", nullable: true),
ApplicationUserId = table.Column<string>(type: "text", nullable: true),
ClaimType = table.Column<string>(type: "text", nullable: true),
ClaimValue = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_ApplicationUserClaim", x => x.Id);
table.ForeignKey(
name: "FK_ApplicationUserClaim_ApplicationUser_ApplicationUserId",
column: x => x.ApplicationUserId,
principalTable: "ApplicationUser",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "Environments",
columns: table => new
{
Id = table.Column<string>(type: "text", nullable: false),
Name = table.Column<string>(type: "text", nullable: true),
UserId = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Environments", x => x.Id);
table.ForeignKey(
name: "FK_Environments_ApplicationUser_UserId",
column: x => x.UserId,
principalTable: "ApplicationUser",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "RoleClaims",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
RoleId = table.Column<string>(type: "text", nullable: false),
ApplicationRoleId = table.Column<string>(type: "text", nullable: true),
ClaimType = table.Column<string>(type: "text", nullable: true),
ClaimValue = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_RoleClaims", x => x.Id);
table.ForeignKey(
name: "FK_RoleClaims_Roles_ApplicationRoleId",
column: x => x.ApplicationRoleId,
principalTable: "Roles",
principalColumn: "Id");
table.ForeignKey(
name: "FK_RoleClaims_Roles_RoleId",
column: x => x.RoleId,
principalTable: "Roles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "UserRole",
columns: table => new
{
UserId = table.Column<string>(type: "text", nullable: false),
RoleId = table.Column<string>(type: "text", nullable: false),
ApplicationRoleId = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_UserRole", x => new { x.UserId, x.RoleId });
table.ForeignKey(
name: "FK_UserRole_ApplicationUser_UserId",
column: x => x.UserId,
principalTable: "ApplicationUser",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_UserRole_Roles_ApplicationRoleId",
column: x => x.ApplicationRoleId,
principalTable: "Roles",
principalColumn: "Id");
table.ForeignKey(
name: "FK_UserRole_Roles_RoleId",
column: x => x.RoleId,
principalTable: "Roles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Sites",
columns: table => new
{
Id = table.Column<string>(type: "text", nullable: false),
EnvironmentId = table.Column<string>(type: "text", nullable: true),
Domain = table.Column<string>(type: "text", nullable: true),
UserId = table.Column<string>(type: "text", nullable: true),
UrlAddress = table.Column<string>(type: "text", nullable: true),
SiteType = table.Column<int>(type: "integer", nullable: false),
CreatedDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
LastChanged = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Sites", x => x.Id);
table.ForeignKey(
name: "FK_Sites_ApplicationUser_UserId",
column: x => x.UserId,
principalTable: "ApplicationUser",
principalColumn: "Id");
table.ForeignKey(
name: "FK_Sites_Environments_EnvironmentId",
column: x => x.EnvironmentId,
principalTable: "Environments",
principalColumn: "Id");
});
migrationBuilder.CreateIndex(
name: "IX_ApplicationUserClaim_ApplicationUserId",
table: "ApplicationUserClaim",
column: "ApplicationUserId");
migrationBuilder.CreateIndex(
name: "IX_Environments_UserId",
table: "Environments",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_RoleClaims_ApplicationRoleId",
table: "RoleClaims",
column: "ApplicationRoleId");
migrationBuilder.CreateIndex(
name: "IX_RoleClaims_RoleId",
table: "RoleClaims",
column: "RoleId");
migrationBuilder.CreateIndex(
name: "RoleNameIndex",
table: "Roles",
column: "NormalizedName",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Sites_EnvironmentId",
table: "Sites",
column: "EnvironmentId");
migrationBuilder.CreateIndex(
name: "IX_Sites_UserId",
table: "Sites",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_UserRole_ApplicationRoleId",
table: "UserRole",
column: "ApplicationRoleId");
migrationBuilder.CreateIndex(
name: "IX_UserRole_RoleId",
table: "UserRole",
column: "RoleId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ApplicationUserClaim");
migrationBuilder.DropTable(
name: "RoleClaims");
migrationBuilder.DropTable(
name: "Sites");
migrationBuilder.DropTable(
name: "UserRole");
migrationBuilder.DropTable(
name: "Environments");
migrationBuilder.DropTable(
name: "Roles");
migrationBuilder.DropTable(
name: "ApplicationUser");
}
}
}

View File

@ -17,7 +17,7 @@ namespace CodeLiturgy.Views.Migrations.SiteDb
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.HasAnnotation("ProductVersion", "7.0.0") .HasAnnotation("ProductVersion", "6.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 63); .HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
@ -37,19 +37,24 @@ namespace CodeLiturgy.Views.Migrations.SiteDb
b.Property<string>("EnvironmentId") b.Property<string>("EnvironmentId")
.HasColumnType("text"); .HasColumnType("text");
b.Property<int>("EnvironmentType")
.HasColumnType("integer");
b.Property<DateTime>("LastChanged") b.Property<DateTime>("LastChanged")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp with time zone");
b.Property<int>("SiteType")
.HasColumnType("integer");
b.Property<string>("UrlAddress") b.Property<string>("UrlAddress")
.HasColumnType("text"); .HasColumnType("text");
b.Property<string>("UserId")
.HasColumnType("text");
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("EnvironmentId"); b.HasIndex("EnvironmentId");
b.HasIndex("UserId");
b.ToTable("Sites"); b.ToTable("Sites");
}); });
@ -71,6 +76,62 @@ namespace CodeLiturgy.Views.Migrations.SiteDb
b.ToTable("Environments"); b.ToTable("Environments");
}); });
modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationRole", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("NormalizedName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasDatabaseName("RoleNameIndex");
b.ToTable("Roles", (string)null);
});
modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationRoleClaim", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ApplicationRoleId")
.HasColumnType("text");
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<string>("RoleId")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ApplicationRoleId");
b.HasIndex("RoleId");
b.ToTable("RoleClaims", (string)null);
});
modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationUser", b => modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationUser", b =>
{ {
b.Property<string>("Id") b.Property<string>("Id")
@ -120,7 +181,54 @@ namespace CodeLiturgy.Views.Migrations.SiteDb
b.HasKey("Id"); b.HasKey("Id");
b.ToTable("ApplicationUser"); b.ToTable("ApplicationUser", (string)null);
});
modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationUserClaim", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ApplicationUserId")
.HasColumnType("text");
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<string>("UserId")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ApplicationUserId");
b.ToTable("ApplicationUserClaim");
});
modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationUserRole", b =>
{
b.Property<string>("UserId")
.HasColumnType("text");
b.Property<string>("RoleId")
.HasColumnType("text");
b.Property<string>("ApplicationRoleId")
.HasColumnType("text");
b.HasKey("UserId", "RoleId");
b.HasIndex("ApplicationRoleId");
b.HasIndex("RoleId");
b.ToTable("UserRole", (string)null);
}); });
modelBuilder.Entity("CodeLiturgy.Data.Application.Site", b => modelBuilder.Entity("CodeLiturgy.Data.Application.Site", b =>
@ -129,7 +237,13 @@ namespace CodeLiturgy.Views.Migrations.SiteDb
.WithMany("Sites") .WithMany("Sites")
.HasForeignKey("EnvironmentId"); .HasForeignKey("EnvironmentId");
b.HasOne("CodeLiturgy.Data.Application.Users.ApplicationUser", "User")
.WithMany("Sites")
.HasForeignKey("UserId");
b.Navigation("Environment"); b.Navigation("Environment");
b.Navigation("User");
}); });
modelBuilder.Entity("CodeLiturgy.Data.Application.SiteEnvironment", b => modelBuilder.Entity("CodeLiturgy.Data.Application.SiteEnvironment", b =>
@ -141,6 +255,53 @@ namespace CodeLiturgy.Views.Migrations.SiteDb
b.Navigation("User"); b.Navigation("User");
}); });
modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationRoleClaim", b =>
{
b.HasOne("CodeLiturgy.Data.Application.Users.ApplicationRole", "ApplicationRole")
.WithMany()
.HasForeignKey("ApplicationRoleId");
b.HasOne("CodeLiturgy.Data.Application.Users.ApplicationRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("ApplicationRole");
});
modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationUserClaim", b =>
{
b.HasOne("CodeLiturgy.Data.Application.Users.ApplicationUser", "ApplicationUser")
.WithMany()
.HasForeignKey("ApplicationUserId");
b.Navigation("ApplicationUser");
});
modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationUserRole", b =>
{
b.HasOne("CodeLiturgy.Data.Application.Users.ApplicationRole", "ApplicationRole")
.WithMany()
.HasForeignKey("ApplicationRoleId");
b.HasOne("CodeLiturgy.Data.Application.Users.ApplicationRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CodeLiturgy.Data.Application.Users.ApplicationUser", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("ApplicationRole");
b.Navigation("User");
});
modelBuilder.Entity("CodeLiturgy.Data.Application.SiteEnvironment", b => modelBuilder.Entity("CodeLiturgy.Data.Application.SiteEnvironment", b =>
{ {
b.Navigation("Sites"); b.Navigation("Sites");
@ -149,6 +310,8 @@ namespace CodeLiturgy.Views.Migrations.SiteDb
modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationUser", b => modelBuilder.Entity("CodeLiturgy.Data.Application.Users.ApplicationUser", b =>
{ {
b.Navigation("Environments"); b.Navigation("Environments");
b.Navigation("Sites");
}); });
#pragma warning restore 612, 618 #pragma warning restore 612, 618
} }

View File

@ -1,3 +1,4 @@
using CodeLiturgy.Data.Application;
using CodeLiturgy.Data.Application.Users; using CodeLiturgy.Data.Application.Users;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
@ -20,7 +21,8 @@ namespace CodeLiturgy.Domain.Model
{ {
modelBuilder modelBuilder
.ConfigureDatabaseKeys() .ConfigureDatabaseKeys()
.CurrencyModel() .EnvironmentModel()
.SiteModel()
.ConfigureUserModel() .ConfigureUserModel()
.ConfigureAppContextModel(); .ConfigureAppContextModel();
@ -107,9 +109,25 @@ namespace CodeLiturgy.Domain.Model
#region Database Models #region Database Models
private static ModelBuilder CurrencyModel(this ModelBuilder modelBuilder) private static ModelBuilder EnvironmentModel(this ModelBuilder modelBuilder)
{
modelBuilder
.Entity<SiteEnvironment>()
.HasMany<Site>(b => b.Sites)
.WithOne(x => x.Environment)
.HasForeignKey(x => x.EnvironmentId);
return modelBuilder;
}
private static ModelBuilder SiteModel(this ModelBuilder modelBuilder)
{ {
modelBuilder.Entity<Site>()
.HasOne(x => x.Environment)
.WithMany(x => x.Sites)
.HasForeignKey(x => x.EnvironmentId);
return modelBuilder; return modelBuilder;
} }
@ -117,6 +135,16 @@ namespace CodeLiturgy.Domain.Model
private static ModelBuilder ConfigureUserModel(this ModelBuilder modelBuilder) private static ModelBuilder ConfigureUserModel(this ModelBuilder modelBuilder)
{ {
modelBuilder
.Entity<ApplicationUser>()
.HasMany(x => x.Sites)
.WithOne(x => x.User);
modelBuilder
.Entity<ApplicationUser>()
.HasMany(x => x.Environments)
.WithOne(x => x.User);
return modelBuilder; return modelBuilder;
} }

File diff suppressed because one or more lines are too long