using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace JobTrackerApi.Migrations
{
///
/// Phase 3: relational children of CareerProfile (Experience/Education/Skill/Project/
/// Certification/Language) + the LongTailJson column on CareerProfiles. See
/// docs/architecture/career-profile-model.md.
///
/// HAND-EDITED after scaffolding. `dotnet ef migrations add` also re-emitted CreateTable for
/// AiWorkspaceNotes / CareerProfiles / InterviewPrepNotes / CareerProfileVersions — all of which
/// already exist in every real database (provisioned by the F1/Phase-0 reconciler in
/// StartupInitializationExtensions, which the prior ModelSnapshot did not know). Those creates
/// were removed so the migration applies cleanly on existing databases; the regenerated
/// snapshot now includes them, closing the drift. Only the six genuinely-new child tables and
/// the new LongTailJson column remain here.
///
public partial class AddCareerProfileRelationalChildren : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
// New editable long-tail JSON on the existing CareerProfiles table.
migrationBuilder.AddColumn(
name: "LongTailJson",
table: "CareerProfiles",
type: "TEXT",
nullable: false,
defaultValue: "");
migrationBuilder.CreateTable(
name: "CareerCertifications",
columns: table => new
{
Id = table.Column(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column(type: "TEXT", nullable: true),
Issuer = table.Column(type: "TEXT", nullable: true),
Location = table.Column(type: "TEXT", nullable: true),
Date = table.Column(type: "TEXT", nullable: true),
DateNormalized = table.Column(type: "TEXT", nullable: true),
DetailsJson = table.Column(type: "TEXT", nullable: false),
CareerProfileId = table.Column(type: "INTEGER", nullable: false),
OwnerUserId = table.Column(type: "TEXT", nullable: false),
ItemKey = table.Column(type: "TEXT", nullable: false),
SortOrder = table.Column(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CareerCertifications", x => x.Id);
table.ForeignKey(
name: "FK_CareerCertifications_CareerProfiles_CareerProfileId",
column: x => x.CareerProfileId,
principalTable: "CareerProfiles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "CareerEducations",
columns: table => new
{
Id = table.Column(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Qualification = table.Column(type: "TEXT", nullable: true),
QualificationLevel = table.Column(type: "TEXT", nullable: true),
Institution = table.Column(type: "TEXT", nullable: true),
Location = table.Column(type: "TEXT", nullable: true),
Start = table.Column(type: "TEXT", nullable: true),
End = table.Column(type: "TEXT", nullable: true),
StartDate = table.Column(type: "TEXT", nullable: true),
EndDate = table.Column(type: "TEXT", nullable: true),
DetailsJson = table.Column(type: "TEXT", nullable: false),
CareerProfileId = table.Column(type: "INTEGER", nullable: false),
OwnerUserId = table.Column(type: "TEXT", nullable: false),
ItemKey = table.Column(type: "TEXT", nullable: false),
SortOrder = table.Column(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CareerEducations", x => x.Id);
table.ForeignKey(
name: "FK_CareerEducations_CareerProfiles_CareerProfileId",
column: x => x.CareerProfileId,
principalTable: "CareerProfiles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "CareerExperiences",
columns: table => new
{
Id = table.Column(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Title = table.Column(type: "TEXT", nullable: true),
Company = table.Column(type: "TEXT", nullable: true),
Location = table.Column(type: "TEXT", nullable: true),
Start = table.Column(type: "TEXT", nullable: true),
End = table.Column(type: "TEXT", nullable: true),
StartDate = table.Column(type: "TEXT", nullable: true),
EndDate = table.Column(type: "TEXT", nullable: true),
IsCurrent = table.Column(type: "INTEGER", nullable: false),
BulletsJson = table.Column(type: "TEXT", nullable: false),
SkillsJson = table.Column(type: "TEXT", nullable: false),
CareerProfileId = table.Column(type: "INTEGER", nullable: false),
OwnerUserId = table.Column(type: "TEXT", nullable: false),
ItemKey = table.Column(type: "TEXT", nullable: false),
SortOrder = table.Column(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CareerExperiences", x => x.Id);
table.ForeignKey(
name: "FK_CareerExperiences_CareerProfiles_CareerProfileId",
column: x => x.CareerProfileId,
principalTable: "CareerProfiles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "CareerLanguages",
columns: table => new
{
Id = table.Column(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column(type: "TEXT", nullable: true),
Level = table.Column(type: "TEXT", nullable: true),
Notes = table.Column(type: "TEXT", nullable: true),
CareerProfileId = table.Column(type: "INTEGER", nullable: false),
OwnerUserId = table.Column(type: "TEXT", nullable: false),
ItemKey = table.Column(type: "TEXT", nullable: false),
SortOrder = table.Column(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CareerLanguages", x => x.Id);
table.ForeignKey(
name: "FK_CareerLanguages_CareerProfiles_CareerProfileId",
column: x => x.CareerProfileId,
principalTable: "CareerProfiles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "CareerProjects",
columns: table => new
{
Id = table.Column(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column(type: "TEXT", nullable: true),
Role = table.Column(type: "TEXT", nullable: true),
Location = table.Column(type: "TEXT", nullable: true),
Start = table.Column(type: "TEXT", nullable: true),
End = table.Column(type: "TEXT", nullable: true),
StartDate = table.Column(type: "TEXT", nullable: true),
EndDate = table.Column(type: "TEXT", nullable: true),
BulletsJson = table.Column(type: "TEXT", nullable: false),
SkillsJson = table.Column(type: "TEXT", nullable: false),
LinksJson = table.Column(type: "TEXT", nullable: false),
CareerProfileId = table.Column(type: "INTEGER", nullable: false),
OwnerUserId = table.Column(type: "TEXT", nullable: false),
ItemKey = table.Column(type: "TEXT", nullable: false),
SortOrder = table.Column(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CareerProjects", x => x.Id);
table.ForeignKey(
name: "FK_CareerProjects_CareerProfiles_CareerProfileId",
column: x => x.CareerProfileId,
principalTable: "CareerProfiles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "CareerSkills",
columns: table => new
{
Id = table.Column(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column(type: "TEXT", nullable: true),
Category = table.Column(type: "TEXT", nullable: true),
Proficiency = table.Column(type: "TEXT", nullable: true),
CareerProfileId = table.Column(type: "INTEGER", nullable: false),
OwnerUserId = table.Column(type: "TEXT", nullable: false),
ItemKey = table.Column(type: "TEXT", nullable: false),
SortOrder = table.Column(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CareerSkills", x => x.Id);
table.ForeignKey(
name: "FK_CareerSkills_CareerProfiles_CareerProfileId",
column: x => x.CareerProfileId,
principalTable: "CareerProfiles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_CareerCertifications_CareerProfileId",
table: "CareerCertifications",
column: "CareerProfileId");
migrationBuilder.CreateIndex(
name: "IX_CareerCertifications_OwnerUserId_CareerProfileId_SortOrder",
table: "CareerCertifications",
columns: new[] { "OwnerUserId", "CareerProfileId", "SortOrder" });
migrationBuilder.CreateIndex(
name: "IX_CareerEducations_CareerProfileId",
table: "CareerEducations",
column: "CareerProfileId");
migrationBuilder.CreateIndex(
name: "IX_CareerEducations_OwnerUserId_CareerProfileId_SortOrder",
table: "CareerEducations",
columns: new[] { "OwnerUserId", "CareerProfileId", "SortOrder" });
migrationBuilder.CreateIndex(
name: "IX_CareerExperiences_CareerProfileId",
table: "CareerExperiences",
column: "CareerProfileId");
migrationBuilder.CreateIndex(
name: "IX_CareerExperiences_OwnerUserId_CareerProfileId_SortOrder",
table: "CareerExperiences",
columns: new[] { "OwnerUserId", "CareerProfileId", "SortOrder" });
migrationBuilder.CreateIndex(
name: "IX_CareerLanguages_CareerProfileId",
table: "CareerLanguages",
column: "CareerProfileId");
migrationBuilder.CreateIndex(
name: "IX_CareerLanguages_OwnerUserId_CareerProfileId_SortOrder",
table: "CareerLanguages",
columns: new[] { "OwnerUserId", "CareerProfileId", "SortOrder" });
migrationBuilder.CreateIndex(
name: "IX_CareerProjects_CareerProfileId",
table: "CareerProjects",
column: "CareerProfileId");
migrationBuilder.CreateIndex(
name: "IX_CareerProjects_OwnerUserId_CareerProfileId_SortOrder",
table: "CareerProjects",
columns: new[] { "OwnerUserId", "CareerProfileId", "SortOrder" });
migrationBuilder.CreateIndex(
name: "IX_CareerSkills_CareerProfileId",
table: "CareerSkills",
column: "CareerProfileId");
migrationBuilder.CreateIndex(
name: "IX_CareerSkills_OwnerUserId_CareerProfileId_SortOrder",
table: "CareerSkills",
columns: new[] { "OwnerUserId", "CareerProfileId", "SortOrder" });
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(name: "CareerCertifications");
migrationBuilder.DropTable(name: "CareerEducations");
migrationBuilder.DropTable(name: "CareerExperiences");
migrationBuilder.DropTable(name: "CareerLanguages");
migrationBuilder.DropTable(name: "CareerProjects");
migrationBuilder.DropTable(name: "CareerSkills");
migrationBuilder.DropColumn(
name: "LongTailJson",
table: "CareerProfiles");
}
}
}