namespace AutomatizovanySklad.Core.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class Migrace : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.Adresas",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Mesto = c.String(maxLength: 100),
                        Ulice = c.String(maxLength: 100),
                        Cislo = c.String(maxLength: 100),
                        PSC = c.String(maxLength: 5),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.DodaciLists",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        KodDodacihoListu = c.String(),
                        TypTransakce = c.Int(nullable: false),
                        DatumVytvoreni = c.DateTime(nullable: false),
                        VytvorilId = c.Int(nullable: false),
                        DatumUpravy = c.DateTime(),
                        UpravilId = c.Int(nullable: false),
                        JeAktivni = c.Boolean(nullable: false),
                        Subjekt_Id = c.Int(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Subjekts", t => t.Subjekt_Id)
                .Index(t => t.Subjekt_Id);
            
            CreateTable(
                "dbo.Produkts",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Kod = c.String(maxLength: 100),
                        Cena = c.Double(nullable: false),
                        Pocet = c.Int(nullable: false),
                        TypTransakce = c.Int(nullable: false),
                        DatumVytvoreni = c.DateTime(nullable: false),
                        VytvorilId = c.Int(nullable: false),
                        DatumUpravy = c.DateTime(),
                        UpravilId = c.Int(nullable: false),
                        Soubor_Id = c.Int(),
                        DodaciList_Id = c.Int(),
                        Karta_Id = c.Int(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Soubors", t => t.Soubor_Id)
                .ForeignKey("dbo.DodaciLists", t => t.DodaciList_Id)
                .ForeignKey("dbo.Kartas", t => t.Karta_Id)
                .Index(t => t.Soubor_Id)
                .Index(t => t.DodaciList_Id)
                .Index(t => t.Karta_Id);
            
            CreateTable(
                "dbo.Soubors",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        NazevSouboru = c.String(maxLength: 255),
                        TypSouboru = c.String(maxLength: 100),
                        Obsah = c.Binary(),
                        DodaciList_Id = c.Int(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.DodaciLists", t => t.DodaciList_Id)
                .Index(t => t.DodaciList_Id);
            
            CreateTable(
                "dbo.Subjekts",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Jmeno = c.String(maxLength: 100),
                        ICO = c.String(maxLength: 100),
                        DIC = c.String(maxLength: 100),
                        Poznamka = c.String(maxLength: 255),
                        TypSubjektu = c.Int(nullable: false),
                        DatumVytvoreni = c.DateTime(nullable: false),
                        VytvorilId = c.Int(nullable: false),
                        DatumUpravy = c.DateTime(),
                        UpravilId = c.Int(nullable: false),
                        JeAktivni = c.Boolean(nullable: false),
                        Adresa_Id = c.Int(),
                        Kontakt_Id = c.Int(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Adresas", t => t.Adresa_Id)
                .ForeignKey("dbo.Kontakts", t => t.Kontakt_Id)
                .Index(t => t.Adresa_Id)
                .Index(t => t.Kontakt_Id);
            
            CreateTable(
                "dbo.Kontakts",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Email = c.String(maxLength: 100),
                        Telefon = c.String(maxLength: 20),
                        Webovky = c.String(maxLength: 100),
                        TypKontaktu = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.Kartas",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Nazev = c.String(maxLength: 100),
                        Pocet = c.Int(nullable: false),
                        MaxPocet = c.Int(),
                        DatumVytvoreni = c.DateTime(nullable: false),
                        VytvorilId = c.Int(nullable: false),
                        DatumUpravy = c.DateTime(),
                        UpravilId = c.Int(nullable: false),
                        MernaJednotka = c.Int(nullable: false),
                        JeAktivni = c.Boolean(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.Zamestnanecs",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Jmeno = c.String(maxLength: 100),
                        Prijmeni = c.String(maxLength: 100),
                        Poznamka = c.String(maxLength: 255),
                        Email = c.String(maxLength: 100),
                        TypZamestnance = c.Int(nullable: false),
                        DatumVytvoreni = c.DateTime(nullable: false),
                        VytvorilId = c.Int(nullable: false),
                        DatumUpravy = c.DateTime(),
                        UpravilId = c.Int(nullable: false),
                        JeAktivni = c.Boolean(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.Produkts", "Karta_Id", "dbo.Kartas");
            DropForeignKey("dbo.DodaciLists", "Subjekt_Id", "dbo.Subjekts");
            DropForeignKey("dbo.Subjekts", "Kontakt_Id", "dbo.Kontakts");
            DropForeignKey("dbo.Subjekts", "Adresa_Id", "dbo.Adresas");
            DropForeignKey("dbo.Soubors", "DodaciList_Id", "dbo.DodaciLists");
            DropForeignKey("dbo.Produkts", "DodaciList_Id", "dbo.DodaciLists");
            DropForeignKey("dbo.Produkts", "Soubor_Id", "dbo.Soubors");
            DropIndex("dbo.Subjekts", new[] { "Kontakt_Id" });
            DropIndex("dbo.Subjekts", new[] { "Adresa_Id" });
            DropIndex("dbo.Soubors", new[] { "DodaciList_Id" });
            DropIndex("dbo.Produkts", new[] { "Karta_Id" });
            DropIndex("dbo.Produkts", new[] { "DodaciList_Id" });
            DropIndex("dbo.Produkts", new[] { "Soubor_Id" });
            DropIndex("dbo.DodaciLists", new[] { "Subjekt_Id" });
            DropTable("dbo.Zamestnanecs");
            DropTable("dbo.Kartas");
            DropTable("dbo.Kontakts");
            DropTable("dbo.Subjekts");
            DropTable("dbo.Soubors");
            DropTable("dbo.Produkts");
            DropTable("dbo.DodaciLists");
            DropTable("dbo.Adresas");
        }
    }
}
