using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace UserManagement.API.Migrations
{
///
public partial class Init : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Roles",
columns: table => new
{
ID = table.Column(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ROLE = table.Column(type: "nvarchar(max)", nullable: false),
CREATION_DATE = table.Column(type: "datetime", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Roles", x => x.ID);
});
migrationBuilder.CreateTable(
name: "Users",
columns: table => new
{
ID = table.Column(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
USER_NAME = table.Column(type: "nvarchar(max)", nullable: false),
FIRST_NAME = table.Column(type: "nvarchar(max)", nullable: false),
LAST_NAME = table.Column(type: "nvarchar(max)", nullable: false),
PASSWORD = table.Column(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(type: "int", nullable: false),
ROLE_ID = table.Column(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");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "UserRoles");
migrationBuilder.DropTable(
name: "Roles");
migrationBuilder.DropTable(
name: "Users");
}
}
}