Authinator/Migrations/20230601004614_32374F74-E406-4989-A326-8973BEBA3593.cs
2023-06-01 06:14:24 +02:00

149 lines
5.6 KiB
C#

using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Authinator.Migrations
{
/// <inheritdoc />
public partial class _32374F74E4064989A3268973BEBA3593 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "ACLs",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: false),
Target = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ACLs", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Networks",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Subnet = table.Column<string>(type: "TEXT", nullable: false),
Subnet1 = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Networks", x => x.Id);
});
migrationBuilder.CreateTable(
name: "ACLGroup",
columns: table => new
{
ACLId = table.Column<int>(type: "INTEGER", nullable: false),
GroupsId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ACLGroup", x => new { x.ACLId, x.GroupsId });
table.ForeignKey(
name: "FK_ACLGroup_ACLs_ACLId",
column: x => x.ACLId,
principalTable: "ACLs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ACLGroup_Groups_GroupsId",
column: x => x.GroupsId,
principalTable: "Groups",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ACLUser",
columns: table => new
{
ACLId = table.Column<int>(type: "INTEGER", nullable: false),
UsersId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ACLUser", x => new { x.ACLId, x.UsersId });
table.ForeignKey(
name: "FK_ACLUser_ACLs_ACLId",
column: x => x.ACLId,
principalTable: "ACLs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ACLUser_Users_UsersId",
column: x => x.UsersId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ACLNetwork",
columns: table => new
{
ACLId = table.Column<int>(type: "INTEGER", nullable: false),
NetworksId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ACLNetwork", x => new { x.ACLId, x.NetworksId });
table.ForeignKey(
name: "FK_ACLNetwork_ACLs_ACLId",
column: x => x.ACLId,
principalTable: "ACLs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ACLNetwork_Networks_NetworksId",
column: x => x.NetworksId,
principalTable: "Networks",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_ACLGroup_GroupsId",
table: "ACLGroup",
column: "GroupsId");
migrationBuilder.CreateIndex(
name: "IX_ACLNetwork_NetworksId",
table: "ACLNetwork",
column: "NetworksId");
migrationBuilder.CreateIndex(
name: "IX_ACLUser_UsersId",
table: "ACLUser",
column: "UsersId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ACLGroup");
migrationBuilder.DropTable(
name: "ACLNetwork");
migrationBuilder.DropTable(
name: "ACLUser");
migrationBuilder.DropTable(
name: "Networks");
migrationBuilder.DropTable(
name: "ACLs");
}
}
}