Index: ChapterX.Infrastructure/Migrations/20260824172555_InitialCreate.cs
===================================================================
--- ChapterX.Infrastructure/Migrations/20260824172555_InitialCreate.cs	(revision e882b92860e1899312f197af1134bb0f33d30d15)
+++ ChapterX.Infrastructure/Migrations/20260824172555_InitialCreate.cs	(revision e882b92860e1899312f197af1134bb0f33d30d15)
@@ -0,0 +1,521 @@
+﻿using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+
+#nullable disable
+
+namespace ChapterX.Infrastructure.Migrations
+{
+    /// <inheritdoc />
+    public partial class InitialCreate : Migration
+    {
+        /// <inheritdoc />
+        protected override void Up(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.CreateTable(
+                name: "genre",
+                columns: table => new
+                {
+                    genre_id = table.Column<int>(type: "integer", nullable: false)
+                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+                    genre_name = table.Column<string>(type: "text", nullable: false)
+                },
+                constraints: table =>
+                {
+                    table.PrimaryKey("PK_genre", x => x.genre_id);
+                });
+
+            migrationBuilder.CreateTable(
+                name: "users",
+                columns: table => new
+                {
+                    user_id = table.Column<int>(type: "integer", nullable: false)
+                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+                    username = table.Column<string>(type: "text", nullable: false),
+                    email = table.Column<string>(type: "text", nullable: false),
+                    user_name = table.Column<string>(type: "text", nullable: false),
+                    surname = table.Column<string>(type: "text", nullable: false),
+                    password = table.Column<string>(type: "text", nullable: false),
+                    user_created_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
+                    user_updated_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
+                },
+                constraints: table =>
+                {
+                    table.PrimaryKey("PK_users", x => x.user_id);
+                });
+
+            migrationBuilder.CreateTable(
+                name: "admins",
+                columns: table => new
+                {
+                    user_id = table.Column<int>(type: "integer", nullable: false),
+                    assigned_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
+                },
+                constraints: table =>
+                {
+                    table.PrimaryKey("PK_admins", x => x.user_id);
+                    table.ForeignKey(
+                        name: "FK_admins_users_user_id",
+                        column: x => x.user_id,
+                        principalTable: "users",
+                        principalColumn: "user_id",
+                        onDelete: ReferentialAction.Cascade);
+                });
+
+            migrationBuilder.CreateTable(
+                name: "reading_list",
+                columns: table => new
+                {
+                    list_id = table.Column<int>(type: "integer", nullable: false)
+                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+                    list_name = table.Column<string>(type: "text", nullable: false),
+                    list_content = table.Column<string>(type: "text", nullable: true),
+                    is_public = table.Column<bool>(type: "boolean", nullable: false),
+                    list_created_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
+                    list_updated_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
+                    user_id = table.Column<int>(type: "integer", nullable: false)
+                },
+                constraints: table =>
+                {
+                    table.PrimaryKey("PK_reading_list", x => x.list_id);
+                    table.ForeignKey(
+                        name: "FK_reading_list_users_user_id",
+                        column: x => x.user_id,
+                        principalTable: "users",
+                        principalColumn: "user_id",
+                        onDelete: ReferentialAction.Cascade);
+                });
+
+            migrationBuilder.CreateTable(
+                name: "regular_user",
+                columns: table => new
+                {
+                    user_id = table.Column<int>(type: "integer", nullable: false),
+                    joined_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
+                },
+                constraints: table =>
+                {
+                    table.PrimaryKey("PK_regular_user", x => x.user_id);
+                    table.ForeignKey(
+                        name: "FK_regular_user_users_user_id",
+                        column: x => x.user_id,
+                        principalTable: "users",
+                        principalColumn: "user_id",
+                        onDelete: ReferentialAction.Cascade);
+                });
+
+            migrationBuilder.CreateTable(
+                name: "writer",
+                columns: table => new
+                {
+                    user_id = table.Column<int>(type: "integer", nullable: false),
+                    bio = table.Column<string>(type: "text", nullable: true)
+                },
+                constraints: table =>
+                {
+                    table.PrimaryKey("PK_writer", x => x.user_id);
+                    table.ForeignKey(
+                        name: "FK_writer_users_user_id",
+                        column: x => x.user_id,
+                        principalTable: "users",
+                        principalColumn: "user_id",
+                        onDelete: ReferentialAction.Cascade);
+                });
+
+            migrationBuilder.CreateTable(
+                name: "story",
+                columns: table => new
+                {
+                    story_id = table.Column<int>(type: "integer", nullable: false)
+                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+                    mature_content = table.Column<bool>(type: "boolean", nullable: false),
+                    title = table.Column<string>(type: "text", nullable: false),
+                    short_description = table.Column<string>(type: "text", nullable: false),
+                    image = table.Column<string>(type: "text", nullable: true),
+                    story_content = table.Column<string>(type: "text", nullable: false),
+                    status = table.Column<string>(type: "text", nullable: false),
+                    story_created_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
+                    story_updated_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
+                    user_id = table.Column<int>(type: "integer", nullable: false)
+                },
+                constraints: table =>
+                {
+                    table.PrimaryKey("PK_story", x => x.story_id);
+                    table.ForeignKey(
+                        name: "FK_story_writer_user_id",
+                        column: x => x.user_id,
+                        principalTable: "writer",
+                        principalColumn: "user_id",
+                        onDelete: ReferentialAction.Cascade);
+                });
+
+            migrationBuilder.CreateTable(
+                name: "ai_suggestion",
+                columns: table => new
+                {
+                    suggestion_id = table.Column<int>(type: "integer", nullable: false)
+                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+                    original_text = table.Column<string>(type: "text", nullable: false),
+                    suggested_text = table.Column<string>(type: "text", nullable: false),
+                    suggestion_type = table.Column<string>(type: "text", nullable: false),
+                    accepted = table.Column<bool>(type: "boolean", nullable: true),
+                    suggestion_created_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
+                    applied_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
+                    story_id = table.Column<int>(type: "integer", nullable: false)
+                },
+                constraints: table =>
+                {
+                    table.PrimaryKey("PK_ai_suggestion", x => x.suggestion_id);
+                    table.ForeignKey(
+                        name: "FK_ai_suggestion_story_story_id",
+                        column: x => x.story_id,
+                        principalTable: "story",
+                        principalColumn: "story_id",
+                        onDelete: ReferentialAction.Cascade);
+                });
+
+            migrationBuilder.CreateTable(
+                name: "chapter",
+                columns: table => new
+                {
+                    chapter_id = table.Column<int>(type: "integer", nullable: false)
+                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+                    chapter_number = table.Column<int>(type: "integer", nullable: false),
+                    chapter_name = table.Column<string>(type: "text", nullable: false),
+                    title = table.Column<string>(type: "text", nullable: false),
+                    chapter_content = table.Column<string>(type: "text", nullable: false),
+                    word_count = table.Column<int>(type: "integer", nullable: true),
+                    rating = table.Column<decimal>(type: "numeric", nullable: true),
+                    published_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
+                    view_count = table.Column<int>(type: "integer", nullable: false),
+                    chapter_created_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
+                    chapter_updated_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
+                    story_id = table.Column<int>(type: "integer", nullable: false)
+                },
+                constraints: table =>
+                {
+                    table.PrimaryKey("PK_chapter", x => x.chapter_id);
+                    table.ForeignKey(
+                        name: "FK_chapter_story_story_id",
+                        column: x => x.story_id,
+                        principalTable: "story",
+                        principalColumn: "story_id",
+                        onDelete: ReferentialAction.Cascade);
+                });
+
+            migrationBuilder.CreateTable(
+                name: "collaboration",
+                columns: table => new
+                {
+                    user_id = table.Column<int>(type: "integer", nullable: false),
+                    story_id = table.Column<int>(type: "integer", nullable: false),
+                    role = table.Column<string>(type: "text", nullable: false),
+                    permission_level = table.Column<int>(type: "integer", nullable: true),
+                    collab_created_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
+                },
+                constraints: table =>
+                {
+                    table.PrimaryKey("PK_collaboration", x => new { x.user_id, x.story_id });
+                    table.ForeignKey(
+                        name: "FK_collaboration_story_story_id",
+                        column: x => x.story_id,
+                        principalTable: "story",
+                        principalColumn: "story_id",
+                        onDelete: ReferentialAction.Cascade);
+                    table.ForeignKey(
+                        name: "FK_collaboration_users_user_id",
+                        column: x => x.user_id,
+                        principalTable: "users",
+                        principalColumn: "user_id",
+                        onDelete: ReferentialAction.Cascade);
+                });
+
+            migrationBuilder.CreateTable(
+                name: "comment",
+                columns: table => new
+                {
+                    comment_id = table.Column<int>(type: "integer", nullable: false)
+                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+                    comment_content = table.Column<string>(type: "text", nullable: false),
+                    comment_created_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
+                    comment_updated_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
+                    user_id = table.Column<int>(type: "integer", nullable: false),
+                    story_id = table.Column<int>(type: "integer", nullable: false)
+                },
+                constraints: table =>
+                {
+                    table.PrimaryKey("PK_comment", x => x.comment_id);
+                    table.ForeignKey(
+                        name: "FK_comment_story_story_id",
+                        column: x => x.story_id,
+                        principalTable: "story",
+                        principalColumn: "story_id",
+                        onDelete: ReferentialAction.Cascade);
+                    table.ForeignKey(
+                        name: "FK_comment_users_user_id",
+                        column: x => x.user_id,
+                        principalTable: "users",
+                        principalColumn: "user_id",
+                        onDelete: ReferentialAction.Cascade);
+                });
+
+            migrationBuilder.CreateTable(
+                name: "has_genre",
+                columns: table => new
+                {
+                    story_id = table.Column<int>(type: "integer", nullable: false),
+                    genre_id = table.Column<int>(type: "integer", nullable: false)
+                },
+                constraints: table =>
+                {
+                    table.PrimaryKey("PK_has_genre", x => new { x.story_id, x.genre_id });
+                    table.ForeignKey(
+                        name: "FK_has_genre_genre_genre_id",
+                        column: x => x.genre_id,
+                        principalTable: "genre",
+                        principalColumn: "genre_id",
+                        onDelete: ReferentialAction.Cascade);
+                    table.ForeignKey(
+                        name: "FK_has_genre_story_story_id",
+                        column: x => x.story_id,
+                        principalTable: "story",
+                        principalColumn: "story_id",
+                        onDelete: ReferentialAction.Cascade);
+                });
+
+            migrationBuilder.CreateTable(
+                name: "likes",
+                columns: table => new
+                {
+                    user_id = table.Column<int>(type: "integer", nullable: false),
+                    story_id = table.Column<int>(type: "integer", nullable: false),
+                    liked_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
+                },
+                constraints: table =>
+                {
+                    table.PrimaryKey("PK_likes", x => new { x.user_id, x.story_id });
+                    table.ForeignKey(
+                        name: "FK_likes_story_story_id",
+                        column: x => x.story_id,
+                        principalTable: "story",
+                        principalColumn: "story_id",
+                        onDelete: ReferentialAction.Cascade);
+                    table.ForeignKey(
+                        name: "FK_likes_users_user_id",
+                        column: x => x.user_id,
+                        principalTable: "users",
+                        principalColumn: "user_id",
+                        onDelete: ReferentialAction.Cascade);
+                });
+
+            migrationBuilder.CreateTable(
+                name: "notification",
+                columns: table => new
+                {
+                    notification_id = table.Column<int>(type: "integer", nullable: false)
+                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+                    notification_content = table.Column<string>(type: "text", nullable: false),
+                    content_type = table.Column<string>(type: "text", nullable: false),
+                    is_read = table.Column<bool>(type: "boolean", nullable: false),
+                    link = table.Column<string>(type: "text", nullable: true),
+                    notification_created_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
+                    user_id = table.Column<int>(type: "integer", nullable: false),
+                    story_id = table.Column<int>(type: "integer", nullable: true)
+                },
+                constraints: table =>
+                {
+                    table.PrimaryKey("PK_notification", x => x.notification_id);
+                    table.ForeignKey(
+                        name: "FK_notification_story_story_id",
+                        column: x => x.story_id,
+                        principalTable: "story",
+                        principalColumn: "story_id",
+                        onDelete: ReferentialAction.SetNull);
+                    table.ForeignKey(
+                        name: "FK_notification_users_user_id",
+                        column: x => x.user_id,
+                        principalTable: "users",
+                        principalColumn: "user_id",
+                        onDelete: ReferentialAction.Cascade);
+                });
+
+            migrationBuilder.CreateTable(
+                name: "reading_list_items",
+                columns: table => new
+                {
+                    list_id = table.Column<int>(type: "integer", nullable: false),
+                    story_id = table.Column<int>(type: "integer", nullable: false),
+                    added_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
+                },
+                constraints: table =>
+                {
+                    table.PrimaryKey("PK_reading_list_items", x => new { x.list_id, x.story_id });
+                    table.ForeignKey(
+                        name: "FK_reading_list_items_reading_list_list_id",
+                        column: x => x.list_id,
+                        principalTable: "reading_list",
+                        principalColumn: "list_id",
+                        onDelete: ReferentialAction.Cascade);
+                    table.ForeignKey(
+                        name: "FK_reading_list_items_story_story_id",
+                        column: x => x.story_id,
+                        principalTable: "story",
+                        principalColumn: "story_id",
+                        onDelete: ReferentialAction.Cascade);
+                });
+
+            migrationBuilder.CreateTable(
+                name: "need_approval",
+                columns: table => new
+                {
+                    suggestion_id = table.Column<int>(type: "integer", nullable: false),
+                    story_id = table.Column<int>(type: "integer", nullable: false),
+                    chapter_id = table.Column<int>(type: "integer", nullable: false)
+                },
+                constraints: table =>
+                {
+                    table.PrimaryKey("PK_need_approval", x => new { x.suggestion_id, x.story_id, x.chapter_id });
+                    table.ForeignKey(
+                        name: "FK_need_approval_ai_suggestion_suggestion_id",
+                        column: x => x.suggestion_id,
+                        principalTable: "ai_suggestion",
+                        principalColumn: "suggestion_id",
+                        onDelete: ReferentialAction.Cascade);
+                    table.ForeignKey(
+                        name: "FK_need_approval_chapter_chapter_id",
+                        column: x => x.chapter_id,
+                        principalTable: "chapter",
+                        principalColumn: "chapter_id",
+                        onDelete: ReferentialAction.Cascade);
+                    table.ForeignKey(
+                        name: "FK_need_approval_story_story_id",
+                        column: x => x.story_id,
+                        principalTable: "story",
+                        principalColumn: "story_id",
+                        onDelete: ReferentialAction.Cascade);
+                });
+
+            migrationBuilder.CreateIndex(
+                name: "IX_ai_suggestion_story_id",
+                table: "ai_suggestion",
+                column: "story_id");
+
+            migrationBuilder.CreateIndex(
+                name: "IX_chapter_story_id",
+                table: "chapter",
+                column: "story_id");
+
+            migrationBuilder.CreateIndex(
+                name: "IX_collaboration_story_id",
+                table: "collaboration",
+                column: "story_id");
+
+            migrationBuilder.CreateIndex(
+                name: "IX_comment_story_id",
+                table: "comment",
+                column: "story_id");
+
+            migrationBuilder.CreateIndex(
+                name: "IX_comment_user_id",
+                table: "comment",
+                column: "user_id");
+
+            migrationBuilder.CreateIndex(
+                name: "IX_has_genre_genre_id",
+                table: "has_genre",
+                column: "genre_id");
+
+            migrationBuilder.CreateIndex(
+                name: "IX_likes_story_id",
+                table: "likes",
+                column: "story_id");
+
+            migrationBuilder.CreateIndex(
+                name: "IX_need_approval_chapter_id",
+                table: "need_approval",
+                column: "chapter_id");
+
+            migrationBuilder.CreateIndex(
+                name: "IX_need_approval_story_id",
+                table: "need_approval",
+                column: "story_id");
+
+            migrationBuilder.CreateIndex(
+                name: "IX_notification_story_id",
+                table: "notification",
+                column: "story_id");
+
+            migrationBuilder.CreateIndex(
+                name: "IX_notification_user_id",
+                table: "notification",
+                column: "user_id");
+
+            migrationBuilder.CreateIndex(
+                name: "IX_reading_list_user_id",
+                table: "reading_list",
+                column: "user_id");
+
+            migrationBuilder.CreateIndex(
+                name: "IX_reading_list_items_story_id",
+                table: "reading_list_items",
+                column: "story_id");
+
+            migrationBuilder.CreateIndex(
+                name: "IX_story_user_id",
+                table: "story",
+                column: "user_id");
+        }
+
+        /// <inheritdoc />
+        protected override void Down(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.DropTable(
+                name: "admins");
+
+            migrationBuilder.DropTable(
+                name: "collaboration");
+
+            migrationBuilder.DropTable(
+                name: "comment");
+
+            migrationBuilder.DropTable(
+                name: "has_genre");
+
+            migrationBuilder.DropTable(
+                name: "likes");
+
+            migrationBuilder.DropTable(
+                name: "need_approval");
+
+            migrationBuilder.DropTable(
+                name: "notification");
+
+            migrationBuilder.DropTable(
+                name: "reading_list_items");
+
+            migrationBuilder.DropTable(
+                name: "regular_user");
+
+            migrationBuilder.DropTable(
+                name: "genre");
+
+            migrationBuilder.DropTable(
+                name: "ai_suggestion");
+
+            migrationBuilder.DropTable(
+                name: "chapter");
+
+            migrationBuilder.DropTable(
+                name: "reading_list");
+
+            migrationBuilder.DropTable(
+                name: "story");
+
+            migrationBuilder.DropTable(
+                name: "writer");
+
+            migrationBuilder.DropTable(
+                name: "users");
+        }
+    }
+}
