Files
server/util/PostgresMigrations/Migrations/20260508004730_SendKeyAndDataNotNull.cs
John Harrington 455a3456c0 [PM-4128] Remove nullability of Send.Data and Send.Keys (#7266)
* Send.Key and Send.Data NOT NULL

* backfill EF providers with empty strings for NULL Data or Key values

* update migration names to match current date
2026-05-20 13:05:10 -07:00

55 lines
1.5 KiB
C#

using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Bit.PostgresMigrations.Migrations;
/// <inheritdoc />
public partial class SendKeyAndDataNotNull : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql("UPDATE \"Send\" SET \"Key\" = '' WHERE \"Key\" IS NULL;");
migrationBuilder.Sql("UPDATE \"Send\" SET \"Data\" = '' WHERE \"Data\" IS NULL;");
migrationBuilder.AlterColumn<string>(
name: "Key",
table: "Send",
type: "text",
nullable: false,
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Data",
table: "Send",
type: "text",
nullable: false,
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "Key",
table: "Send",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "Data",
table: "Send",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
}
}