This commit is contained in:
code liturgy 2022-11-18 00:38:56 +00:00
parent 7091849e38
commit a0c6749bad
4 changed files with 426 additions and 0 deletions

View File

@ -1,6 +1,7 @@
using CodeLiturgy.Data.Application;
using Microsoft.EntityFrameworkCore;
using BlueWest.EfMethods;
using CodeLiturgy.Domain.Model;
namespace CodeLiturgy.Domain
{
@ -23,6 +24,13 @@ namespace CodeLiturgy.Domain
{
Database.EnsureCreated();
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.ConfigureCurrentDbModel();
}
}
}

View File

@ -0,0 +1,159 @@
// <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

@ -0,0 +1,103 @@
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,156 @@
// <auto-generated />
using System;
using CodeLiturgy.Domain;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace CodeLiturgy.Views.Migrations.SiteDb
{
[DbContext(typeof(SiteDbContext))]
partial class SiteDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(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
}
}
}