55 lines
2.0 KiB
C#
55 lines
2.0 KiB
C#
using Backend.Data;
|
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace Backend.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
[DbContext(typeof(AwardsDbContext))]
|
|
[Migration("20260625110000_AddFooterPageContent")]
|
|
public partial class AddFooterPageContent : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
var imprintContent = SeedCatalog.DefaultImprintContent.Replace("'", "''");
|
|
var contactContent = SeedCatalog.DefaultContactContent.Replace("'", "''");
|
|
var sponsorsContent = SeedCatalog.DefaultSponsorsContent.Replace("'", "''");
|
|
|
|
migrationBuilder.Sql(
|
|
$"""
|
|
ALTER TABLE IF EXISTS "SiteSettings"
|
|
ADD COLUMN IF NOT EXISTS "ImprintContent" text NOT NULL DEFAULT '',
|
|
ADD COLUMN IF NOT EXISTS "ContactContent" text NOT NULL DEFAULT '',
|
|
ADD COLUMN IF NOT EXISTS "SponsorsContent" text NOT NULL DEFAULT '';
|
|
|
|
UPDATE "SiteSettings"
|
|
SET "ImprintContent" = '{imprintContent}'
|
|
WHERE "ImprintContent" IS NULL OR btrim("ImprintContent") = '';
|
|
|
|
UPDATE "SiteSettings"
|
|
SET "ContactContent" = '{contactContent}'
|
|
WHERE "ContactContent" IS NULL OR btrim("ContactContent") = '';
|
|
|
|
UPDATE "SiteSettings"
|
|
SET "SponsorsContent" = '{sponsorsContent}'
|
|
WHERE "SponsorsContent" IS NULL OR btrim("SponsorsContent") = '';
|
|
""");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.Sql(
|
|
"""
|
|
ALTER TABLE IF EXISTS "SiteSettings"
|
|
DROP COLUMN IF EXISTS "ImprintContent",
|
|
DROP COLUMN IF EXISTS "ContactContent",
|
|
DROP COLUMN IF EXISTS "SponsorsContent";
|
|
""");
|
|
}
|
|
}
|
|
}
|