Adeed base database build

This commit is contained in:
Samuele Lorefice
2023-11-07 01:47:56 +01:00
parent 1fe234914d
commit 57ddbbf115
13 changed files with 532 additions and 121 deletions

View File

@@ -0,0 +1,159 @@
// <auto-generated />
using IsleBot;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace IsleBot.Migrations
{
[DbContext(typeof(DbManager))]
[Migration("20231107003428_Initial")]
partial class Initial
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.13");
modelBuilder.Entity("IsleBot.Card", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("Attack")
.HasColumnType("INTEGER");
b.Property<int>("CurrentHealth")
.HasColumnType("INTEGER");
b.Property<int>("Defense")
.HasColumnType("INTEGER");
b.Property<int>("MaxHealth")
.HasColumnType("INTEGER");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("OwnerId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("OwnerId");
b.ToTable("Cards");
});
modelBuilder.Entity("IsleBot.Match", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("PlayedTurns")
.HasColumnType("INTEGER");
b.Property<int>("PlayerACardId")
.HasColumnType("INTEGER");
b.Property<int>("PlayerAId")
.HasColumnType("INTEGER");
b.Property<int>("PlayerBCardId")
.HasColumnType("INTEGER");
b.Property<int>("PlayerBId")
.HasColumnType("INTEGER");
b.Property<int>("Status")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("PlayerACardId");
b.HasIndex("PlayerAId");
b.HasIndex("PlayerBCardId");
b.HasIndex("PlayerBId");
b.ToTable("Matches");
});
modelBuilder.Entity("IsleBot.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("UserName")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Players");
});
modelBuilder.Entity("IsleBot.Card", b =>
{
b.HasOne("IsleBot.User", "Owner")
.WithMany("Cards")
.HasForeignKey("OwnerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Owner");
});
modelBuilder.Entity("IsleBot.Match", b =>
{
b.HasOne("IsleBot.Card", "PlayerACard")
.WithMany()
.HasForeignKey("PlayerACardId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("IsleBot.User", "PlayerA")
.WithMany()
.HasForeignKey("PlayerAId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("IsleBot.Card", "PlayerBCard")
.WithMany()
.HasForeignKey("PlayerBCardId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("IsleBot.User", "PlayerB")
.WithMany()
.HasForeignKey("PlayerBId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("PlayerA");
b.Navigation("PlayerACard");
b.Navigation("PlayerB");
b.Navigation("PlayerBCard");
});
modelBuilder.Entity("IsleBot.User", b =>
{
b.Navigation("Cards");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,131 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace IsleBot.Migrations
{
/// <inheritdoc />
public partial class Initial : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Players",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
UserName = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Players", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Cards",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: false),
Attack = table.Column<int>(type: "INTEGER", nullable: false),
Defense = table.Column<int>(type: "INTEGER", nullable: false),
MaxHealth = table.Column<int>(type: "INTEGER", nullable: false),
CurrentHealth = table.Column<int>(type: "INTEGER", nullable: false),
OwnerId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Cards", x => x.Id);
table.ForeignKey(
name: "FK_Cards_Players_OwnerId",
column: x => x.OwnerId,
principalTable: "Players",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Matches",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
PlayerAId = table.Column<int>(type: "INTEGER", nullable: false),
PlayerACardId = table.Column<int>(type: "INTEGER", nullable: false),
PlayerBId = table.Column<int>(type: "INTEGER", nullable: false),
PlayerBCardId = table.Column<int>(type: "INTEGER", nullable: false),
PlayedTurns = table.Column<int>(type: "INTEGER", nullable: false),
Status = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Matches", x => x.Id);
table.ForeignKey(
name: "FK_Matches_Cards_PlayerACardId",
column: x => x.PlayerACardId,
principalTable: "Cards",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Matches_Cards_PlayerBCardId",
column: x => x.PlayerBCardId,
principalTable: "Cards",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Matches_Players_PlayerAId",
column: x => x.PlayerAId,
principalTable: "Players",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Matches_Players_PlayerBId",
column: x => x.PlayerBId,
principalTable: "Players",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Cards_OwnerId",
table: "Cards",
column: "OwnerId");
migrationBuilder.CreateIndex(
name: "IX_Matches_PlayerACardId",
table: "Matches",
column: "PlayerACardId");
migrationBuilder.CreateIndex(
name: "IX_Matches_PlayerAId",
table: "Matches",
column: "PlayerAId");
migrationBuilder.CreateIndex(
name: "IX_Matches_PlayerBCardId",
table: "Matches",
column: "PlayerBCardId");
migrationBuilder.CreateIndex(
name: "IX_Matches_PlayerBId",
table: "Matches",
column: "PlayerBId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Matches");
migrationBuilder.DropTable(
name: "Cards");
migrationBuilder.DropTable(
name: "Players");
}
}
}

View File

@@ -0,0 +1,156 @@
// <auto-generated />
using IsleBot;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace IsleBot.Migrations
{
[DbContext(typeof(DbManager))]
partial class DbManagerModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.13");
modelBuilder.Entity("IsleBot.Card", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("Attack")
.HasColumnType("INTEGER");
b.Property<int>("CurrentHealth")
.HasColumnType("INTEGER");
b.Property<int>("Defense")
.HasColumnType("INTEGER");
b.Property<int>("MaxHealth")
.HasColumnType("INTEGER");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("OwnerId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("OwnerId");
b.ToTable("Cards");
});
modelBuilder.Entity("IsleBot.Match", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("PlayedTurns")
.HasColumnType("INTEGER");
b.Property<int>("PlayerACardId")
.HasColumnType("INTEGER");
b.Property<int>("PlayerAId")
.HasColumnType("INTEGER");
b.Property<int>("PlayerBCardId")
.HasColumnType("INTEGER");
b.Property<int>("PlayerBId")
.HasColumnType("INTEGER");
b.Property<int>("Status")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("PlayerACardId");
b.HasIndex("PlayerAId");
b.HasIndex("PlayerBCardId");
b.HasIndex("PlayerBId");
b.ToTable("Matches");
});
modelBuilder.Entity("IsleBot.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("UserName")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Players");
});
modelBuilder.Entity("IsleBot.Card", b =>
{
b.HasOne("IsleBot.User", "Owner")
.WithMany("Cards")
.HasForeignKey("OwnerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Owner");
});
modelBuilder.Entity("IsleBot.Match", b =>
{
b.HasOne("IsleBot.Card", "PlayerACard")
.WithMany()
.HasForeignKey("PlayerACardId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("IsleBot.User", "PlayerA")
.WithMany()
.HasForeignKey("PlayerAId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("IsleBot.Card", "PlayerBCard")
.WithMany()
.HasForeignKey("PlayerBCardId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("IsleBot.User", "PlayerB")
.WithMany()
.HasForeignKey("PlayerBId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("PlayerA");
b.Navigation("PlayerACard");
b.Navigation("PlayerB");
b.Navigation("PlayerBCard");
});
modelBuilder.Entity("IsleBot.User", b =>
{
b.Navigation("Cards");
});
#pragma warning restore 612, 618
}
}
}