namespace EgtBEAMWALL.DataLayer.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class FullDbInit : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.BTLPartList",
                c => new
                    {
                        DbId = c.Int(nullable: false, identity: true),
                        CalcState = c.Int(nullable: false),
                        CNT = c.Int(nullable: false),
                        DO = c.Boolean(nullable: false),
                        H = c.Double(nullable: false),
                        L = c.Double(nullable: false),
                        Material = c.String(unicode: false),
                        NAM = c.String(unicode: false),
                        Id = c.Int(nullable: false),
                        PDN = c.Int(nullable: false),
                        ProjDbId = c.Int(nullable: false),
                        W = c.Double(nullable: false),
                    })
                .PrimaryKey(t => t.DbId)
                .ForeignKey("dbo.ProjList", t => t.ProjDbId, cascadeDelete: true)
                .Index(t => t.ProjDbId);
            
            CreateTable(
                "dbo.ProjList",
                c => new
                    {
                        ProjDbId = c.Int(nullable: false, identity: true),
                        BTLFileName = c.String(unicode: false),
                        DtCreated = c.DateTime(nullable: false, precision: 0),
                        DtExported = c.DateTime(nullable: false, precision: 0),
                        IsNew = c.Boolean(nullable: false),
                        ListName = c.String(unicode: false),
                        Lock = c.Boolean(nullable: false),
                        ProdDbId = c.Int(),
                        Id = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.ProjDbId)
                .ForeignKey("dbo.ProdList", t => t.ProdDbId)
                .Index(t => t.ProdDbId);
            
            CreateTable(
                "dbo.ProdList",
                c => new
                    {
                        ProdDbId = c.Int(nullable: false, identity: true),
                        Description = c.String(unicode: false),
                        DtCreated = c.DateTime(nullable: false, precision: 0),
                        IsNew = c.Boolean(nullable: false),
                        Lock = c.Boolean(nullable: false),
                        Id = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.ProdDbId);
            
            CreateTable(
                "dbo.LogMachine",
                c => new
                    {
                        DbId = c.Int(nullable: false, identity: true),
                        CncFileName = c.String(unicode: false),
                        Description = c.String(unicode: false),
                        DtEvent = c.DateTime(nullable: false, precision: 0),
                        DtExported = c.DateTime(nullable: false, precision: 0),
                        EventType = c.Int(nullable: false),
                        MachineId = c.String(unicode: false),
                        Message = c.String(unicode: false),
                        SN = c.Int(nullable: false),
                        Value = c.Double(nullable: false),
                    })
                .PrimaryKey(t => t.DbId);
            
            CreateTable(
                "dbo.LogSupport",
                c => new
                    {
                        DbId = c.Int(nullable: false, identity: true),
                        DtEvent = c.DateTime(nullable: false, precision: 0),
                        Level = c.Int(nullable: false),
                        Message = c.String(unicode: false),
                        Target = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.DbId);
            
            CreateTable(
                "dbo.MachGroupList",
                c => new
                    {
                        DbId = c.Int(nullable: false, identity: true),
                        DtEnd = c.DateTime(nullable: false, precision: 0),
                        DtStart = c.DateTime(nullable: false, precision: 0),
                        H = c.Double(nullable: false),
                        L = c.Double(nullable: false),
                        Lock = c.Boolean(nullable: false),
                        LogRev = c.Int(nullable: false),
                        Id = c.Int(nullable: false),
                        Material = c.String(unicode: false),
                        Name = c.String(unicode: false),
                        Order = c.Int(nullable: false),
                        ProdDbId = c.Int(nullable: false),
                        State = c.Int(nullable: false),
                        SupervisorId = c.String(unicode: false),
                        W = c.Double(nullable: false),
                    })
                .PrimaryKey(t => t.DbId)
                .ForeignKey("dbo.ProdList", t => t.ProdDbId, cascadeDelete: true)
                .Index(t => t.ProdDbId);
            
            CreateTable(
                "dbo.PartList",
                c => new
                    {
                        DbId = c.Int(nullable: false, identity: true),
                        BTLPartDbId = c.Int(),
                        CalcState = c.Int(nullable: false),
                        DtEnd = c.DateTime(nullable: false, precision: 0),
                        DtStart = c.DateTime(nullable: false, precision: 0),
                        GRP = c.String(unicode: false),
                        H = c.Double(nullable: false),
                        L = c.Double(nullable: false),
                        MachGroupDbId = c.Int(),
                        Material = c.String(unicode: false),
                        NAM = c.String(unicode: false),
                        Id = c.Int(nullable: false),
                        PDN = c.Int(nullable: false),
                        ROT = c.Int(nullable: false),
                        State = c.Int(nullable: false),
                        W = c.Double(nullable: false),
                    })
                .PrimaryKey(t => t.DbId)
                .ForeignKey("dbo.BTLPartList", t => t.BTLPartDbId)
                .ForeignKey("dbo.MachGroupList", t => t.MachGroupDbId)
                .Index(t => t.BTLPartDbId)
                .Index(t => t.MachGroupDbId);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.PartList", "MachGroupDbId", "dbo.MachGroupList");
            DropForeignKey("dbo.PartList", "BTLPartDbId", "dbo.BTLPartList");
            DropForeignKey("dbo.MachGroupList", "ProdDbId", "dbo.ProdList");
            DropForeignKey("dbo.BTLPartList", "ProjDbId", "dbo.ProjList");
            DropForeignKey("dbo.ProjList", "ProdDbId", "dbo.ProdList");
            DropIndex("dbo.PartList", new[] { "MachGroupDbId" });
            DropIndex("dbo.PartList", new[] { "BTLPartDbId" });
            DropIndex("dbo.MachGroupList", new[] { "ProdDbId" });
            DropIndex("dbo.ProjList", new[] { "ProdDbId" });
            DropIndex("dbo.BTLPartList", new[] { "ProjDbId" });
            DropTable("dbo.PartList");
            DropTable("dbo.MachGroupList");
            DropTable("dbo.LogSupport");
            DropTable("dbo.LogMachine");
            DropTable("dbo.ProdList");
            DropTable("dbo.ProjList");
            DropTable("dbo.BTLPartList");
        }
    }
}
