db + migrations

This commit is contained in:
Aleksandr Popov
2023-06-25 18:33:44 +02:00
parent 944712df97
commit 34acef713d
14 changed files with 255 additions and 172 deletions
@@ -0,0 +1,53 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using TURN.Services.Chess.DBModel;
#nullable disable
namespace TURN.Services.Chess.Migrations
{
[DbContext(typeof(ModelBaseContext))]
[Migration("20230625160918_Init")]
partial class Init
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.8")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("TURN.Services.Chess.DBModel.Game", b =>
{
b.Property<long?>("GameId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint")
.HasColumnName("GameId");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long?>("GameId"));
b.Property<string>("BlackUserName")
.HasColumnType("text");
b.Property<string>("StartDate")
.HasColumnType("text");
b.Property<string>("WhiteUserName")
.HasColumnType("text");
b.HasKey("GameId");
b.ToTable("Games");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,37 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace TURN.Services.Chess.Migrations
{
/// <inheritdoc />
public partial class Init : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Games",
columns: table => new
{
GameId = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
BlackUserName = table.Column<string>(type: "varchar", nullable: true),
WhiteUserName = table.Column<string>(type: "varchar", nullable: true),
StartDate = table.Column<string>(type: "varchar", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Games", x => x.GameId);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Games");
}
}
}
@@ -0,0 +1,50 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using TURN.Services.Chess.DBModel;
#nullable disable
namespace TURN.Services.Chess.Migrations
{
[DbContext(typeof(ModelBaseContext))]
partial class ModelBaseContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.8")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("TURN.Services.Chess.DBModel.Game", b =>
{
b.Property<long?>("GameId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint")
.HasColumnName("GameId");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long?>("GameId"));
b.Property<string>("BlackUserName")
.HasColumnType("text");
b.Property<string>("StartDate")
.HasColumnType("text");
b.Property<string>("WhiteUserName")
.HasColumnType("text");
b.HasKey("GameId");
b.ToTable("Games");
});
#pragma warning restore 612, 618
}
}
}