using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace ZB.MOM.WW.ScadaBridge.ConfigurationDatabase.Migrations { /// /// SMS code-review (CentralUI-NNN / UI-Med-2): makes SmsConfigurations.FromNumber /// optional. A Twilio Messaging-Service-only config supplies a MessagingServiceSid instead /// of a From number; the design doc, the delivery adapter, and now the UI/CLI treat the two /// as either-or, so the column must allow NULL. /// /// ALTER COLUMN to NULL is naturally idempotent (re-running re-applies the same shape). /// public partial class SmsFromNumberOptional : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.Sql("ALTER TABLE [SmsConfigurations] ALTER COLUMN [FromNumber] nvarchar(32) NULL;"); } /// protected override void Down(MigrationBuilder migrationBuilder) { // Reversing to NOT NULL requires backfilling NULLs first. Unlike the recipient // EmailAddress backfill, '' is a harmless reversal here: a Messaging-Service-only // config keeps its MessagingServiceSid and stays deliverable, so no data is lost. migrationBuilder.Sql("UPDATE [SmsConfigurations] SET [FromNumber] = '' WHERE [FromNumber] IS NULL;"); migrationBuilder.Sql("ALTER TABLE [SmsConfigurations] ALTER COLUMN [FromNumber] nvarchar(32) NOT NULL;"); } } }