namespace LeafWeb.Core.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class LeafInputData : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.LeafInputData",
                c => new
                    {
                        Id = c.Int(nullable: false),
                        InvestigatorName = c.String(),
                        ContactInformation = c.String(),
                        SiteName = c.String(),
                        VegetationType = c.String(),
                        SoilType = c.String(),
                        MajorSpecies = c.String(),
                        SampleLeafLightEnv = c.String(),
                        WaterStressAssessment = c.String(),
                        InstrumentUsed = c.String(),
                        ExtraInfo = c.String(),
                        LeafInput_Id = c.Int(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.LeafInput", t => t.LeafInput_Id)
                .ForeignKey("dbo.LeafOutputFile", t => t.Id)
                .Index(t => t.Id)
                .Index(t => t.LeafInput_Id);
            
            CreateTable(
                "dbo.LeafInputDataCurve",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        ListOrder = c.Int(nullable: false),
                        Obs = c.Double(),
                        HHMMSS = c.String(maxLength: 8),
                        FTime = c.Double(),
                        Photo = c.Double(),
                        AdjPhoto = c.Double(),
                        StomCond = c.Double(),
                        Ci = c.Double(),
                        Trmmol = c.Double(),
                        VpdL = c.Double(),
                        Area = c.Double(),
                        StmRat = c.Double(),
                        BLCond = c.Double(),
                        Tair = c.Double(),
                        Tleaf = c.Double(),
                        TBlk = c.Double(),
                        CO2R = c.Double(),
                        CO2S = c.Double(),
                        H2OR = c.Double(),
                        H2OS = c.Double(),
                        RH_R = c.Double(),
                        RH_S = c.Double(),
                        Flow = c.Double(),
                        PARi = c.Double(),
                        PARo = c.Double(),
                        Press = c.Double(),
                        CsMch = c.Double(),
                        HsMch = c.Double(),
                        StableF = c.Double(),
                        Status = c.String(),
                        PhiPS2 = c.Double(),
                        OxygenPress = c.Double(),
                        LeafInputData_Id = c.Int(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.LeafInputData", t => t.LeafInputData_Id)
                .Index(t => t.LeafInputData_Id);
            
            CreateTable(
                "dbo.LeafInputDataPhotosynthetic",
                c => new
                    {
                        Id = c.Int(nullable: false),
                        GammaStar = c.Double(nullable: false),
                        Kc = c.Double(nullable: false),
                        Ko = c.Double(nullable: false),
                        Alpha = c.Double(nullable: false),
                        Rd = c.Double(nullable: false),
                        gi = c.Double(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.LeafInputData", t => t.Id)
                .Index(t => t.Id);
            
            CreateTable(
                "dbo.LeafInputDataSite",
                c => new
                    {
                        Id = c.Int(nullable: false),
                        SiteId = c.String(),
                        Latitude = c.Double(),
                        Longitude = c.Double(),
                        Elevation = c.Double(),
                        SampleYear = c.Int(),
                        SampleDayOfYear = c.Int(),
                        GrowSeasonStart = c.Int(),
                        GrowSeasonEnd = c.Int(),
                        StandAge = c.Double(),
                        CanopyHeight = c.Double(),
                        LeafAreaIndex = c.Double(),
                        SpeciesSampled = c.String(),
                        AverageTimeResolution = c.Double(),
                        SampleHeight = c.Double(),
                        LeafAge = c.Int(),
                        SpecificLeafArea = c.Double(),
                        LfNitrogenContent = c.Double(),
                        LfCarbonContent = c.Double(),
                        LfPhosphContent = c.Double(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.LeafInputData", t => t.Id)
                .Index(t => t.Id);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.LeafInputDataSite", "Id", "dbo.LeafInputData");
            DropForeignKey("dbo.LeafInputDataPhotosynthetic", "Id", "dbo.LeafInputData");
            DropForeignKey("dbo.LeafInputData", "Id", "dbo.LeafOutputFile");
            DropForeignKey("dbo.LeafInputData", "LeafInput_Id", "dbo.LeafInput");
            DropForeignKey("dbo.LeafInputDataCurve", "LeafInputData_Id", "dbo.LeafInputData");
            DropIndex("dbo.LeafInputDataSite", new[] { "Id" });
            DropIndex("dbo.LeafInputDataPhotosynthetic", new[] { "Id" });
            DropIndex("dbo.LeafInputDataCurve", new[] { "LeafInputData_Id" });
            DropIndex("dbo.LeafInputData", new[] { "LeafInput_Id" });
            DropIndex("dbo.LeafInputData", new[] { "Id" });
            DropTable("dbo.LeafInputDataSite");
            DropTable("dbo.LeafInputDataPhotosynthetic");
            DropTable("dbo.LeafInputDataCurve");
            DropTable("dbo.LeafInputData");
        }
    }
}
