﻿using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore.Migrations;

namespace kisvuz.Migrations
{
    public partial class init : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "HumanIdentityConformities",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("MySql:ValueGeneratedOnAdd", true),
                    HumanId = table.Column<long>(nullable: false),
                    IdentityId = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_HumanIdentityConformities", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Portfolios",
                columns: table => new
                {
                    PortfolioID = table.Column<long>(nullable: false)
                        .Annotation("MySql:ValueGeneratedOnAdd", true),
                    UserFIO = table.Column<string>(nullable: true),
                    UserInfo = table.Column<string>(nullable: true),
                    UserPhoto = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Portfolios", x => x.PortfolioID);
                });

            migrationBuilder.CreateTable(
                name: "CertificatesOfRegistrationSoftware",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("MySql:ValueGeneratedOnAdd", true),
                    Name = table.Column<string>(nullable: true),
                    Number = table.Column<string>(nullable: true),
                    Rightholder = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_CertificatesOfRegistrationSoftware", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Articles",
                columns: table => new
                {
                    ArticleID = table.Column<int>(nullable: false)
                        .Annotation("MySql:ValueGeneratedOnAdd", true),
                    Caption = table.Column<string>(nullable: true),
                    PortfolioID = table.Column<long>(nullable: false),
                    PublicationDate = table.Column<DateTime>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Articles", x => x.ArticleID);
                    table.ForeignKey(
                        name: "FK_Articles_Portfolios_PortfolioID",
                        column: x => x.PortfolioID,
                        principalTable: "Portfolios",
                        principalColumn: "PortfolioID",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "CertificateOfRegistrationSoftwareAuthors",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("MySql:ValueGeneratedOnAdd", true),
                    CertificateOfRegistrationSoftwareID = table.Column<long>(nullable: false),
                    HumanId = table.Column<long>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_CertificateOfRegistrationSoftwareAuthors", x => x.Id);
                    table.ForeignKey(
                        name: "FK_CertificateOfRegistrationSoftwareAuthors_CertificatesOfRegistrationSoftware_CertificateOfRegistrationSoftwareID",
                        column: x => x.CertificateOfRegistrationSoftwareID,
                        principalTable: "CertificatesOfRegistrationSoftware",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_Articles_PortfolioID",
                table: "Articles",
                column: "PortfolioID");

            migrationBuilder.CreateIndex(
                name: "IX_CertificateOfRegistrationSoftwareAuthors_CertificateOfRegistrationSoftwareID",
                table: "CertificateOfRegistrationSoftwareAuthors",
                column: "CertificateOfRegistrationSoftwareID");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "Articles");

            migrationBuilder.DropTable(
                name: "HumanIdentityConformities");

            migrationBuilder.DropTable(
                name: "CertificateOfRegistrationSoftwareAuthors");

            migrationBuilder.DropTable(
                name: "Portfolios");

            migrationBuilder.DropTable(
                name: "CertificatesOfRegistrationSoftware");
        }
    }
}
