using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace IUT_ISTAG.Migrations
{
///
public partial class Init : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterDatabase()
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "ApplicationRoles",
columns: table => new
{
Id = table.Column(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Name = table.Column(type: "varchar(256)", maxLength: 256, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
NormalizedName = table.Column(type: "varchar(256)", maxLength: 256, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
ConcurrencyStamp = table.Column(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_ApplicationRoles", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "ApplicationUsers",
columns: table => new
{
Id = table.Column(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
CreatedAt = table.Column(type: "datetime(6)", nullable: false),
is_actif = table.Column(type: "tinyint(1)", nullable: false),
nom = table.Column(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
CreatedByUserId = table.Column(type: "int", nullable: true),
UserName = table.Column(type: "varchar(256)", maxLength: 256, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
NormalizedUserName = table.Column(type: "varchar(256)", maxLength: 256, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Email = table.Column(type: "varchar(256)", maxLength: 256, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
NormalizedEmail = table.Column(type: "varchar(256)", maxLength: 256, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
EmailConfirmed = table.Column(type: "tinyint(1)", nullable: false),
PasswordHash = table.Column(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
SecurityStamp = table.Column(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
ConcurrencyStamp = table.Column(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
PhoneNumber = table.Column(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
PhoneNumberConfirmed = table.Column(type: "tinyint(1)", nullable: false),
TwoFactorEnabled = table.Column(type: "tinyint(1)", nullable: false),
LockoutEnd = table.Column(type: "datetime(6)", nullable: true),
LockoutEnabled = table.Column(type: "tinyint(1)", nullable: false),
AccessFailedCount = table.Column(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ApplicationUsers", x => x.Id);
table.ForeignKey(
name: "FK_ApplicationUsers_ApplicationUsers_CreatedByUserId",
column: x => x.CreatedByUserId,
principalTable: "ApplicationUsers",
principalColumn: "Id");
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "ApplicationRoleClaims",
columns: table => new
{
Id = table.Column(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
RoleId = table.Column(type: "int", nullable: false),
ClaimType = table.Column(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
ClaimValue = table.Column(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_ApplicationRoleClaims", x => x.Id);
table.ForeignKey(
name: "FK_ApplicationRoleClaims_ApplicationRoles_RoleId",
column: x => x.RoleId,
principalTable: "ApplicationRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "ApplicationUserClaims",
columns: table => new
{
Id = table.Column(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
UserId = table.Column(type: "int", nullable: false),
ClaimType = table.Column(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
ClaimValue = table.Column(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_ApplicationUserClaims", x => x.Id);
table.ForeignKey(
name: "FK_ApplicationUserClaims_ApplicationUsers_UserId",
column: x => x.UserId,
principalTable: "ApplicationUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "ApplicationUserLogins",
columns: table => new
{
LoginProvider = table.Column(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
ProviderKey = table.Column(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
ProviderDisplayName = table.Column(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
UserId = table.Column(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ApplicationUserLogins", x => new { x.LoginProvider, x.ProviderKey });
table.ForeignKey(
name: "FK_ApplicationUserLogins_ApplicationUsers_UserId",
column: x => x.UserId,
principalTable: "ApplicationUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "ApplicationUserRoles",
columns: table => new
{
UserId = table.Column(type: "int", nullable: false),
RoleId = table.Column(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ApplicationUserRoles", x => new { x.UserId, x.RoleId });
table.ForeignKey(
name: "FK_ApplicationUserRoles_ApplicationRoles_RoleId",
column: x => x.RoleId,
principalTable: "ApplicationRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ApplicationUserRoles_ApplicationUsers_UserId",
column: x => x.UserId,
principalTable: "ApplicationUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "ApplicationUserTokens",
columns: table => new
{
UserId = table.Column(type: "int", nullable: false),
LoginProvider = table.Column(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Name = table.Column(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Value = table.Column(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_ApplicationUserTokens", x => new { x.UserId, x.LoginProvider, x.Name });
table.ForeignKey(
name: "FK_ApplicationUserTokens_ApplicationUsers_UserId",
column: x => x.UserId,
principalTable: "ApplicationUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.InsertData(
table: "ApplicationRoles",
columns: new[] { "Id", "ConcurrencyStamp", "Name", "NormalizedName" },
values: new object[,]
{
{ 1, null, "Super_Admin", "SUPER_ADMIN" },
{ 2, null, "Administrateur_Niveau_3", "ADMINISTRATEUR_NIVEAU_3" },
{ 3, null, "Administrateur_Niveau_2", "ADMINISTRATEUR_NIVEAU_2" },
{ 4, null, "Administrateur_Niveau_1", "ADMINISTRATEUR_NIVEAU_1" },
{ 5, null, "Enseignant", "Enseignant" },
{ 6, null, "Étudiant", "ÉTUDIANT" }
});
migrationBuilder.InsertData(
table: "ApplicationUsers",
columns: new[] { "Id", "AccessFailedCount", "ConcurrencyStamp", "CreatedAt", "CreatedByUserId", "Email", "EmailConfirmed", "LockoutEnabled", "LockoutEnd", "NormalizedEmail", "NormalizedUserName", "PasswordHash", "PhoneNumber", "PhoneNumberConfirmed", "SecurityStamp", "TwoFactorEnabled", "UserName", "is_actif", "nom" },
values: new object[] { 1, 0, "da9f3739-2ca6-4ec3-b867-91f6f3bac515", new DateTime(2026, 5, 20, 21, 12, 9, 309, DateTimeKind.Utc).AddTicks(2357), null, "admin@istag.com", true, false, null, "ADMIN@istag.com", "ADMIN", "AQAAAAIAAYagAAAAENxyUEdROj9rEK7kwgJVKFfcJ9lbGTXpaitrkbVLrV22a8A0tVewXsPgGFp1rRXgMQ==", "672651571", false, "a0e5ab59-a729-43c9-8059-fe24d62c04a6", false, "admin", true, "admin" });
migrationBuilder.InsertData(
table: "ApplicationUserRoles",
columns: new[] { "RoleId", "UserId" },
values: new object[] { 1, 1 });
migrationBuilder.CreateIndex(
name: "IX_ApplicationRoleClaims_RoleId",
table: "ApplicationRoleClaims",
column: "RoleId");
migrationBuilder.CreateIndex(
name: "RoleNameIndex",
table: "ApplicationRoles",
column: "NormalizedName",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_ApplicationUserClaims_UserId",
table: "ApplicationUserClaims",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_ApplicationUserLogins_UserId",
table: "ApplicationUserLogins",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_ApplicationUserRoles_RoleId",
table: "ApplicationUserRoles",
column: "RoleId");
migrationBuilder.CreateIndex(
name: "EmailIndex",
table: "ApplicationUsers",
column: "NormalizedEmail");
migrationBuilder.CreateIndex(
name: "IX_ApplicationUsers_CreatedByUserId",
table: "ApplicationUsers",
column: "CreatedByUserId");
migrationBuilder.CreateIndex(
name: "UserNameIndex",
table: "ApplicationUsers",
column: "NormalizedUserName",
unique: true);
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ApplicationRoleClaims");
migrationBuilder.DropTable(
name: "ApplicationUserClaims");
migrationBuilder.DropTable(
name: "ApplicationUserLogins");
migrationBuilder.DropTable(
name: "ApplicationUserRoles");
migrationBuilder.DropTable(
name: "ApplicationUserTokens");
migrationBuilder.DropTable(
name: "ApplicationRoles");
migrationBuilder.DropTable(
name: "ApplicationUsers");
}
}
}