88 lines
3.2 KiB
C#
88 lines
3.2 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace UserManagement.API.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class Init : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "Roles",
|
|
columns: table => new
|
|
{
|
|
ID = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
ROLE = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
CREATION_DATE = table.Column<DateTime>(type: "datetime", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Roles", x => x.ID);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Users",
|
|
columns: table => new
|
|
{
|
|
ID = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
USER_NAME = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
FIRST_NAME = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
LAST_NAME = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
PASSWORD = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Users", x => x.ID);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "UserRoles",
|
|
columns: table => new
|
|
{
|
|
USER_ID = table.Column<int>(type: "int", nullable: false),
|
|
ROLE_ID = table.Column<int>(type: "int", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_UserRoles", x => new { x.USER_ID, x.ROLE_ID });
|
|
table.ForeignKey(
|
|
name: "FK_UserRoles_Roles_ROLE_ID",
|
|
column: x => x.ROLE_ID,
|
|
principalTable: "Roles",
|
|
principalColumn: "ID",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_UserRoles_Users_USER_ID",
|
|
column: x => x.USER_ID,
|
|
principalTable: "Users",
|
|
principalColumn: "ID",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_UserRoles_ROLE_ID",
|
|
table: "UserRoles",
|
|
column: "ROLE_ID");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "UserRoles");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Roles");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Users");
|
|
}
|
|
}
|
|
}
|