Files
systemrevivalserver/Migrations/20251223134442_CraftingSystem.cs
T
2025-12-23 08:45:11 -05:00

331 lines
17 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SystemRevivalServer.Migrations
{
/// <inheritdoc />
public partial class CraftingSystem : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "dungeon_character_crafting_skills",
columns: table => new
{
Id = table.Column<ulong>(type: "bigint unsigned", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
CharacterId = table.Column<ulong>(type: "bigint unsigned", nullable: false),
SkillType = table.Column<int>(type: "int", nullable: false),
Level = table.Column<int>(type: "int", nullable: false),
Experience = table.Column<long>(type: "bigint", nullable: false),
TotalItemsCrafted = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_dungeon_character_crafting_skills", x => x.Id);
table.ForeignKey(
name: "FK_dungeon_character_crafting_skills_dungeon_characters_Charact~",
column: x => x.CharacterId,
principalTable: "dungeon_characters",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "dungeon_crafting_recipes",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Name = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Description = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
SkillType = table.Column<int>(type: "int", nullable: false),
RequiredLevel = table.Column<int>(type: "int", nullable: false),
OutputItemDefinitionId = table.Column<int>(type: "int", nullable: false),
OutputQuantity = table.Column<int>(type: "int", nullable: false),
Tier = table.Column<int>(type: "int", nullable: false),
BaseXp = table.Column<int>(type: "int", nullable: false),
IsBaseRecipe = table.Column<bool>(type: "tinyint(1)", nullable: false),
HasStatRolls = table.Column<bool>(type: "tinyint(1)", nullable: false),
PossibleStatsJson = table.Column<string>(type: "varchar(1024)", maxLength: 1024, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
IsEnabled = table.Column<bool>(type: "tinyint(1)", nullable: false),
OutputItemId = table.Column<int>(type: "int", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_dungeon_crafting_recipes", x => x.Id);
table.ForeignKey(
name: "FK_dungeon_crafting_recipes_dungeon_item_definitions_OutputItem~",
column: x => x.OutputItemId,
principalTable: "dungeon_item_definitions",
principalColumn: "Id");
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "dungeon_character_known_recipes",
columns: table => new
{
Id = table.Column<ulong>(type: "bigint unsigned", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
CharacterId = table.Column<ulong>(type: "bigint unsigned", nullable: false),
RecipeId = table.Column<int>(type: "int", nullable: false),
DiscoveredAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
TimesCrafted = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_dungeon_character_known_recipes", x => x.Id);
table.ForeignKey(
name: "FK_dungeon_character_known_recipes_dungeon_characters_Character~",
column: x => x.CharacterId,
principalTable: "dungeon_characters",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_dungeon_character_known_recipes_dungeon_crafting_recipes_Rec~",
column: x => x.RecipeId,
principalTable: "dungeon_crafting_recipes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "dungeon_crafted_items",
columns: table => new
{
Id = table.Column<ulong>(type: "bigint unsigned", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
BaseItemDefinitionId = table.Column<int>(type: "int", nullable: false),
CrafterId = table.Column<ulong>(type: "bigint unsigned", nullable: true),
CrafterName = table.Column<string>(type: "varchar(32)", maxLength: 32, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
RecipeId = table.Column<int>(type: "int", nullable: true),
CraftedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
CraftingLevelAtCreation = table.Column<int>(type: "int", nullable: false),
RolledBonusStrength = table.Column<int>(type: "int", nullable: false),
RolledBonusIntelligence = table.Column<int>(type: "int", nullable: false),
RolledBonusWisdom = table.Column<int>(type: "int", nullable: false),
RolledBonusEndurance = table.Column<int>(type: "int", nullable: false),
RolledBonusDexterity = table.Column<int>(type: "int", nullable: false),
RolledBonusHealth = table.Column<int>(type: "int", nullable: false),
RolledBonusMana = table.Column<int>(type: "int", nullable: false),
RolledBonusArmor = table.Column<int>(type: "int", nullable: false),
RolledBonusMagicResist = table.Column<int>(type: "int", nullable: false),
RolledBonusMinDamage = table.Column<int>(type: "int", nullable: false),
RolledBonusMaxDamage = table.Column<int>(type: "int", nullable: false),
RolledBonusHealAmount = table.Column<int>(type: "int", nullable: false),
RolledBonusManaRestore = table.Column<int>(type: "int", nullable: false),
QualityRating = table.Column<int>(type: "int", nullable: false),
CustomName = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
RollHistoryJson = table.Column<string>(type: "varchar(1024)", maxLength: 1024, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_dungeon_crafted_items", x => x.Id);
table.ForeignKey(
name: "FK_dungeon_crafted_items_dungeon_characters_CrafterId",
column: x => x.CrafterId,
principalTable: "dungeon_characters",
principalColumn: "Id");
table.ForeignKey(
name: "FK_dungeon_crafted_items_dungeon_crafting_recipes_RecipeId",
column: x => x.RecipeId,
principalTable: "dungeon_crafting_recipes",
principalColumn: "Id");
table.ForeignKey(
name: "FK_dungeon_crafted_items_dungeon_item_definitions_BaseItemDefin~",
column: x => x.BaseItemDefinitionId,
principalTable: "dungeon_item_definitions",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "dungeon_crafting_recipe_ingredients",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
RecipeId = table.Column<int>(type: "int", nullable: false),
ItemDefinitionId = table.Column<int>(type: "int", nullable: false),
Quantity = table.Column<int>(type: "int", nullable: false),
SlotOrder = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_dungeon_crafting_recipe_ingredients", x => x.Id);
table.ForeignKey(
name: "FK_dungeon_crafting_recipe_ingredients_dungeon_crafting_recipes~",
column: x => x.RecipeId,
principalTable: "dungeon_crafting_recipes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_dungeon_crafting_recipe_ingredients_dungeon_item_definitions~",
column: x => x.ItemDefinitionId,
principalTable: "dungeon_item_definitions",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "dungeon_recipe_scrolls",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
ItemDefinitionId = table.Column<int>(type: "int", nullable: false),
RecipeId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_dungeon_recipe_scrolls", x => x.Id);
table.ForeignKey(
name: "FK_dungeon_recipe_scrolls_dungeon_crafting_recipes_RecipeId",
column: x => x.RecipeId,
principalTable: "dungeon_crafting_recipes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_dungeon_recipe_scrolls_dungeon_item_definitions_ItemDefiniti~",
column: x => x.ItemDefinitionId,
principalTable: "dungeon_item_definitions",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "dungeon_character_item_crafted_link",
columns: table => new
{
Id = table.Column<ulong>(type: "bigint unsigned", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
CharacterItemId = table.Column<ulong>(type: "bigint unsigned", nullable: false),
CraftedItemId = table.Column<ulong>(type: "bigint unsigned", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_dungeon_character_item_crafted_link", x => x.Id);
table.ForeignKey(
name: "FK_dungeon_character_item_crafted_link_dungeon_character_items_~",
column: x => x.CharacterItemId,
principalTable: "dungeon_character_items",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_dungeon_character_item_crafted_link_dungeon_crafted_items_Cr~",
column: x => x.CraftedItemId,
principalTable: "dungeon_crafted_items",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_dungeon_character_crafting_skills_CharacterId",
table: "dungeon_character_crafting_skills",
column: "CharacterId");
migrationBuilder.CreateIndex(
name: "IX_dungeon_character_item_crafted_link_CharacterItemId",
table: "dungeon_character_item_crafted_link",
column: "CharacterItemId");
migrationBuilder.CreateIndex(
name: "IX_dungeon_character_item_crafted_link_CraftedItemId",
table: "dungeon_character_item_crafted_link",
column: "CraftedItemId");
migrationBuilder.CreateIndex(
name: "IX_dungeon_character_known_recipes_CharacterId",
table: "dungeon_character_known_recipes",
column: "CharacterId");
migrationBuilder.CreateIndex(
name: "IX_dungeon_character_known_recipes_RecipeId",
table: "dungeon_character_known_recipes",
column: "RecipeId");
migrationBuilder.CreateIndex(
name: "IX_dungeon_crafted_items_BaseItemDefinitionId",
table: "dungeon_crafted_items",
column: "BaseItemDefinitionId");
migrationBuilder.CreateIndex(
name: "IX_dungeon_crafted_items_CrafterId",
table: "dungeon_crafted_items",
column: "CrafterId");
migrationBuilder.CreateIndex(
name: "IX_dungeon_crafted_items_RecipeId",
table: "dungeon_crafted_items",
column: "RecipeId");
migrationBuilder.CreateIndex(
name: "IX_dungeon_crafting_recipe_ingredients_ItemDefinitionId",
table: "dungeon_crafting_recipe_ingredients",
column: "ItemDefinitionId");
migrationBuilder.CreateIndex(
name: "IX_dungeon_crafting_recipe_ingredients_RecipeId",
table: "dungeon_crafting_recipe_ingredients",
column: "RecipeId");
migrationBuilder.CreateIndex(
name: "IX_dungeon_crafting_recipes_OutputItemId",
table: "dungeon_crafting_recipes",
column: "OutputItemId");
migrationBuilder.CreateIndex(
name: "IX_dungeon_recipe_scrolls_ItemDefinitionId",
table: "dungeon_recipe_scrolls",
column: "ItemDefinitionId");
migrationBuilder.CreateIndex(
name: "IX_dungeon_recipe_scrolls_RecipeId",
table: "dungeon_recipe_scrolls",
column: "RecipeId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "dungeon_character_crafting_skills");
migrationBuilder.DropTable(
name: "dungeon_character_item_crafted_link");
migrationBuilder.DropTable(
name: "dungeon_character_known_recipes");
migrationBuilder.DropTable(
name: "dungeon_crafting_recipe_ingredients");
migrationBuilder.DropTable(
name: "dungeon_recipe_scrolls");
migrationBuilder.DropTable(
name: "dungeon_crafted_items");
migrationBuilder.DropTable(
name: "dungeon_crafting_recipes");
}
}
}