namespace MileageTraker.Web.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class ServiceReminder : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.ServiceReminder",
                c => new
                    {
                        ServiceReminderId = c.Int(nullable: false, identity: true),
                        TargetOdometer = c.Int(nullable: false),
                        Description = c.String(maxLength: 64),
                        Vehicle_VehicleId = c.String(nullable: false, maxLength: 6),
                    })
                .PrimaryKey(t => t.ServiceReminderId)
                .ForeignKey("dbo.Vehicle", t => t.Vehicle_VehicleId, cascadeDelete: true)
                .Index(t => t.Vehicle_VehicleId);

			Sql(@"INSERT INTO [Role]
				   ([RoleId]
				   ,[RoleName]
				   ,[Description])
				 VALUES
					   ('dd28bb32-afb6-4d54-bce6-04457bcf79d9'
					   ,'Vehicle Admin'
					   ,'Vehicle Administrator')");
			Sql(@"INSERT INTO [RoleUser]
				([User_UserId], [Role_RoleId])
				VALUES
				('A1720B63-5970-4313-9AC3-90B844FABD65',
				'dd28bb32-afb6-4d54-bce6-04457bcf79d9')");
        }

        public override void Down()
        {
            DropForeignKey("dbo.ServiceReminder", "Vehicle_VehicleId", "dbo.Vehicle");
            DropIndex("dbo.ServiceReminder", new[] { "Vehicle_VehicleId" });
            DropTable("dbo.ServiceReminder");

			Sql(@"DELETE FROM [Role]
					WHERE [RoleId] = 'dd28bb32-afb6-4d54-bce6-04457bcf79d9'");
			Sql(@"DELETE FROM [RoleUser]
					WHERE [Role_RoleId] = 'dd28bb32-afb6-4d54-bce6-04457bcf79d9'");
        }
    }
}
