summaryrefslogtreecommitdiff
path: root/Migrations/20231001212740_Security.cs
diff options
context:
space:
mode:
authorJake Mannens <jake@asger.xyz>2023-10-03 16:41:58 +1100
committerJake Mannens <jake@asger.xyz>2023-10-03 16:41:58 +1100
commit33438ac951430fa370965b42a3d98a54e704ab01 (patch)
treefbd835c25ac7566e8437cd0ef988fce0596a15e7 /Migrations/20231001212740_Security.cs
parent7170867a9a2650fa5a98b9e2664fb2114a0bf114 (diff)
AclDialog
Diffstat (limited to 'Migrations/20231001212740_Security.cs')
-rw-r--r--Migrations/20231001212740_Security.cs312
1 files changed, 312 insertions, 0 deletions
diff --git a/Migrations/20231001212740_Security.cs b/Migrations/20231001212740_Security.cs
new file mode 100644
index 0000000..0e38fde
--- /dev/null
+++ b/Migrations/20231001212740_Security.cs
@@ -0,0 +1,312 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+
+#nullable disable
+
+namespace HyperBooru.Migrations
+{
+ /// <inheritdoc />
+ public partial class Security : Migration
+ {
+ /// <inheritdoc />
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropForeignKey(
+ name: "FK_TagDefinitionTagDefinition_TagDefinitions_ImplicitTagsObjec~",
+ table: "TagDefinitionTagDefinition");
+
+ migrationBuilder.DropForeignKey(
+ name: "FK_TagDefinitionTagDefinition_TagDefinitions_TagDefinitionObje~",
+ table: "TagDefinitionTagDefinition");
+
+ migrationBuilder.DropTable(
+ name: "Users");
+
+ migrationBuilder.DropPrimaryKey(
+ name: "PK_TagDefinitionTagDefinition",
+ table: "TagDefinitionTagDefinition");
+
+ migrationBuilder.DeleteData(
+ table: "Objects",
+ keyColumn: "ObjectId",
+ keyValue: -3);
+
+ migrationBuilder.RenameTable(
+ name: "TagDefinitionTagDefinition",
+ newName: "ImplicitTags");
+
+ migrationBuilder.RenameIndex(
+ name: "IX_TagDefinitionTagDefinition_TagDefinitionObjectId",
+ table: "ImplicitTags",
+ newName: "IX_ImplicitTags_TagDefinitionObjectId");
+
+ migrationBuilder.AddColumn<int>(
+ name: "AclId",
+ table: "Objects",
+ type: "integer",
+ nullable: true);
+
+ migrationBuilder.AddColumn<byte[]>(
+ name: "Owner",
+ table: "Objects",
+ type: "bytea",
+ nullable: false,
+ defaultValue: new byte[] { 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 });
+
+ migrationBuilder.AddPrimaryKey(
+ name: "PK_ImplicitTags",
+ table: "ImplicitTags",
+ columns: new[] { "ImplicitTagsObjectId", "TagDefinitionObjectId" });
+
+ migrationBuilder.CreateTable(
+ name: "Acls",
+ columns: table => new
+ {
+ AclId = table.Column<int>(type: "integer", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Acls", x => x.AclId);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "SecurityPrincipals",
+ columns: table => new
+ {
+ LocalPrincipalId = table.Column<int>(type: "integer", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ Name = table.Column<string>(type: "text", nullable: false),
+ Sid = table.Column<byte[]>(type: "bytea", nullable: false),
+ Discriminator = table.Column<string>(type: "text", nullable: false),
+ PasswordHash = table.Column<string>(type: "text", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_SecurityPrincipals", x => x.LocalPrincipalId);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "AclRules",
+ columns: table => new
+ {
+ AclRuleId = table.Column<int>(type: "integer", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ Principal = table.Column<byte[]>(type: "bytea", nullable: false),
+ Action = table.Column<int>(type: "integer", nullable: false),
+ Permissions = table.Column<long>(type: "bigint", nullable: false),
+ AclId = table.Column<int>(type: "integer", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_AclRules", x => x.AclRuleId);
+ table.ForeignKey(
+ name: "FK_AclRules_Acls_AclId",
+ column: x => x.AclId,
+ principalTable: "Acls",
+ principalColumn: "AclId");
+ });
+
+ migrationBuilder.CreateTable(
+ name: "SecurityPrincipalMemberships",
+ columns: table => new
+ {
+ LocalPrincipalId = table.Column<int>(type: "integer", nullable: false),
+ MemberOfLocalPrincipalId = table.Column<int>(type: "integer", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_SecurityPrincipalMemberships", x => new { x.LocalPrincipalId, x.MemberOfLocalPrincipalId });
+ table.ForeignKey(
+ name: "FK_SecurityPrincipalMemberships_SecurityPrincipals_LocalPrinci~",
+ column: x => x.LocalPrincipalId,
+ principalTable: "SecurityPrincipals",
+ principalColumn: "LocalPrincipalId",
+ onDelete: ReferentialAction.Cascade);
+ table.ForeignKey(
+ name: "FK_SecurityPrincipalMemberships_SecurityPrincipals_MemberOfLoc~",
+ column: x => x.MemberOfLocalPrincipalId,
+ principalTable: "SecurityPrincipals",
+ principalColumn: "LocalPrincipalId",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.UpdateData(
+ table: "Objects",
+ keyColumn: "ObjectId",
+ keyValue: -2,
+ columns: new[] { "AclId", "Owner" },
+ values: new object[] { null, new byte[] { 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 } });
+
+ migrationBuilder.UpdateData(
+ table: "Objects",
+ keyColumn: "ObjectId",
+ keyValue: -1,
+ columns: new[] { "AclId", "Owner" },
+ values: new object[] { null, new byte[] { 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 } });
+
+ migrationBuilder.InsertData(
+ table: "SecurityPrincipals",
+ columns: new[] { "LocalPrincipalId", "Discriminator", "Name", "PasswordHash", "Sid" },
+ values: new object[] { -1, "LocalUser", "admin", "P4geAuE2yX/PDRHuJSq74FF5vO782rWz5c0LAQPR8m45DEYAONhu1wYnAn60PSNyjocqEBdnCeKCJfK3sKyuWw==", new byte[] { 1, 1, 0, 0, 0, 0, 0, 5, 18, 0, 0, 0 } });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Objects_AclId",
+ table: "Objects",
+ column: "AclId",
+ unique: true);
+
+ migrationBuilder.CreateIndex(
+ name: "IX_AclRules_AclId",
+ table: "AclRules",
+ column: "AclId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_SecurityPrincipalMemberships_MemberOfLocalPrincipalId",
+ table: "SecurityPrincipalMemberships",
+ column: "MemberOfLocalPrincipalId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_SecurityPrincipals_Name",
+ table: "SecurityPrincipals",
+ column: "Name");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_SecurityPrincipals_Sid",
+ table: "SecurityPrincipals",
+ column: "Sid");
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_ImplicitTags_TagDefinitions_ImplicitTagsObjectId",
+ table: "ImplicitTags",
+ column: "ImplicitTagsObjectId",
+ principalTable: "TagDefinitions",
+ principalColumn: "ObjectId",
+ onDelete: ReferentialAction.Cascade);
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_ImplicitTags_TagDefinitions_TagDefinitionObjectId",
+ table: "ImplicitTags",
+ column: "TagDefinitionObjectId",
+ principalTable: "TagDefinitions",
+ principalColumn: "ObjectId",
+ onDelete: ReferentialAction.Cascade);
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_Objects_Acls_AclId",
+ table: "Objects",
+ column: "AclId",
+ principalTable: "Acls",
+ principalColumn: "AclId");
+ }
+
+ /// <inheritdoc />
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropForeignKey(
+ name: "FK_ImplicitTags_TagDefinitions_ImplicitTagsObjectId",
+ table: "ImplicitTags");
+
+ migrationBuilder.DropForeignKey(
+ name: "FK_ImplicitTags_TagDefinitions_TagDefinitionObjectId",
+ table: "ImplicitTags");
+
+ migrationBuilder.DropForeignKey(
+ name: "FK_Objects_Acls_AclId",
+ table: "Objects");
+
+ migrationBuilder.DropTable(
+ name: "AclRules");
+
+ migrationBuilder.DropTable(
+ name: "SecurityPrincipalMemberships");
+
+ migrationBuilder.DropTable(
+ name: "Acls");
+
+ migrationBuilder.DropTable(
+ name: "SecurityPrincipals");
+
+ migrationBuilder.DropIndex(
+ name: "IX_Objects_AclId",
+ table: "Objects");
+
+ migrationBuilder.DropPrimaryKey(
+ name: "PK_ImplicitTags",
+ table: "ImplicitTags");
+
+ migrationBuilder.DropColumn(
+ name: "AclId",
+ table: "Objects");
+
+ migrationBuilder.DropColumn(
+ name: "Owner",
+ table: "Objects");
+
+ migrationBuilder.RenameTable(
+ name: "ImplicitTags",
+ newName: "TagDefinitionTagDefinition");
+
+ migrationBuilder.RenameIndex(
+ name: "IX_ImplicitTags_TagDefinitionObjectId",
+ table: "TagDefinitionTagDefinition",
+ newName: "IX_TagDefinitionTagDefinition_TagDefinitionObjectId");
+
+ migrationBuilder.AddPrimaryKey(
+ name: "PK_TagDefinitionTagDefinition",
+ table: "TagDefinitionTagDefinition",
+ columns: new[] { "ImplicitTagsObjectId", "TagDefinitionObjectId" });
+
+ migrationBuilder.CreateTable(
+ name: "Users",
+ columns: table => new
+ {
+ ObjectId = table.Column<int>(type: "integer", nullable: false),
+ PasswordHash = table.Column<string>(type: "text", nullable: false),
+ Username = table.Column<string>(type: "text", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Users", x => x.ObjectId);
+ table.ForeignKey(
+ name: "FK_Users_Objects_ObjectId",
+ column: x => x.ObjectId,
+ principalTable: "Objects",
+ principalColumn: "ObjectId",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.InsertData(
+ table: "Objects",
+ columns: new[] { "ObjectId", "Guid" },
+ values: new object[] { -3, new Guid("4fa948f4-7c45-4f81-bb6b-e417491e6c96") });
+
+ migrationBuilder.InsertData(
+ table: "Users",
+ columns: new[] { "ObjectId", "PasswordHash", "Username" },
+ values: new object[] { -3, "P4geAuE2yX/PDRHuJSq74FF5vO782rWz5c0LAQPR8m45DEYAONhu1wYnAn60PSNyjocqEBdnCeKCJfK3sKyuWw==", "admin" });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Users_Username",
+ table: "Users",
+ column: "Username");
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_TagDefinitionTagDefinition_TagDefinitions_ImplicitTagsObjec~",
+ table: "TagDefinitionTagDefinition",
+ column: "ImplicitTagsObjectId",
+ principalTable: "TagDefinitions",
+ principalColumn: "ObjectId",
+ onDelete: ReferentialAction.Cascade);
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_TagDefinitionTagDefinition_TagDefinitions_TagDefinitionObje~",
+ table: "TagDefinitionTagDefinition",
+ column: "TagDefinitionObjectId",
+ principalTable: "TagDefinitions",
+ principalColumn: "ObjectId",
+ onDelete: ReferentialAction.Cascade);
+ }
+ }
+}