Files
myAi/Apis/email-data/Migrations/20260601133043_InitialSchema.cs
T
claude e3e088a365 WIP: Add automatic seeding to migrations (SQL not executing yet)
- Email migration includes seed data for 14 templates (en, ro)
- CV matcher migration includes seed data for 2 AI prompts (en, ro)
- Tables are created successfully by migrations
- Issue: migrationBuilder.Sql() statements not being executed by EF Core
- Workaround needed: Current seeding approach not working automatically

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-06-01 17:14:54 +03:00

63 lines
3.2 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Email.Data.Migrations
{
/// <inheritdoc />
public partial class InitialSchema : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.EnsureSchema(
name: "email");
migrationBuilder.CreateTable(
name: "Templates",
schema: "email",
columns: table => new
{
Key = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
Language = table.Column<string>(type: "nvarchar(8)", maxLength: 8, nullable: false),
Value = table.Column<string>(type: "nvarchar(max)", nullable: false),
Description = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: false, defaultValue: ""),
UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValueSql: "SYSUTCDATETIME()"),
OperatorCopy = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false, defaultValue: "")
},
constraints: table =>
{
table.PrimaryKey("PK_Templates", x => new { x.Key, x.Language });
});
// Seed email templates with a single comprehensive SQL batch
migrationBuilder.Sql(@"
INSERT INTO [email].Templates ([Key], [Language], [Value], [Description]) VALUES
('email.match.subject', 'en', 'MyAi.ro CV Match: {{score}}% - {{jobLabel}}', 'Subject for the CV match result email'),
('email.match.subject', 'ro', 'MyAi.ro Potrivire CV: {{score}}% - {{jobLabel}}', 'Subiect email rezultat potrivire CV'),
('email.search-results.subject', 'en', 'MyAi.ro: {{count}} jobs matching your CV', 'Subject for job search results email'),
('email.search-results.subject', 'ro', 'MyAi.ro: {{count}} joburi potrivite CV-ului tau', 'Subiect email rezultate cautare joburi'),
('html.job-search.started.title', 'en', 'Job search started', 'Title for job search started page'),
('html.job-search.started.title', 'ro', 'Căutare joburi pornită', 'Titlu pagina cautare joburi pornita'),
('html.job-search.already-used.title', 'en', 'Link already used', 'Title for already-used page'),
('html.job-search.already-used.title', 'ro', 'Link deja folosit', 'Titlu pagina link deja folosit'),
('html.job-search.expired.title', 'en', 'Link expired', 'Title for expired link page'),
('html.job-search.expired.title', 'ro', 'Link expirat', 'Titlu pagina link expirat'),
('html.job-search.invalid.title', 'en', 'Invalid link', 'Title for invalid link page'),
('html.job-search.invalid.title', 'ro', 'Link invalid', 'Titlu pagina link invalid'),
('html.job-search.error.title', 'en', 'Error', 'Title for error page'),
('html.job-search.error.title', 'ro', 'Eroare', 'Titlu pagina eroare');
");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Templates",
schema: "email");
}
}
}