using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace JobTrackerApi.Migrations { /// public partial class AddCorrespondence : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { var mysql = ActiveProvider.Contains("MySql", StringComparison.OrdinalIgnoreCase); migrationBuilder.CreateTable( name: "Companies", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Name = table.Column(type: "TEXT", nullable: false), Location = table.Column(type: "TEXT", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Companies", x => x.Id); }); migrationBuilder.CreateTable( name: "JobApplications", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), CompanyId = table.Column(type: "INTEGER", nullable: false), JobTitle = table.Column(type: "TEXT", nullable: false), DateApplied = table.Column(type: "TEXT", nullable: false), Status = table.Column(type: "TEXT", nullable: false, defaultValue: "Applied"), ResponseReceived = table.Column(type: "INTEGER", nullable: false), ResponseDate = table.Column(type: "TEXT", nullable: true), Notes = table.Column(type: "TEXT", nullable: true), CoverLetterText = table.Column(type: "TEXT", nullable: true), JobUrl = table.Column(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(type: mysql ? "varchar(255)" : "TEXT", nullable: true), ShortSummary = table.Column(type: mysql ? "longtext" : "TEXT", nullable: true), TailoredCvText = table.Column(type: mysql ? "longtext" : "TEXT", nullable: true), TailoredCvUpdatedAt = table.Column(type: mysql ? "datetime(6)" : "TEXT", nullable: true), LastReminderEmailSentAt = table.Column(type: mysql ? "datetime(6)" : "TEXT", nullable: true), RecruiterMessageDraft = table.Column(type: mysql ? "longtext" : "TEXT", nullable: true), SalaryMin = table.Column(type: mysql ? "decimal(18,2)" : "TEXT", nullable: true), SalaryMax = table.Column(type: mysql ? "decimal(18,2)" : "TEXT", nullable: true), SalaryCurrency = table.Column(type: mysql ? "varchar(8)" : "TEXT", nullable: true), SalaryPeriod = table.Column(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(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), JobApplicationId = table.Column(type: "INTEGER", nullable: false), Date = table.Column(type: "TEXT", nullable: false), From = table.Column(type: "TEXT", nullable: false), Content = table.Column(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"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Correspondences"); migrationBuilder.DropTable( name: "JobApplications"); migrationBuilder.DropTable( name: "Companies"); } } }