using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace Nuuru.Server.Migrations.PostgreSQL
{
///
public partial class InitialCreate : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "AspNetRoles",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
Color = table.Column(type: "text", nullable: true),
Priority = table.Column(type: "integer", nullable: false),
Name = table.Column(type: "character varying(256)", maxLength: 256, nullable: true),
NormalizedName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true),
ConcurrencyStamp = table.Column(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetRoles", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AspNetUsers",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
Status = table.Column(type: "text", nullable: false),
Biography = table.Column(type: "text", nullable: false),
BiographyHtml = table.Column(type: "text", nullable: true),
AvatarStorageIdentifier = table.Column(type: "text", nullable: true),
DateCreated = table.Column(type: "timestamp with time zone", nullable: false),
SignupVerificationAvailableAt = table.Column(type: "timestamp with time zone", nullable: true),
SignupVerificationCompletedAt = table.Column(type: "timestamp with time zone", nullable: true),
SignupVerificationIpAddress = table.Column(type: "text", nullable: true),
SignupVerificationCountryCode = table.Column(type: "text", nullable: true),
SignupVerificationRegionCode = table.Column(type: "text", nullable: true),
SignupVerificationCity = table.Column(type: "text", nullable: true),
SignupVerificationIspAsn = table.Column(type: "text", nullable: true),
SignupVerificationIspName = table.Column(type: "text", nullable: true),
IsSystemAccount = table.Column(type: "boolean", nullable: false),
UserName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true),
NormalizedUserName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true),
Email = table.Column(type: "character varying(256)", maxLength: 256, nullable: true),
NormalizedEmail = table.Column(type: "character varying(256)", maxLength: 256, nullable: true),
EmailConfirmed = table.Column(type: "boolean", nullable: false),
PasswordHash = table.Column(type: "text", nullable: true),
SecurityStamp = table.Column(type: "text", nullable: true),
ConcurrencyStamp = table.Column(type: "text", nullable: true),
PhoneNumber = table.Column(type: "text", nullable: true),
PhoneNumberConfirmed = table.Column(type: "boolean", nullable: false),
TwoFactorEnabled = table.Column(type: "boolean", nullable: false),
LockoutEnd = table.Column(type: "timestamp with time zone", nullable: true),
LockoutEnabled = table.Column(type: "boolean", nullable: false),
AccessFailedCount = table.Column(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUsers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "BooruTagCategories",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
Name = table.Column(type: "character varying(100)", maxLength: 100, nullable: false),
Slug = table.Column(type: "character varying(50)", maxLength: 50, nullable: false),
ColorHex = table.Column(type: "character varying(20)", maxLength: 20, nullable: true),
SortOrder = table.Column(type: "integer", nullable: false),
IsActive = table.Column(type: "boolean", nullable: false),
MaxPerPost = table.Column(type: "integer", nullable: true),
ParentCategoryId = table.Column(type: "uuid", nullable: true),
Version = table.Column(type: "bigint", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_BooruTagCategories", x => x.Id);
table.ForeignKey(
name: "FK_BooruTagCategories_BooruTagCategories_ParentCategoryId",
column: x => x.ParentCategoryId,
principalTable: "BooruTagCategories",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "ForumCategories",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
Slug = table.Column(type: "character varying(50)", maxLength: 50, nullable: false),
Name = table.Column(type: "character varying(100)", maxLength: 100, nullable: false),
Description = table.Column(type: "character varying(500)", maxLength: 500, nullable: false),
DisplayOrder = table.Column(type: "integer", nullable: false),
Color = table.Column(type: "character varying(50)", maxLength: 50, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ForumCategories", x => x.Id);
});
migrationBuilder.CreateTable(
name: "SiteSettings",
columns: table => new
{
Key = table.Column(type: "character varying(255)", maxLength: 255, nullable: false),
Value = table.Column(type: "character varying(4000)", maxLength: 4000, nullable: false),
UpdatedAt = table.Column(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_SiteSettings", x => x.Key);
});
migrationBuilder.CreateTable(
name: "AspNetRoleClaims",
columns: table => new
{
Id = table.Column(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
RoleId = table.Column(type: "uuid", nullable: false),
ClaimType = table.Column(type: "text", nullable: true),
ClaimValue = table.Column(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id);
table.ForeignKey(
name: "FK_AspNetRoleClaims_AspNetRoles_RoleId",
column: x => x.RoleId,
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AspNetUserClaims",
columns: table => new
{
Id = table.Column(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
UserId = table.Column(type: "uuid", nullable: false),
ClaimType = table.Column(type: "text", nullable: true),
ClaimValue = table.Column(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserClaims", x => x.Id);
table.ForeignKey(
name: "FK_AspNetUserClaims_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AspNetUserLogins",
columns: table => new
{
LoginProvider = table.Column(type: "text", nullable: false),
ProviderKey = table.Column(type: "text", nullable: false),
ProviderDisplayName = table.Column(type: "text", nullable: true),
UserId = table.Column(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey });
table.ForeignKey(
name: "FK_AspNetUserLogins_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AspNetUserRoles",
columns: table => new
{
UserId = table.Column(type: "uuid", nullable: false),
RoleId = table.Column(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId });
table.ForeignKey(
name: "FK_AspNetUserRoles_AspNetRoles_RoleId",
column: x => x.RoleId,
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_AspNetUserRoles_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AspNetUserTokens",
columns: table => new
{
UserId = table.Column(type: "uuid", nullable: false),
LoginProvider = table.Column(type: "text", nullable: false),
Name = table.Column(type: "text", nullable: false),
Value = table.Column(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name });
table.ForeignKey(
name: "FK_AspNetUserTokens_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AuditLogs",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
Action = table.Column(type: "text", nullable: false),
Category = table.Column(type: "text", nullable: false),
TargetType = table.Column(type: "text", nullable: true),
TargetId = table.Column(type: "text", nullable: true),
IpAddress = table.Column(type: "text", nullable: true),
HttpMethod = table.Column(type: "text", nullable: false),
RequestPath = table.Column(type: "text", nullable: false),
ResponseStatusCode = table.Column(type: "integer", nullable: false),
Timestamp = table.Column(type: "timestamp with time zone", nullable: false),
UserId = table.Column(type: "uuid", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AuditLogs", x => x.Id);
table.ForeignKey(
name: "FK_AuditLogs_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
});
migrationBuilder.CreateTable(
name: "Bans",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
Reason = table.Column(type: "text", nullable: false),
StartTime = table.Column(type: "timestamp with time zone", nullable: false),
EndTime = table.Column(type: "timestamp with time zone", nullable: false),
Zone = table.Column(type: "integer", nullable: false),
UserId = table.Column(type: "uuid", nullable: false),
Active = table.Column(type: "boolean", nullable: false),
AppealsDenied = table.Column(type: "boolean", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Bans", x => x.Id);
table.ForeignKey(
name: "FK_Bans_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "BooruPosts",
columns: table => new
{
Id = table.Column(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
StorageIdentifier = table.Column(type: "text", nullable: false),
ImageHash = table.Column(type: "text", nullable: false),
MimeType = table.Column(type: "text", nullable: false),
FileSize = table.Column(type: "bigint", nullable: false),
OriginalFileName = table.Column(type: "text", nullable: true),
Source = table.Column(type: "character varying(2000)", maxLength: 2000, nullable: true),
Width = table.Column(type: "integer", nullable: true),
Height = table.Column(type: "integer", nullable: true),
DurationSeconds = table.Column(type: "integer", nullable: true),
ThumbnailPath = table.Column(type: "text", nullable: true),
UploadedAt = table.Column(type: "timestamp with time zone", nullable: false),
Rating = table.Column(type: "integer", nullable: false),
IsApproved = table.Column(type: "boolean", nullable: false),
CommentsLocked = table.Column(type: "boolean", nullable: false),
IsTrashed = table.Column(type: "boolean", nullable: false),
TrashedAt = table.Column(type: "timestamp with time zone", nullable: true),
TrashedById = table.Column(type: "uuid", nullable: true),
TrashReason = table.Column(type: "text", nullable: true),
IsFeatured = table.Column(type: "boolean", nullable: false),
FeaturedAt = table.Column(type: "timestamp with time zone", nullable: true),
Score = table.Column(type: "integer", nullable: false),
TagCount = table.Column(type: "integer", nullable: false),
IpAddress = table.Column(type: "text", nullable: true),
UploaderId = table.Column(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_BooruPosts", x => x.Id);
table.ForeignKey(
name: "FK_BooruPosts_AspNetUsers_TrashedById",
column: x => x.TrashedById,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_BooruPosts_AspNetUsers_UploaderId",
column: x => x.UploaderId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Conversations",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
Title = table.Column(type: "character varying(200)", maxLength: 200, nullable: true),
CreatedAt = table.Column(type: "timestamp with time zone", nullable: false),
LastMessageAt = table.Column(type: "timestamp with time zone", nullable: false),
MessageCount = table.Column(type: "integer", nullable: false),
CreatorId = table.Column(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Conversations", x => x.Id);
table.ForeignKey(
name: "FK_Conversations_AspNetUsers_CreatorId",
column: x => x.CreatorId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "ModerationActions",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
Action = table.Column(type: "text", nullable: false),
TargetType = table.Column(type: "text", nullable: false),
TargetId = table.Column(type: "text", nullable: false),
Reason = table.Column(type: "text", nullable: true),
Details = table.Column(type: "text", nullable: true),
Timestamp = table.Column(type: "timestamp with time zone", nullable: false),
ModeratorId = table.Column(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ModerationActions", x => x.Id);
table.ForeignKey(
name: "FK_ModerationActions_AspNetUsers_ModeratorId",
column: x => x.ModeratorId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Notifications",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
Type = table.Column(type: "integer", nullable: false),
Message = table.Column(type: "character varying(500)", maxLength: 500, nullable: false),
CreatedAt = table.Column(type: "timestamp with time zone", nullable: false),
IsRead = table.Column(type: "boolean", nullable: false),
RelatedPostId = table.Column(type: "integer", nullable: true),
RelatedCommentId = table.Column(type: "integer", nullable: true),
RelatedForumPostId = table.Column(type: "integer", nullable: true),
RelatedForumThreadId = table.Column(type: "integer", nullable: true),
RelatedConversationId = table.Column(type: "uuid", nullable: true),
RelatedMessageId = table.Column(type: "integer", nullable: true),
TriggeredByUserId = table.Column(type: "uuid", nullable: true),
UserId = table.Column(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Notifications", x => x.Id);
table.ForeignKey(
name: "FK_Notifications_AspNetUsers_TriggeredByUserId",
column: x => x.TriggeredByUserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_Notifications_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Reactions",
columns: table => new
{
Id = table.Column(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
EntityType = table.Column(type: "integer", nullable: false),
EntityId = table.Column(type: "integer", nullable: false),
UserId = table.Column(type: "uuid", nullable: false),
EmoteName = table.Column(type: "character varying(32)", maxLength: 32, nullable: false),
CreatedAt = table.Column(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Reactions", x => x.Id);
table.ForeignKey(
name: "FK_Reactions_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "RefreshTokens",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
Token = table.Column(type: "text", nullable: false),
UserId = table.Column(type: "uuid", nullable: false),
ExpiresAt = table.Column(type: "timestamp with time zone", nullable: false),
CreatedAt = table.Column(type: "timestamp with time zone", nullable: false),
IsRevoked = table.Column(type: "boolean", nullable: false),
RevokedAt = table.Column(type: "timestamp with time zone", nullable: true),
ReplacedByToken = table.Column(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_RefreshTokens", x => x.Id);
table.ForeignKey(
name: "FK_RefreshTokens_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Reports",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
TargetType = table.Column(type: "integer", nullable: false),
TargetId = table.Column(type: "character varying(100)", maxLength: 100, nullable: false),
Reason = table.Column(type: "character varying(2000)", maxLength: 2000, nullable: false),
Status = table.Column(type: "integer", nullable: false),
CreatedAt = table.Column(type: "timestamp with time zone", nullable: false),
ResolvedAt = table.Column(type: "timestamp with time zone", nullable: true),
ResolutionNote = table.Column(type: "character varying(2000)", maxLength: 2000, nullable: true),
ReporterId = table.Column(type: "uuid", nullable: false),
ModeratorId = table.Column(type: "uuid", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Reports", x => x.Id);
table.ForeignKey(
name: "FK_Reports_AspNetUsers_ModeratorId",
column: x => x.ModeratorId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_Reports_AspNetUsers_ReporterId",
column: x => x.ReporterId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "StoredFiles",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
FileIdentifier = table.Column(type: "text", nullable: false),
ContentType = table.Column(type: "text", nullable: false),
FileSize = table.Column(type: "bigint", nullable: false),
OriginalFileName = table.Column(type: "text", nullable: false),
Hash = table.Column(type: "text", nullable: false),
CreatedAtUtc = table.Column(type: "timestamp with time zone", nullable: false),
IsPublic = table.Column(type: "boolean", nullable: false),
UploaderId = table.Column(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_StoredFiles", x => x.Id);
table.ForeignKey(
name: "FK_StoredFiles_AspNetUsers_UploaderId",
column: x => x.UploaderId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "UserIps",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
IpAddress = table.Column(type: "text", nullable: false),
FirstSeen = table.Column(type: "timestamp with time zone", nullable: false),
LastSeen = table.Column(type: "timestamp with time zone", nullable: false),
UserId = table.Column(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_UserIps", x => x.Id);
table.ForeignKey(
name: "FK_UserIps_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Watches",
columns: table => new
{
Id = table.Column(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
UserId = table.Column(type: "uuid", nullable: false),
TargetType = table.Column(type: "integer", nullable: false),
TargetId = table.Column(type: "integer", nullable: false),
CreatedAt = table.Column(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Watches", x => x.Id);
table.ForeignKey(
name: "FK_Watches_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "BooruTags",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
Name = table.Column(type: "character varying(100)", maxLength: 100, nullable: false),
CategoryId = table.Column(type: "uuid", nullable: true),
PostCount = table.Column(type: "integer", nullable: false),
CreatedAt = table.Column(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_BooruTags", x => x.Id);
table.ForeignKey(
name: "FK_BooruTags_BooruTagCategories_CategoryId",
column: x => x.CategoryId,
principalTable: "BooruTagCategories",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "BanAppeals",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
BanId = table.Column(type: "uuid", nullable: false),
UserId = table.Column(type: "uuid", nullable: false),
Reason = table.Column(type: "character varying(4000)", maxLength: 4000, nullable: false),
Status = table.Column(type: "integer", nullable: false),
CreatedAt = table.Column(type: "timestamp with time zone", nullable: false),
ResolvedAt = table.Column(type: "timestamp with time zone", nullable: true),
ModeratorNote = table.Column(type: "character varying(2000)", maxLength: 2000, nullable: true),
ModeratorId = table.Column(type: "uuid", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_BanAppeals", x => x.Id);
table.ForeignKey(
name: "FK_BanAppeals_AspNetUsers_ModeratorId",
column: x => x.ModeratorId,
principalTable: "AspNetUsers",
principalColumn: "Id");
table.ForeignKey(
name: "FK_BanAppeals_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_BanAppeals_Bans_BanId",
column: x => x.BanId,
principalTable: "Bans",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "BooruComments",
columns: table => new
{
Id = table.Column(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ContentRaw = table.Column(type: "text", maxLength: 10000, nullable: false),
ContentHtml = table.Column(type: "text", nullable: false),
CreatedAt = table.Column(type: "timestamp with time zone", nullable: false),
EditedAt = table.Column(type: "timestamp with time zone", nullable: true),
IpAddress = table.Column(type: "text", nullable: true),
UserId = table.Column(type: "uuid", nullable: false),
PostId = table.Column(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_BooruComments", x => x.Id);
table.ForeignKey(
name: "FK_BooruComments_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_BooruComments_BooruPosts_PostId",
column: x => x.PostId,
principalTable: "BooruPosts",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "BooruPostFavorites",
columns: table => new
{
PostId = table.Column(type: "integer", nullable: false),
UserId = table.Column(type: "uuid", nullable: false),
CreatedAt = table.Column(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_BooruPostFavorites", x => new { x.PostId, x.UserId });
table.ForeignKey(
name: "FK_BooruPostFavorites_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_BooruPostFavorites_BooruPosts_PostId",
column: x => x.PostId,
principalTable: "BooruPosts",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "BooruPostVotes",
columns: table => new
{
PostId = table.Column(type: "integer", nullable: false),
UserId = table.Column(type: "uuid", nullable: false),
Value = table.Column(type: "integer", nullable: false),
CreatedAt = table.Column(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_BooruPostVotes", x => new { x.PostId, x.UserId });
table.ForeignKey(
name: "FK_BooruPostVotes_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_BooruPostVotes_BooruPosts_PostId",
column: x => x.PostId,
principalTable: "BooruPosts",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "SourceHistories",
columns: table => new
{
Id = table.Column(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
PostId = table.Column(type: "integer", nullable: false),
UserId = table.Column(type: "uuid", nullable: false),
UserIp = table.Column(type: "text", nullable: true),
Source = table.Column(type: "character varying(2000)", maxLength: 2000, nullable: true),
DateSet = table.Column(type: "timestamp with time zone", nullable: false),
SuppressedAt = table.Column(type: "timestamp with time zone", nullable: true),
SuppressedById = table.Column(type: "uuid", nullable: true),
SuppressionReason = table.Column(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_SourceHistories", x => x.Id);
table.ForeignKey(
name: "FK_SourceHistories_AspNetUsers_SuppressedById",
column: x => x.SuppressedById,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_SourceHistories_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_SourceHistories_BooruPosts_PostId",
column: x => x.PostId,
principalTable: "BooruPosts",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "TagHistories",
columns: table => new
{
Id = table.Column(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
PostId = table.Column(type: "integer", nullable: false),
UserId = table.Column(type: "uuid", nullable: false),
UserIp = table.Column(type: "text", nullable: true),
Tags = table.Column(type: "text", nullable: false),
DateSet = table.Column(type: "timestamp with time zone", nullable: false),
SuppressedAt = table.Column(type: "timestamp with time zone", nullable: true),
SuppressedById = table.Column(type: "uuid", nullable: true),
SuppressionReason = table.Column(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_TagHistories", x => x.Id);
table.ForeignKey(
name: "FK_TagHistories_AspNetUsers_SuppressedById",
column: x => x.SuppressedById,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_TagHistories_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_TagHistories_BooruPosts_PostId",
column: x => x.PostId,
principalTable: "BooruPosts",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ConversationParticipants",
columns: table => new
{
ConversationId = table.Column(type: "uuid", nullable: false),
UserId = table.Column(type: "uuid", nullable: false),
JoinedAt = table.Column(type: "timestamp with time zone", nullable: false),
LastReadAt = table.Column(type: "timestamp with time zone", nullable: true),
HasLeft = table.Column(type: "boolean", nullable: false),
LeftAt = table.Column(type: "timestamp with time zone", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_ConversationParticipants", x => new { x.ConversationId, x.UserId });
table.ForeignKey(
name: "FK_ConversationParticipants_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ConversationParticipants_Conversations_ConversationId",
column: x => x.ConversationId,
principalTable: "Conversations",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Messages",
columns: table => new
{
Id = table.Column(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ContentRaw = table.Column(type: "character varying(10000)", maxLength: 10000, nullable: false),
ContentHtml = table.Column(type: "text", nullable: false),
CreatedAt = table.Column(type: "timestamp with time zone", nullable: false),
EditedAt = table.Column(type: "timestamp with time zone", nullable: true),
ConversationId = table.Column(type: "uuid", nullable: false),
AuthorId = table.Column(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Messages", x => x.Id);
table.ForeignKey(
name: "FK_Messages_AspNetUsers_AuthorId",
column: x => x.AuthorId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_Messages_Conversations_ConversationId",
column: x => x.ConversationId,
principalTable: "Conversations",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "BooruTagAliases",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
AliasTagId = table.Column(type: "uuid", nullable: false),
TargetTagId = table.Column(type: "uuid", nullable: false),
CreatedAt = table.Column(type: "timestamp with time zone", nullable: false),
CreatedByUserId = table.Column(type: "uuid", nullable: true),
IsActive = table.Column(type: "boolean", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_BooruTagAliases", x => x.Id);
table.ForeignKey(
name: "FK_BooruTagAliases_AspNetUsers_CreatedByUserId",
column: x => x.CreatedByUserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_BooruTagAliases_BooruTags_AliasTagId",
column: x => x.AliasTagId,
principalTable: "BooruTags",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_BooruTagAliases_BooruTags_TargetTagId",
column: x => x.TargetTagId,
principalTable: "BooruTags",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "BooruTagImplications",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
AntecedentTagId = table.Column(type: "uuid", nullable: false),
ConsequentTagId = table.Column(type: "uuid", nullable: false),
CreatedAt = table.Column