69 lines
2.6 KiB
C#
69 lines
2.6 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace UserManagement.API.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class Initial : 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),
|
|
ROLE_ID = table.Column<int>(type: "int", nullable: false),
|
|
ROLE = table.Column<int>(type: "int", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Users", x => x.ID);
|
|
table.ForeignKey(
|
|
name: "FK_Users_Roles_ROLE_ID",
|
|
column: x => x.ROLE_ID,
|
|
principalTable: "Roles",
|
|
principalColumn: "ID",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Users_ROLE_ID",
|
|
table: "Users",
|
|
column: "ROLE_ID");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "Users");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Roles");
|
|
}
|
|
}
|
|
}
|