I am working on a stored procedure that generates some tax data and stores that data into a separate table in the database. A while back I created an empty migration and added the following to the migration to add the stored procedure to the DB.
using Microsoft.EntityFrameworkCore.Migrations;
namespace Tax.Data.Migrations
{
public partial class sp_Generate5498TaxData : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
var sp = @"USE [TAX_DB]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE sp_GenerateTaxData
@Year int
AS
BEGIN
-- A bunch of SQL that is the stored procedure
END
GO";
migrationBuilder.Sql(sp);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}
Without thinking about it I added the migration without putting anything in the down method. Now, I need to alter the stored procedure and I am not sure how to do it so as to not cause other issues. My initial though was to remove the migration and add a new one but since the down method is empty would this cause any issues? Can I just write the following into the down method of the existing migration?
public override void Down()
{
this.Sql("DROP PROCEDURE sp_GenerateTaxData");
}
My other thought was to create a new migration and add in my SQL that instead says ALTER PROCEDURE sp_GenerateTaxData but again I am not sure what the side effects of this would be. I have looked around and cannot find information on how to best do this because of my mistake of not setting the down method initially. Any suggestions on how I can remote the existing migration or add a new one that will update the SP?