Files
jobtrackingapp/JobTrackerApi/Migrations/20261025090000_AddCoverLetterDocumentDesign.cs
T

36 lines
1.7 KiB
C#

using JobTrackerApi.Data;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace JobTrackerApi.Migrations;
[DbContext(typeof(JobTrackerContext))]
[Migration("20261025090000_AddCoverLetterDocumentDesign")]
public sealed class AddCoverLetterDocumentDesign : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
var text = ActiveProvider.Contains("MySql", StringComparison.OrdinalIgnoreCase) ? "longtext" : "TEXT";
migrationBuilder.AddColumn<string>(name: "CoverLetterDocumentSettingsJson", table: "JobApplications", type: text, nullable: true);
migrationBuilder.AddColumn<string>(name: "DocumentSettingsJson", table: "CoverLetterVersions", type: text, nullable: true);
migrationBuilder.AddColumn<string>(name: "CoverLetterDocumentSettingsJson", table: "SubmittedApplicationPackages", type: text, nullable: true);
migrationBuilder.AddColumn<string>(name: "RenderedCoverLetterHtml", table: "SubmittedApplicationPackages", type: text, nullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
foreach (var (table, column) in new[]
{
("JobApplications", "CoverLetterDocumentSettingsJson"), ("CoverLetterVersions", "DocumentSettingsJson"),
("SubmittedApplicationPackages", "CoverLetterDocumentSettingsJson"), ("SubmittedApplicationPackages", "RenderedCoverLetterHtml"),
})
{
if (ActiveProvider.Contains("Sqlite", StringComparison.OrdinalIgnoreCase))
migrationBuilder.Sql($"ALTER TABLE \"{table}\" DROP COLUMN \"{column}\";");
else migrationBuilder.DropColumn(name: column, table: table);
}
}
}