Files
reallife-gamemode/ReallifeGamemode.Database/Migrations/20210413201146_Ammunations.cs
2021-04-13 23:56:24 +02:00

102 lines
4.0 KiB
C#

using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
namespace ReallifeGamemode.Database.Migrations
{
public partial class Ammunations : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "WeaponCategories",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Category = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_WeaponCategories", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Weapons",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
WeaponModel = table.Column<string>(nullable: true),
CategoryId = table.Column<int>(nullable: false),
SlotID = table.Column<int>(nullable: false),
Ammo = table.Column<int>(nullable: false),
Price = table.Column<float>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Weapons", x => x.Id);
table.ForeignKey(
name: "FK_Weapons_WeaponCategories_CategoryId",
column: x => x.CategoryId,
principalTable: "WeaponCategories",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "UserWeapons",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
UserId = table.Column<int>(nullable: false),
WeaponId = table.Column<int>(nullable: false),
Ammo = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_UserWeapons", x => x.Id);
table.ForeignKey(
name: "FK_UserWeapons_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_UserWeapons_Weapons_WeaponId",
column: x => x.WeaponId,
principalTable: "Weapons",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_UserWeapons_UserId",
table: "UserWeapons",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_UserWeapons_WeaponId",
table: "UserWeapons",
column: "WeaponId");
migrationBuilder.CreateIndex(
name: "IX_Weapons_CategoryId",
table: "Weapons",
column: "CategoryId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "UserWeapons");
migrationBuilder.DropTable(
name: "Weapons");
migrationBuilder.DropTable(
name: "WeaponCategories");
}
}
}