namespace Vrh.iScheduler.Report.Lib.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class Update02 : DbMigration
    {
        public override void Up()
        {
            DropIndex("dbo.SchedulerReportPackageItems", new[] { "SchedulerReportPackageId" });
            AddColumn("dbo.SchedulerReportPackageItems", "LCID", c => c.String(nullable: false, maxLength: 10));

            AddColumn("dbo.SchedulerReportPackages", "GroupId", c => c.String(nullable: false, maxLength: 100));
            Sql("update dbo.SchedulerReportPackages set GroupId = SchedulerReportPackageGroup");

            AlterColumn("dbo.SchedulerReportPackageItems", "ReportId", c => c.String(nullable: false, maxLength: 50));
            AlterColumn("dbo.SchedulerReportPackageItems", "ExportType", c => c.String(nullable: false, maxLength: 30));
            AlterColumn("dbo.SchedulerReportPackages", "Name", c => c.String(nullable: false, maxLength: 100));
            AlterColumn("dbo.SchedulerReportPackages", "Description", c => c.String(nullable: false, maxLength: 200));
            CreateIndex("dbo.SchedulerReportPackageItems", new[] { "SchedulerReportPackageId", "ReportId", "LCID" }, unique: true, name: "IX_SchedulerReportPackageItems_SchedulerReportPackageId_ReportId_LCID");
            CreateIndex("dbo.SchedulerReportPackages", new[] { "Name", "GroupId" }, unique: true, name: "IX_SchedulerReportPackages_NameGroup");
            DropColumn("dbo.SchedulerReportPackages", "SchedulerReportPackageGroup");
        }
        
        public override void Down()
        {
            AddColumn("dbo.SchedulerReportPackages", "SchedulerReportPackageGroup", c => c.String());
            DropIndex("dbo.SchedulerReportPackages", "IX_SchedulerReportPackages_NameGroup");
            DropIndex("dbo.SchedulerReportPackageItems", "IX_SchedulerReportPackageItems_SchedulerReportPackageId_ReportId_LCID");
            AlterColumn("dbo.SchedulerReportPackages", "Description", c => c.String(maxLength: 200));
            AlterColumn("dbo.SchedulerReportPackages", "Name", c => c.String(maxLength: 200));
            AlterColumn("dbo.SchedulerReportPackageItems", "ExportType", c => c.String(maxLength: 30));
            AlterColumn("dbo.SchedulerReportPackageItems", "ReportId", c => c.String(maxLength: 50));
            DropColumn("dbo.SchedulerReportPackages", "GroupId");
            DropColumn("dbo.SchedulerReportPackageItems", "LCID");
            CreateIndex("dbo.SchedulerReportPackageItems", "SchedulerReportPackageId");
        }
    }
}
