Files
server/util/MySqlMigrations/Migrations/20260508004721_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

63 lines
1.9 KiB
C#

using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Bit.MySqlMigrations.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: "longtext",
nullable: false,
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "Data",
table: "Send",
type: "longtext",
nullable: false,
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "Key",
table: "Send",
type: "longtext",
nullable: true,
oldClrType: typeof(string),
oldType: "longtext")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "Data",
table: "Send",
type: "longtext",
nullable: true,
oldClrType: typeof(string),
oldType: "longtext")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
}
}