using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace FakturyWeb.Migrations
{
    public partial class Init : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "UZIVATEL",
                columns: table => new
                {
                    ID = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    JMENO = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    PRIJMENI = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    ULICE = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    MESTO = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    PSC = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    IC = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    DIC = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    TELEFON = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    EMAIL = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    BANKA = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    WEB = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    FAKTURA_SPLATNOST = table.Column<int>(type: "int", nullable: false),
                    FAKTURA_MASKA = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    FAKTURA_CISLOVANI = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_UZIVATEL", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "ZAKAZNIK",
                columns: table => new
                {
                    ID = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    JMENO = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    PRIJMENI = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    ULICE = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    MESTO = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    PSC = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    IC = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    DIC = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    TELEFON = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    EMAIL = table.Column<string>(type: "nvarchar(max)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ZAKAZNIK", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "FAKTURA",
                columns: table => new
                {
                    ID = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    ZakaznikID = table.Column<int>(type: "int", nullable: false),
                    CISLO = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    CISLO_ABS = table.Column<int>(type: "int", nullable: false),
                    VYSTAVENI = table.Column<DateTime>(type: "datetime2", nullable: false),
                    SPLATNOST = table.Column<DateTime>(type: "datetime2", nullable: false),
                    D_PRAJM = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    D_ULICE = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    D_MESTO = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    D_PSC = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    D_IC = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    D_DIC = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    D_BANKA = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    D_TELEFON = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    D_EMAIL = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    D_WEB = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    O_PRAJM = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    O_ULICE = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    O_MESTO = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    O_PSC = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    O_IC = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    O_DIC = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    FORMA_UHRADY = table.Column<byte>(type: "tinyint", nullable: false),
                    CINNOSTI = table.Column<string>(type: "nvarchar(max)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_FAKTURA", x => x.ID);
                    table.ForeignKey(
                        name: "FK_FAKTURA_ZAKAZNIK_ZakaznikID",
                        column: x => x.ZakaznikID,
                        principalTable: "ZAKAZNIK",
                        principalColumn: "ID",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "PLATBA",
                columns: table => new
                {
                    ID = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    CASTKA = table.Column<decimal>(type: "money", nullable: false),
                    DATUM = table.Column<DateTime>(type: "datetime2", nullable: false),
                    POZNAMKA = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    FAKTURAID = table.Column<int>(type: "int", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_PLATBA", x => x.ID);
                    table.ForeignKey(
                        name: "FK_PLATBA_FAKTURA_FAKTURAID",
                        column: x => x.FAKTURAID,
                        principalTable: "FAKTURA",
                        principalColumn: "ID",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "POLOZKA",
                columns: table => new
                {
                    ID = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    NAZEV = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    POCET = table.Column<float>(type: "real", nullable: false),
                    CENA_JEDNOTKA = table.Column<decimal>(type: "money", nullable: false),
                    SLEVA = table.Column<float>(type: "real", nullable: false),
                    CENA = table.Column<decimal>(type: "money", nullable: false),
                    JEDNOTKA = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    FAKTURAID = table.Column<int>(type: "int", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_POLOZKA", x => x.ID);
                    table.ForeignKey(
                        name: "FK_POLOZKA_FAKTURA_FAKTURAID",
                        column: x => x.FAKTURAID,
                        principalTable: "FAKTURA",
                        principalColumn: "ID",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateIndex(
                name: "IX_FAKTURA_ZakaznikID",
                table: "FAKTURA",
                column: "ZakaznikID");

            migrationBuilder.CreateIndex(
                name: "IX_PLATBA_FAKTURAID",
                table: "PLATBA",
                column: "FAKTURAID");

            migrationBuilder.CreateIndex(
                name: "IX_POLOZKA_FAKTURAID",
                table: "POLOZKA",
                column: "FAKTURAID");
        }

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

            migrationBuilder.DropTable(
                name: "POLOZKA");

            migrationBuilder.DropTable(
                name: "UZIVATEL");

            migrationBuilder.DropTable(
                name: "FAKTURA");

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