namespace DataAccessLayer.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class Update2 : DbMigration
    {
        public override void Up()
        {
            DropForeignKey("dbo.TimeSheetRecords", "ProjectId", "dbo.Projects");
            DropIndex("dbo.TimeSheetRecords", new[] { "ProjectId" });
            AddColumn("dbo.TimeSheetRecords", "FromId", c => c.Int(nullable: false));
            AddColumn("dbo.TimeSheetRecords", "ToId", c => c.Int(nullable: false));
            AlterColumn("dbo.TimeSheetRecords", "ProjectId", c => c.Int());
            CreateIndex("dbo.TimeSheetRecords", "FromId");
            CreateIndex("dbo.TimeSheetRecords", "ToId");
            CreateIndex("dbo.TimeSheetRecords", "ProjectId");
            AddForeignKey("dbo.TimeSheetRecords", "FromId", "dbo.AttendanceRecords", "Id");
            AddForeignKey("dbo.TimeSheetRecords", "ToId", "dbo.AttendanceRecords", "Id");
            AddForeignKey("dbo.TimeSheetRecords", "ProjectId", "dbo.Projects", "Id");
            DropColumn("dbo.TimeSheetRecords", "From");
            DropColumn("dbo.TimeSheetRecords", "To");
        }
        
        public override void Down()
        {
            AddColumn("dbo.TimeSheetRecords", "To", c => c.DateTimeOffset(nullable: false, precision: 7));
            AddColumn("dbo.TimeSheetRecords", "From", c => c.DateTimeOffset(nullable: false, precision: 7));
            DropForeignKey("dbo.TimeSheetRecords", "ProjectId", "dbo.Projects");
            DropForeignKey("dbo.TimeSheetRecords", "ToId", "dbo.AttendanceRecords");
            DropForeignKey("dbo.TimeSheetRecords", "FromId", "dbo.AttendanceRecords");
            DropIndex("dbo.TimeSheetRecords", new[] { "ProjectId" });
            DropIndex("dbo.TimeSheetRecords", new[] { "ToId" });
            DropIndex("dbo.TimeSheetRecords", new[] { "FromId" });
            AlterColumn("dbo.TimeSheetRecords", "ProjectId", c => c.Int(nullable: false));
            DropColumn("dbo.TimeSheetRecords", "ToId");
            DropColumn("dbo.TimeSheetRecords", "FromId");
            CreateIndex("dbo.TimeSheetRecords", "ProjectId");
            AddForeignKey("dbo.TimeSheetRecords", "ProjectId", "dbo.Projects", "Id", cascadeDelete: true);
        }
    }
}
