248 lines
11 KiB
C#
248 lines
11 KiB
C#
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");
|
|
}
|
|
}
|
|
}
|