using System; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace SystemRevivalServer.Migrations { /// public partial class AddOverworldRegionZoneChunkEditor : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "world_regions", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Name = table.Column(type: "varchar(64)", maxLength: 64, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), ZonesPerRegionX = table.Column(type: "int", nullable: false), ZonesPerRegionY = table.Column(type: "int", nullable: false), ChunksPerZoneX = table.Column(type: "int", nullable: false), ChunksPerZoneY = table.Column(type: "int", nullable: false), ChunkWidthTiles = table.Column(type: "int", nullable: false), ChunkHeightTiles = table.Column(type: "int", nullable: false), IsEnabled = table.Column(type: "tinyint(1)", nullable: false), CreatedAt = table.Column(type: "datetime(6)", nullable: false), UpdatedAt = table.Column(type: "datetime(6)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_world_regions", x => x.Id); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "world_zones", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), RegionId = table.Column(type: "int", nullable: false), ZoneX = table.Column(type: "int", nullable: false), ZoneY = table.Column(type: "int", nullable: false), Name = table.Column(type: "varchar(64)", maxLength: 64, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), IsEnabled = table.Column(type: "tinyint(1)", nullable: false), CreatedAt = table.Column(type: "datetime(6)", nullable: false), UpdatedAt = table.Column(type: "datetime(6)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_world_zones", x => x.Id); table.ForeignKey( name: "FK_world_zones_world_regions_RegionId", column: x => x.RegionId, principalTable: "world_regions", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "world_chunks", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), WorldZoneId = table.Column(type: "bigint", nullable: false), ChunkX = table.Column(type: "int", nullable: false), ChunkY = table.Column(type: "int", nullable: false), Version = table.Column(type: "bigint", nullable: false), CreatedAt = table.Column(type: "datetime(6)", nullable: false), UpdatedAt = table.Column(type: "datetime(6)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_world_chunks", x => x.Id); table.ForeignKey( name: "FK_world_chunks_world_zones_WorldZoneId", column: x => x.WorldZoneId, principalTable: "world_zones", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "world_chunk_npc_spawns", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), WorldChunkId = table.Column(type: "bigint", nullable: false), NpcDefinitionId = table.Column(type: "int", nullable: false), TileX = table.Column(type: "int", nullable: false), TileY = table.Column(type: "int", nullable: false), Rotation = table.Column(type: "int", nullable: false), MetadataJson = table.Column(type: "varchar(1024)", maxLength: 1024, nullable: true) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_world_chunk_npc_spawns", x => x.Id); table.ForeignKey( name: "FK_world_chunk_npc_spawns_dungeon_npc_definitions_NpcDefinition~", column: x => x.NpcDefinitionId, principalTable: "dungeon_npc_definitions", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_world_chunk_npc_spawns_world_chunks_WorldChunkId", column: x => x.WorldChunkId, principalTable: "world_chunks", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "world_chunk_objects", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), WorldChunkId = table.Column(type: "bigint", nullable: false), ObjectDefinitionId = table.Column(type: "int", nullable: false), TileX = table.Column(type: "int", nullable: false), TileY = table.Column(type: "int", nullable: false), Rotation = table.Column(type: "int", nullable: false), MetadataJson = table.Column(type: "varchar(1024)", maxLength: 1024, nullable: true) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_world_chunk_objects", x => x.Id); table.ForeignKey( name: "FK_world_chunk_objects_dungeon_objects_ObjectDefinitionId", column: x => x.ObjectDefinitionId, principalTable: "dungeon_objects", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_world_chunk_objects_world_chunks_WorldChunkId", column: x => x.WorldChunkId, principalTable: "world_chunks", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "world_chunk_tiles", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), WorldChunkId = table.Column(type: "bigint", nullable: false), TileX = table.Column(type: "int", nullable: false), TileY = table.Column(type: "int", nullable: false), SheetId = table.Column(type: "int", nullable: false), FrameIndex = table.Column(type: "int", nullable: false), IsWalkable = table.Column(type: "tinyint(1)", nullable: false), IsInvisiblePaywall = table.Column(type: "tinyint(1)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_world_chunk_tiles", x => x.Id); table.ForeignKey( name: "FK_world_chunk_tiles_world_chunks_WorldChunkId", column: x => x.WorldChunkId, principalTable: "world_chunks", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateIndex( name: "IX_world_chunk_npc_spawns_NpcDefinitionId", table: "world_chunk_npc_spawns", column: "NpcDefinitionId"); migrationBuilder.CreateIndex( name: "IX_world_chunk_npc_spawns_WorldChunkId_TileX_TileY_NpcDefinitio~", table: "world_chunk_npc_spawns", columns: new[] { "WorldChunkId", "TileX", "TileY", "NpcDefinitionId" }); migrationBuilder.CreateIndex( name: "IX_world_chunk_objects_ObjectDefinitionId", table: "world_chunk_objects", column: "ObjectDefinitionId"); migrationBuilder.CreateIndex( name: "IX_world_chunk_objects_WorldChunkId_TileX_TileY_ObjectDefinitio~", table: "world_chunk_objects", columns: new[] { "WorldChunkId", "TileX", "TileY", "ObjectDefinitionId" }); migrationBuilder.CreateIndex( name: "IX_world_chunk_tiles_WorldChunkId_TileX_TileY", table: "world_chunk_tiles", columns: new[] { "WorldChunkId", "TileX", "TileY" }, unique: true); migrationBuilder.CreateIndex( name: "IX_world_chunks_WorldZoneId_ChunkX_ChunkY", table: "world_chunks", columns: new[] { "WorldZoneId", "ChunkX", "ChunkY" }, unique: true); migrationBuilder.CreateIndex( name: "IX_world_regions_Name", table: "world_regions", column: "Name", unique: true); migrationBuilder.CreateIndex( name: "IX_world_zones_RegionId_ZoneX_ZoneY", table: "world_zones", columns: new[] { "RegionId", "ZoneX", "ZoneY" }, unique: true); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "world_chunk_npc_spawns"); migrationBuilder.DropTable( name: "world_chunk_objects"); migrationBuilder.DropTable( name: "world_chunk_tiles"); migrationBuilder.DropTable( name: "world_chunks"); migrationBuilder.DropTable( name: "world_zones"); migrationBuilder.DropTable( name: "world_regions"); } } }