diff --git a/Iceshrimp.Backend/Core/Database/Migrations/v2024.1-beta5/20241214231301_NormalizeMfmLineEndings.cs b/Iceshrimp.Backend/Core/Database/Migrations/v2024.1-beta5/20241214231301_NormalizeMfmLineEndings.cs new file mode 100644 index 00000000..8df4cfb1 --- /dev/null +++ b/Iceshrimp.Backend/Core/Database/Migrations/v2024.1-beta5/20241214231301_NormalizeMfmLineEndings.cs @@ -0,0 +1,30 @@ +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Infrastructure; + +#nullable disable + +namespace Iceshrimp.Backend.Core.Database.Migrations +{ + /// + [DbContext(typeof(DatabaseContext))] + [Migration("20241214231301_NormalizeMfmLineEndings")] + public partial class NormalizeMfmLineEndings : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.Sql(""" + UPDATE "note" SET "text" = regexp_replace("text", '\r\n', '\n', 'g') WHERE "text" ~ '\r\n'; + UPDATE "note" SET "text" = regexp_replace("text", '\r', '\n', 'g') WHERE "text" ~ '\r'; + UPDATE "user_profile" SET "description" = regexp_replace("description", '\r\n', '\n', 'g') WHERE "description" ~ '\r\n'; + UPDATE "user_profile" SET "description" = regexp_replace("description", '\r', '\n', 'g') WHERE "description" ~ '\r'; + """); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +}