using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace GerbilManagerWebAPI.Migrations { /// public partial class AddSearchFields : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AddColumn( name: "NameSearch", table: "Gerbils", type: "text", nullable: true); migrationBuilder.AddColumn( name: "OriginBreeder", table: "Gerbils", type: "text", nullable: true); // Backfill NameSearch for existing rows (lowercase, strip whitespace/.-_), // matching GerbilSearch.Normalize. New/updated rows stay in sync via // ApplicationContext.SaveChanges. migrationBuilder.Sql( "UPDATE \"Gerbils\" SET \"NameSearch\" = lower(regexp_replace(\"Name\", '[[:space:]._-]', '', 'g'));"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropColumn( name: "NameSearch", table: "Gerbils"); migrationBuilder.DropColumn( name: "OriginBreeder", table: "Gerbils"); } } }