[backend/database] Normalize note text & user bio line endings

This commit is contained in:
Laura Hausmann 2024-12-15 00:22:31 +01:00
parent 9865f3dde7
commit 2453e0f673
No known key found for this signature in database
GPG key ID: D044E84C5BE01605

View file

@ -0,0 +1,30 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Infrastructure;
#nullable disable
namespace Iceshrimp.Backend.Core.Database.Migrations
{
/// <inheritdoc />
[DbContext(typeof(DatabaseContext))]
[Migration("20241214231301_NormalizeMfmLineEndings")]
public partial class NormalizeMfmLineEndings : Migration
{
/// <inheritdoc />
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';
""");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}