7c09f5a871
New JobProviderEntity persists provider config (name, URL template, link filter, initial keywords, max results, display order) in the DB instead of appsettings. Migration seeds three disabled defaults: ejobs.ro, bestjobs.eu, and linkedin.com. Closes #35 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
56 lines
2.8 KiB
C#
56 lines
2.8 KiB
C#
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace CvSearch.Data.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AddJobProviders : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "JobProviders",
|
|
schema: "cvSearch",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
Name = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
|
|
Enabled = table.Column<bool>(type: "bit", nullable: false),
|
|
SearchUrlTemplate = table.Column<string>(type: "nvarchar(1024)", maxLength: 1024, nullable: false),
|
|
JobLinkContains = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
|
|
InitialKeywordsJson = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: false, defaultValue: "[]"),
|
|
MaxResults = table.Column<int>(type: "int", nullable: false, defaultValue: 20),
|
|
DisplayOrder = table.Column<int>(type: "int", nullable: false, defaultValue: 0)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_JobProviders", x => x.Id);
|
|
});
|
|
|
|
// Seed the three default providers — all disabled so the feature is opt-in per environment.
|
|
// Enable a provider by setting its Enabled column to 1 via SQL or a future admin UI.
|
|
migrationBuilder.InsertData(
|
|
schema: "cvSearch",
|
|
table: "JobProviders",
|
|
columns: ["Name", "Enabled", "SearchUrlTemplate", "JobLinkContains", "InitialKeywordsJson", "MaxResults", "DisplayOrder"],
|
|
values: new object[,]
|
|
{
|
|
{ "ejobs.ro", false, "https://www.ejobs.ro/user/locuri-de-munca/?utm_source=myai&q={keywords}", "/user/locuri-de-munca/", "[]", 20, 0 },
|
|
{ "bestjobs.eu", false, "https://www.bestjobs.eu/ro/locuri-de-munca?keywords={keywords}", "/ro/locuri-de-munca/", "[]", 20, 1 },
|
|
{ "linkedin.com", false, "https://www.linkedin.com/jobs/search/?keywords={keywords}", "/jobs/view/", "[]", 20, 2 },
|
|
});
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "JobProviders",
|
|
schema: "cvSearch");
|
|
}
|
|
}
|
|
}
|