using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Nocr.Users.Persistence.Migrations
{
///
public partial class InitialMigration : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterDatabase()
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "Users",
columns: table => new
{
Id = table.Column(type: "bigint", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Username = table.Column(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_Users", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "UserIdentity",
columns: table => new
{
Id = table.Column(type: "bigint", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Identity = table.Column(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
UserId = table.Column(type: "bigint", nullable: false),
Type = table.Column(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_UserIdentity", x => x.Id);
table.ForeignKey(
name: "FK_UserIdentity_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id");
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_UserIdentity_UserId",
table: "UserIdentity",
column: "UserId");
migrationBuilder.CreateIndex(
name: "UX_users_identity_identity_type",
table: "UserIdentity",
columns: new[] { "Identity", "Type" },
unique: true);
migrationBuilder.CreateIndex(
name: "UX_users_username",
table: "Users",
column: "Username",
unique: true);
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "UserIdentity");
migrationBuilder.DropTable(
name: "Users");
}
}
}