using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace FSI.Prj.Mgt.Data.Migrations
{
    /// <inheritdoc />
    public partial class InitProjects : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<int>(
                name: "ProjectId",
                table: "Organizations",
                type: "int",
                nullable: true);

            migrationBuilder.CreateTable(
                name: "Projects",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    No = table.Column<int>(type: "int", nullable: false),
                    Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Description = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Status = table.Column<int>(type: "int", nullable: false),
                    CreationTimeStamp = table.Column<DateTime>(type: "datetime2", nullable: false),
                    ModificationTimeStamp = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Projects", x => x.Id);
                });

            migrationBuilder.CreateIndex(
                name: "IX_Organizations_ProjectId",
                table: "Organizations",
                column: "ProjectId");

            migrationBuilder.AddForeignKey(
                name: "FK_Organizations_Projects_ProjectId",
                table: "Organizations",
                column: "ProjectId",
                principalTable: "Projects",
                principalColumn: "Id");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Organizations_Projects_ProjectId",
                table: "Organizations");

            migrationBuilder.DropTable(
                name: "Projects");

            migrationBuilder.DropIndex(
                name: "IX_Organizations_ProjectId",
                table: "Organizations");

            migrationBuilder.DropColumn(
                name: "ProjectId",
                table: "Organizations");
        }
    }
}
