From 2453e0f673102039b7f5e658d64e466f755853bd Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Sun, 15 Dec 2024 00:22:31 +0100 Subject: [PATCH] [backend/database] Normalize note text & user bio line endings --- .../20241214231301_NormalizeMfmLineEndings.cs | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Iceshrimp.Backend/Core/Database/Migrations/v2024.1-beta5/20241214231301_NormalizeMfmLineEndings.cs 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) + { + + } + } +}