using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace Nuuru.Server.Migrations.PostgreSQL { /// public partial class AddBointsAndClans : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AddColumn( name: "BoostedUntil", table: "BooruPosts", type: "timestamp with time zone", nullable: true); migrationBuilder.AddColumn( name: "HasGoldenFrame", table: "BooruPosts", type: "boolean", nullable: false, defaultValue: false); migrationBuilder.AddColumn( name: "Boints", table: "AspNetUsers", type: "integer", nullable: false, defaultValue: 0); migrationBuilder.AddColumn( name: "ForcedDisplayName", table: "AspNetUsers", type: "character varying(30)", maxLength: 30, nullable: true); migrationBuilder.AddColumn( name: "ForcedDisplayNameUntil", table: "AspNetUsers", type: "timestamp with time zone", nullable: true); migrationBuilder.AddColumn( name: "HasProfileBorder", table: "AspNetUsers", type: "boolean", maxLength: 50, nullable: false, defaultValue: false); migrationBuilder.AddColumn( name: "HasRenameImmunity", table: "AspNetUsers", type: "boolean", nullable: false, defaultValue: false); migrationBuilder.AddColumn( name: "RenameImmunityUntil", table: "AspNetUsers", type: "timestamp with time zone", nullable: true); migrationBuilder.CreateTable( name: "BointsLedger", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), UserId = table.Column(type: "uuid", nullable: false), Amount = table.Column(type: "integer", nullable: false), Reason = table.Column(type: "integer", nullable: false), SourcePostId = table.Column(type: "integer", nullable: true), SourceCommentId = table.Column(type: "integer", nullable: true), SourceForumPostId = table.Column(type: "integer", nullable: true), SourceUserId = table.Column(type: "uuid", nullable: true), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_BointsLedger", x => x.Id); table.ForeignKey( name: "FK_BointsLedger_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Clans", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Name = table.Column(type: "character varying(30)", maxLength: 30, nullable: false), Tag = table.Column(type: "character varying(5)", maxLength: 5, nullable: false), Color = table.Column(type: "character varying(7)", maxLength: 7, nullable: false), LeaderId = table.Column(type: "uuid", nullable: false), Treasury = table.Column(type: "integer", nullable: false), MaxMembers = table.Column(type: "integer", nullable: false), TaxRate = table.Column(type: "integer", nullable: false), BannerStorageIdentifier = table.Column(type: "text", nullable: true), BadgeStorageIdentifier = table.Column(type: "text", nullable: true), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Clans", x => x.Id); table.ForeignKey( name: "FK_Clans_AspNetUsers_LeaderId", column: x => x.LeaderId, principalTable: "AspNetUsers", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "SiteEffects", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Type = table.Column(type: "integer", nullable: false), Content = table.Column(type: "character varying(500)", maxLength: 500, nullable: false), UserId = table.Column(type: "uuid", nullable: false), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), ExpiresAt = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_SiteEffects", x => x.Id); table.ForeignKey( name: "FK_SiteEffects_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "UserInventoryItems", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), UserId = table.Column(type: "uuid", nullable: false), ItemId = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), Quantity = table.Column(type: "integer", nullable: false), AcquiredAt = table.Column(type: "timestamp with time zone", nullable: false), UpdatedAt = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_UserInventoryItems", x => x.Id); table.ForeignKey( name: "FK_UserInventoryItems_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "ClanEmotes", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), ClanId = table.Column(type: "integer", nullable: false), Name = table.Column(type: "character varying(30)", maxLength: 30, nullable: false), StorageIdentifier = table.Column(type: "text", nullable: false), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_ClanEmotes", x => x.Id); table.ForeignKey( name: "FK_ClanEmotes_Clans_ClanId", column: x => x.ClanId, principalTable: "Clans", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "ClanForumCategories", columns: table => new { ClanId = table.Column(type: "integer", nullable: false), ForumCategoryId = table.Column(type: "uuid", nullable: false) }, constraints: table => { table.PrimaryKey("PK_ClanForumCategories", x => x.ClanId); table.ForeignKey( name: "FK_ClanForumCategories_Clans_ClanId", column: x => x.ClanId, principalTable: "Clans", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_ClanForumCategories_ForumCategories_ForumCategoryId", column: x => x.ForumCategoryId, principalTable: "ForumCategories", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "ClanInvites", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), ClanId = table.Column(type: "integer", nullable: false), InvitedUserId = table.Column(type: "uuid", nullable: false), InvitedByUserId = table.Column(type: "uuid", nullable: false), IsApplication = table.Column(type: "boolean", nullable: false), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), ExpiresAt = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_ClanInvites", x => x.Id); table.ForeignKey( name: "FK_ClanInvites_AspNetUsers_InvitedByUserId", column: x => x.InvitedByUserId, principalTable: "AspNetUsers", principalColumn: "Id"); table.ForeignKey( name: "FK_ClanInvites_AspNetUsers_InvitedUserId", column: x => x.InvitedUserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_ClanInvites_Clans_ClanId", column: x => x.ClanId, principalTable: "Clans", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "ClanMembers", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), ClanId = table.Column(type: "integer", nullable: false), UserId = table.Column(type: "uuid", nullable: false), JoinedAt = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_ClanMembers", x => x.Id); table.ForeignKey( name: "FK_ClanMembers_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_ClanMembers_Clans_ClanId", column: x => x.ClanId, principalTable: "Clans", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_BointsLedger_SourcePostId", table: "BointsLedger", column: "SourcePostId"); migrationBuilder.CreateIndex( name: "IX_BointsLedger_UserId_CreatedAt", table: "BointsLedger", columns: new[] { "UserId", "CreatedAt" }); migrationBuilder.CreateIndex( name: "IX_BointsLedger_UserId_Reason_CreatedAt", table: "BointsLedger", columns: new[] { "UserId", "Reason", "CreatedAt" }); migrationBuilder.CreateIndex( name: "IX_BointsLedger_UserId_Reason_SourceCommentId_SourceUserId", table: "BointsLedger", columns: new[] { "UserId", "Reason", "SourceCommentId", "SourceUserId" }); migrationBuilder.CreateIndex( name: "IX_BointsLedger_UserId_Reason_SourceForumPostId_SourceUserId", table: "BointsLedger", columns: new[] { "UserId", "Reason", "SourceForumPostId", "SourceUserId" }); migrationBuilder.CreateIndex( name: "IX_BointsLedger_UserId_Reason_SourcePostId_SourceUserId", table: "BointsLedger", columns: new[] { "UserId", "Reason", "SourcePostId", "SourceUserId" }); migrationBuilder.CreateIndex( name: "IX_ClanEmotes_ClanId_Name", table: "ClanEmotes", columns: new[] { "ClanId", "Name" }, unique: true); migrationBuilder.CreateIndex( name: "IX_ClanEmotes_Name", table: "ClanEmotes", column: "Name", unique: true); migrationBuilder.CreateIndex( name: "IX_ClanForumCategories_ForumCategoryId", table: "ClanForumCategories", column: "ForumCategoryId", unique: true); migrationBuilder.CreateIndex( name: "IX_ClanInvites_ClanId_InvitedUserId", table: "ClanInvites", columns: new[] { "ClanId", "InvitedUserId" }, unique: true); migrationBuilder.CreateIndex( name: "IX_ClanInvites_ExpiresAt", table: "ClanInvites", column: "ExpiresAt"); migrationBuilder.CreateIndex( name: "IX_ClanInvites_InvitedByUserId", table: "ClanInvites", column: "InvitedByUserId"); migrationBuilder.CreateIndex( name: "IX_ClanInvites_InvitedUserId", table: "ClanInvites", column: "InvitedUserId"); migrationBuilder.CreateIndex( name: "IX_ClanMembers_ClanId", table: "ClanMembers", column: "ClanId"); migrationBuilder.CreateIndex( name: "IX_ClanMembers_UserId", table: "ClanMembers", column: "UserId", unique: true); migrationBuilder.CreateIndex( name: "IX_Clans_LeaderId", table: "Clans", column: "LeaderId"); migrationBuilder.CreateIndex( name: "IX_Clans_Name", table: "Clans", column: "Name", unique: true); migrationBuilder.CreateIndex( name: "IX_Clans_Tag", table: "Clans", column: "Tag", unique: true); migrationBuilder.CreateIndex( name: "IX_SiteEffects_ExpiresAt", table: "SiteEffects", column: "ExpiresAt"); migrationBuilder.CreateIndex( name: "IX_SiteEffects_Type_ExpiresAt", table: "SiteEffects", columns: new[] { "Type", "ExpiresAt" }); migrationBuilder.CreateIndex( name: "IX_SiteEffects_UserId", table: "SiteEffects", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_UserInventoryItems_UserId", table: "UserInventoryItems", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_UserInventoryItems_UserId_ItemId", table: "UserInventoryItems", columns: new[] { "UserId", "ItemId" }, unique: true); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "BointsLedger"); migrationBuilder.DropTable( name: "ClanEmotes"); migrationBuilder.DropTable( name: "ClanForumCategories"); migrationBuilder.DropTable( name: "ClanInvites"); migrationBuilder.DropTable( name: "ClanMembers"); migrationBuilder.DropTable( name: "SiteEffects"); migrationBuilder.DropTable( name: "UserInventoryItems"); migrationBuilder.DropTable( name: "Clans"); migrationBuilder.DropColumn( name: "BoostedUntil", table: "BooruPosts"); migrationBuilder.DropColumn( name: "HasGoldenFrame", table: "BooruPosts"); migrationBuilder.DropColumn( name: "Boints", table: "AspNetUsers"); migrationBuilder.DropColumn( name: "ForcedDisplayName", table: "AspNetUsers"); migrationBuilder.DropColumn( name: "ForcedDisplayNameUntil", table: "AspNetUsers"); migrationBuilder.DropColumn( name: "HasProfileBorder", table: "AspNetUsers"); migrationBuilder.DropColumn( name: "HasRenameImmunity", table: "AspNetUsers"); migrationBuilder.DropColumn( name: "RenameImmunityUntil", table: "AspNetUsers"); } } }