summaryrefslogtreecommitdiff
path: root/Migrations/20230811002826_Initial.cs
diff options
context:
space:
mode:
authorJake Mannens <jake@asger.xyz>2023-08-12 19:06:00 +1000
committerJake Mannens <jake@asger.xyz>2023-08-12 19:06:00 +1000
commit3ce156d00197a894ac9b0507544afd51aec2a0fd (patch)
treea20e12c7bd0fe413d192ed454db07165e14551fd /Migrations/20230811002826_Initial.cs
parentb704601c81f026f63391b8f05f271ac3f427a20a (diff)
parent0d758c6cd118641e86e6a7ddd7285be916cdb2d8 (diff)
Merge branch 'dev' of gitlab.com:plasmicplexus/HyperBooru-Server into dev
Diffstat (limited to 'Migrations/20230811002826_Initial.cs')
-rw-r--r--Migrations/20230811002826_Initial.cs180
1 files changed, 180 insertions, 0 deletions
diff --git a/Migrations/20230811002826_Initial.cs b/Migrations/20230811002826_Initial.cs
new file mode 100644
index 0000000..f3017e5
--- /dev/null
+++ b/Migrations/20230811002826_Initial.cs
@@ -0,0 +1,180 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace HyperBooru.Migrations
+{
+ /// <inheritdoc />
+ public partial class Initial : Migration
+ {
+ /// <inheritdoc />
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.CreateTable(
+ name: "Objects",
+ columns: table => new
+ {
+ ObjectId = table.Column<int>(type: "INTEGER", nullable: false)
+ .Annotation("Sqlite:Autoincrement", true),
+ Guid = table.Column<Guid>(type: "TEXT", nullable: false),
+ ObjectType = table.Column<int>(type: "INTEGER", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Objects", x => x.ObjectId);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Media",
+ columns: table => new
+ {
+ ObjectId = table.Column<int>(type: "INTEGER", nullable: false)
+ .Annotation("Sqlite:Autoincrement", true),
+ Checksum = table.Column<string>(type: "TEXT", nullable: false),
+ MimeType = table.Column<string>(type: "TEXT", nullable: false),
+ ShortDescription = table.Column<string>(type: "TEXT", nullable: true),
+ LongDescription = table.Column<string>(type: "TEXT", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Media", x => x.ObjectId);
+ table.ForeignKey(
+ name: "FK_Media_Objects_ObjectId",
+ column: x => x.ObjectId,
+ principalTable: "Objects",
+ principalColumn: "ObjectId",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "TagDefinitions",
+ columns: table => new
+ {
+ ObjectId = table.Column<int>(type: "INTEGER", nullable: false)
+ .Annotation("Sqlite:Autoincrement", true),
+ Source = table.Column<int>(type: "INTEGER", nullable: false),
+ Namespace = table.Column<string>(type: "TEXT", nullable: true),
+ Name = table.Column<string>(type: "TEXT", nullable: false),
+ DbTagDefinitionObjectId = table.Column<int>(type: "INTEGER", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_TagDefinitions", x => x.ObjectId);
+ table.ForeignKey(
+ name: "FK_TagDefinitions_Objects_ObjectId",
+ column: x => x.ObjectId,
+ principalTable: "Objects",
+ principalColumn: "ObjectId",
+ onDelete: ReferentialAction.Cascade);
+ table.ForeignKey(
+ name: "FK_TagDefinitions_TagDefinitions_DbTagDefinitionObjectId",
+ column: x => x.DbTagDefinitionObjectId,
+ principalTable: "TagDefinitions",
+ principalColumn: "ObjectId");
+ });
+
+ migrationBuilder.CreateTable(
+ name: "UploadedFiles",
+ columns: table => new
+ {
+ UploadedFileId = table.Column<int>(type: "INTEGER", nullable: false)
+ .Annotation("Sqlite:Autoincrement", true),
+ OriginalChecksum = table.Column<string>(type: "TEXT", nullable: false),
+ Filename = table.Column<string>(type: "TEXT", nullable: true),
+ UploadTime = table.Column<DateTime>(type: "TEXT", nullable: false),
+ LastAccessTime = table.Column<DateTime>(type: "TEXT", nullable: true),
+ LastWriteTime = table.Column<DateTime>(type: "TEXT", nullable: true),
+ CreateTime = table.Column<DateTime>(type: "TEXT", nullable: true),
+ MediaObjectId = table.Column<int>(type: "INTEGER", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_UploadedFiles", x => x.UploadedFileId);
+ table.ForeignKey(
+ name: "FK_UploadedFiles_Media_MediaObjectId",
+ column: x => x.MediaObjectId,
+ principalTable: "Media",
+ principalColumn: "ObjectId",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Tags",
+ columns: table => new
+ {
+ ObjectId = table.Column<int>(type: "INTEGER", nullable: false)
+ .Annotation("Sqlite:Autoincrement", true),
+ TagDefinitionObjectId = table.Column<int>(type: "INTEGER", nullable: false),
+ CreateTime = table.Column<DateTime>(type: "TEXT", nullable: false),
+ TargetObjectId = table.Column<int>(type: "INTEGER", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Tags", x => x.ObjectId);
+ table.ForeignKey(
+ name: "FK_Tags_Objects_ObjectId",
+ column: x => x.ObjectId,
+ principalTable: "Objects",
+ principalColumn: "ObjectId",
+ onDelete: ReferentialAction.Cascade);
+ table.ForeignKey(
+ name: "FK_Tags_Objects_TargetObjectId",
+ column: x => x.TargetObjectId,
+ principalTable: "Objects",
+ principalColumn: "ObjectId",
+ onDelete: ReferentialAction.Cascade);
+ table.ForeignKey(
+ name: "FK_Tags_TagDefinitions_TagDefinitionObjectId",
+ column: x => x.TagDefinitionObjectId,
+ principalTable: "TagDefinitions",
+ principalColumn: "ObjectId",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Objects_Guid",
+ table: "Objects",
+ column: "Guid");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_TagDefinitions_DbTagDefinitionObjectId",
+ table: "TagDefinitions",
+ column: "DbTagDefinitionObjectId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Tags_TagDefinitionObjectId",
+ table: "Tags",
+ column: "TagDefinitionObjectId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Tags_TargetObjectId",
+ table: "Tags",
+ column: "TargetObjectId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_UploadedFiles_MediaObjectId",
+ table: "UploadedFiles",
+ column: "MediaObjectId");
+ }
+
+ /// <inheritdoc />
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "Tags");
+
+ migrationBuilder.DropTable(
+ name: "UploadedFiles");
+
+ migrationBuilder.DropTable(
+ name: "TagDefinitions");
+
+ migrationBuilder.DropTable(
+ name: "Media");
+
+ migrationBuilder.DropTable(
+ name: "Objects");
+ }
+ }
+}