namespace Vrh.iScheduler.Report.Lib.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class FirstMigration : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.SchedulerReportPackageGroups",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false, maxLength: 100),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.SchedulerReportPackages",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Name = c.String(maxLength: 200),
                        SchedulerReportPackageGroupId = c.Int(nullable: false),
                        Description = c.String(maxLength: 200),
                        RoleName = c.String(maxLength: 100),
                        Active = c.Boolean(nullable: false),
                        Mark = c.String(maxLength: 100),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.SchedulerReportPackageGroups", t => t.SchedulerReportPackageGroupId, cascadeDelete: true)
                .Index(t => t.SchedulerReportPackageGroupId);
            
            CreateTable(
                "dbo.SchedulerReportPackageItems",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        SchedulerReportPackageId = c.Int(nullable: false),
                        ReportId = c.String(maxLength: 50),
                        ExportType = c.String(maxLength: 30),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.SchedulerReportPackages", t => t.SchedulerReportPackageId, cascadeDelete: true)
                .Index(t => t.SchedulerReportPackageId);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.SchedulerReportPackageItems", "SchedulerReportPackageId", "dbo.SchedulerReportPackages");
            DropForeignKey("dbo.SchedulerReportPackages", "SchedulerReportPackageGroupId", "dbo.SchedulerReportPackageGroups");
            DropIndex("dbo.SchedulerReportPackageItems", new[] { "SchedulerReportPackageId" });
            DropIndex("dbo.SchedulerReportPackages", new[] { "SchedulerReportPackageGroupId" });
            DropTable("dbo.SchedulerReportPackageItems");
            DropTable("dbo.SchedulerReportPackages");
            DropTable("dbo.SchedulerReportPackageGroups");
        }
    }
}
