Files
jobtrackingapp/JobTrackerApi/Migrations/20260310174114_AddCorrespondence.cs
T
cesnimda 74a1e0d845
CI and Deploy / test (pull_request) Successful in 5m19s
CI and Deploy / deploy (pull_request) Has been skipped
fix(db): repair fresh migration chain
2026-08-15 20:47:36 +02:00

116 lines
5.8 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace JobTrackerApi.Migrations
{
/// <inheritdoc />
public partial class AddCorrespondence : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
var mysql = ActiveProvider.Contains("MySql", StringComparison.OrdinalIgnoreCase);
migrationBuilder.CreateTable(
name: "Companies",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: false),
Location = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Companies", x => x.Id);
});
migrationBuilder.CreateTable(
name: "JobApplications",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
CompanyId = table.Column<int>(type: "INTEGER", nullable: false),
JobTitle = table.Column<string>(type: "TEXT", nullable: false),
DateApplied = table.Column<DateTime>(type: "TEXT", nullable: false),
Status = table.Column<string>(type: "TEXT", nullable: false, defaultValue: "Applied"),
ResponseReceived = table.Column<bool>(type: "INTEGER", nullable: false),
ResponseDate = table.Column<DateTime>(type: "TEXT", nullable: true),
Notes = table.Column<string>(type: "TEXT", nullable: true),
CoverLetterText = table.Column<string>(type: "TEXT", nullable: true),
JobUrl = table.Column<string>(type: "TEXT", nullable: true),
// These stable columns predated EF ownership and were historically supplied by
// startup reconciliation. Include them for new databases so the later SQLite
// DateApplied rebuild has a complete source shape under standalone EF tooling.
OwnerUserId = table.Column<string>(type: mysql ? "varchar(255)" : "TEXT", nullable: true),
ShortSummary = table.Column<string>(type: mysql ? "longtext" : "TEXT", nullable: true),
TailoredCvText = table.Column<string>(type: mysql ? "longtext" : "TEXT", nullable: true),
TailoredCvUpdatedAt = table.Column<DateTime>(type: mysql ? "datetime(6)" : "TEXT", nullable: true),
LastReminderEmailSentAt = table.Column<DateTime>(type: mysql ? "datetime(6)" : "TEXT", nullable: true),
RecruiterMessageDraft = table.Column<string>(type: mysql ? "longtext" : "TEXT", nullable: true),
SalaryMin = table.Column<decimal>(type: mysql ? "decimal(18,2)" : "TEXT", nullable: true),
SalaryMax = table.Column<decimal>(type: mysql ? "decimal(18,2)" : "TEXT", nullable: true),
SalaryCurrency = table.Column<string>(type: mysql ? "varchar(8)" : "TEXT", nullable: true),
SalaryPeriod = table.Column<string>(type: mysql ? "varchar(16)" : "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_JobApplications", x => x.Id);
table.ForeignKey(
name: "FK_JobApplications_Companies_CompanyId",
column: x => x.CompanyId,
principalTable: "Companies",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Correspondences",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
JobApplicationId = table.Column<int>(type: "INTEGER", nullable: false),
Date = table.Column<DateTime>(type: "TEXT", nullable: false),
From = table.Column<string>(type: "TEXT", nullable: false),
Content = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Correspondences", x => x.Id);
table.ForeignKey(
name: "FK_Correspondences_JobApplications_JobApplicationId",
column: x => x.JobApplicationId,
principalTable: "JobApplications",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Correspondences_JobApplicationId",
table: "Correspondences",
column: "JobApplicationId");
migrationBuilder.CreateIndex(
name: "IX_JobApplications_CompanyId",
table: "JobApplications",
column: "CompanyId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Correspondences");
migrationBuilder.DropTable(
name: "JobApplications");
migrationBuilder.DropTable(
name: "Companies");
}
}
}