Move RAG repository from rag-api to rag-data — consolidate data layer ownership

- Move IRagRepository, EfRagRepository, and VectorSerializer from rag-api/Data to rag-data/Repositories
- Add rag-api-models ProjectReference to rag-data.csproj for model type availability
- Delete rag-api/Data folder (no longer needed; all data access is now in rag-data)
- This aligns RAG with email-api and other services: all data code in the data project

Pattern: rag-api (API logic) → rag-data (repository, EF entities, migrations)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-05-29 09:38:25 +03:00
parent 36759d8fee
commit 487924e345
25 changed files with 125 additions and 57 deletions
+2 -2
View File
@@ -5,8 +5,8 @@ namespace CvMatcher.Data;
public sealed class CvMatcherDbContext : DbContext public sealed class CvMatcherDbContext : DbContext
{ {
public const string SchemaName = "cvMatcher"; public const string SchemaName = MigrationConstants.SchemaName;
public const string MigrationTableName = "_Migrations"; public const string MigrationTableName = MigrationConstants.MigrationTableName;
public CvMatcherDbContext(DbContextOptions<CvMatcherDbContext> options) : base(options) public CvMatcherDbContext(DbContextOptions<CvMatcherDbContext> options) : base(options)
{ {
@@ -0,0 +1,11 @@
namespace CvMatcher.Data;
/// <summary>
/// Schema constants used by CvMatcherDbContext and migrations.
/// Centralized to avoid hardcoded strings and ensure consistency.
/// </summary>
public static class MigrationConstants
{
public const string SchemaName = "cvMatcher";
public const string MigrationTableName = "_Migrations";
}
@@ -1,5 +1,6 @@
using System; using System;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using CvMatcher.Data;
#nullable disable #nullable disable
@@ -12,11 +13,11 @@ namespace CvMatcher.Data.Migrations
protected override void Up(MigrationBuilder migrationBuilder) protected override void Up(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.EnsureSchema( migrationBuilder.EnsureSchema(
name: "cvMatcher"); name: MigrationConstants.SchemaName);
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "ChatCache", name: "ChatCache",
schema: "cvMatcher", schema: MigrationConstants.SchemaName,
columns: table => new columns: table => new
{ {
CacheKey = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false), CacheKey = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
@@ -32,7 +33,7 @@ namespace CvMatcher.Data.Migrations
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "Results", name: "Results",
schema: "cvMatcher", schema: MigrationConstants.SchemaName,
columns: table => new columns: table => new
{ {
Id = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false), Id = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
@@ -49,7 +50,7 @@ namespace CvMatcher.Data.Migrations
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_Results_CvDocumentId_JobDocumentId", name: "IX_Results_CvDocumentId_JobDocumentId",
schema: "cvMatcher", schema: MigrationConstants.SchemaName,
table: "Results", table: "Results",
columns: new[] { "CvDocumentId", "JobDocumentId" }, columns: new[] { "CvDocumentId", "JobDocumentId" },
unique: true); unique: true);
@@ -60,11 +61,11 @@ namespace CvMatcher.Data.Migrations
{ {
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "ChatCache", name: "ChatCache",
schema: "cvMatcher"); schema: MigrationConstants.SchemaName);
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Results", name: "Results",
schema: "cvMatcher"); schema: MigrationConstants.SchemaName);
} }
} }
} }
@@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using CvMatcher.Data;
#nullable disable #nullable disable
@@ -12,7 +13,7 @@ namespace CvMatcher.Data.Migrations
{ {
migrationBuilder.AddColumn<string>( migrationBuilder.AddColumn<string>(
name: "Language", name: "Language",
schema: "cvMatcher", schema: MigrationConstants.SchemaName,
table: "Results", table: "Results",
type: "nvarchar(max)", type: "nvarchar(max)",
nullable: false, nullable: false,
@@ -24,7 +25,7 @@ namespace CvMatcher.Data.Migrations
{ {
migrationBuilder.DropColumn( migrationBuilder.DropColumn(
name: "Language", name: "Language",
schema: "cvMatcher", schema: MigrationConstants.SchemaName,
table: "Results"); table: "Results");
} }
} }
@@ -1,5 +1,6 @@
using System; using System;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using CvMatcher.Data;
#nullable disable #nullable disable
@@ -13,7 +14,7 @@ namespace CvMatcher.Data.Migrations
{ {
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "AiPrompts", name: "AiPrompts",
schema: "cvMatcher", schema: MigrationConstants.SchemaName,
columns: table => new columns: table => new
{ {
Key = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false), Key = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
@@ -28,7 +29,7 @@ namespace CvMatcher.Data.Migrations
}); });
migrationBuilder.InsertData( migrationBuilder.InsertData(
schema: "cvMatcher", schema: MigrationConstants.SchemaName,
table: "AiPrompts", table: "AiPrompts",
columns: ["Key", "Language", "Value", "Description"], columns: ["Key", "Language", "Value", "Description"],
values: new object[] values: new object[]
@@ -43,7 +44,7 @@ namespace CvMatcher.Data.Migrations
/// <inheritdoc /> /// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder) protected override void Down(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.DropTable(name: "AiPrompts", schema: "cvMatcher"); migrationBuilder.DropTable(name: "AiPrompts", schema: MigrationConstants.SchemaName);
} }
} }
} }
@@ -5,8 +5,8 @@ namespace CvSearch.Data;
public sealed class CvSearchDbContext : DbContext public sealed class CvSearchDbContext : DbContext
{ {
public const string SchemaName = "cvSearch"; public const string SchemaName = MigrationConstants.SchemaName;
public const string MigrationTableName = "_Migrations"; public const string MigrationTableName = MigrationConstants.MigrationTableName;
public CvSearchDbContext(DbContextOptions<CvSearchDbContext> options) : base(options) { } public CvSearchDbContext(DbContextOptions<CvSearchDbContext> options) : base(options) { }
@@ -0,0 +1,11 @@
namespace CvSearch.Data;
/// <summary>
/// Schema constants used by CvSearchDbContext and migrations.
/// Centralized to avoid hardcoded strings and ensure consistency.
/// </summary>
public static class MigrationConstants
{
public const string SchemaName = "cvSearch";
public const string MigrationTableName = "_Migrations";
}
@@ -1,5 +1,6 @@
using System; using System;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using CvSearch.Data;
#nullable disable #nullable disable
@@ -12,11 +13,11 @@ namespace CvSearch.Data.Migrations
protected override void Up(MigrationBuilder migrationBuilder) protected override void Up(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.EnsureSchema( migrationBuilder.EnsureSchema(
name: "cvSearch"); name: MigrationConstants.SchemaName);
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "JobSearchResults", name: "JobSearchResults",
schema: "cvSearch", schema: MigrationConstants.SchemaName,
columns: table => new columns: table => new
{ {
Id = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false), Id = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
@@ -36,7 +37,7 @@ namespace CvSearch.Data.Migrations
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "JobSearchSessions", name: "JobSearchSessions",
schema: "cvSearch", schema: MigrationConstants.SchemaName,
columns: table => new columns: table => new
{ {
Id = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false), Id = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
@@ -55,7 +56,7 @@ namespace CvSearch.Data.Migrations
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "JobSearchTokens", name: "JobSearchTokens",
schema: "cvSearch", schema: MigrationConstants.SchemaName,
columns: table => new columns: table => new
{ {
Id = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false), Id = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
@@ -88,15 +89,15 @@ namespace CvSearch.Data.Migrations
{ {
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "JobSearchResults", name: "JobSearchResults",
schema: "cvSearch"); schema: MigrationConstants.SchemaName);
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "JobSearchSessions", name: "JobSearchSessions",
schema: "cvSearch"); schema: MigrationConstants.SchemaName);
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "JobSearchTokens", name: "JobSearchTokens",
schema: "cvSearch"); schema: MigrationConstants.SchemaName);
} }
} }
} }
@@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using CvSearch.Data;
#nullable disable #nullable disable
@@ -12,7 +13,7 @@ namespace CvSearch.Data.Migrations
{ {
migrationBuilder.AddColumn<string>( migrationBuilder.AddColumn<string>(
name: "Language", name: "Language",
schema: "cvSearch", schema: MigrationConstants.SchemaName,
table: "JobSearchTokens", table: "JobSearchTokens",
type: "nvarchar(8)", type: "nvarchar(8)",
maxLength: 8, maxLength: 8,
@@ -21,7 +22,7 @@ namespace CvSearch.Data.Migrations
migrationBuilder.AddColumn<string>( migrationBuilder.AddColumn<string>(
name: "Language", name: "Language",
schema: "cvSearch", schema: MigrationConstants.SchemaName,
table: "JobSearchSessions", table: "JobSearchSessions",
type: "nvarchar(8)", type: "nvarchar(8)",
maxLength: 8, maxLength: 8,
@@ -34,12 +35,12 @@ namespace CvSearch.Data.Migrations
{ {
migrationBuilder.DropColumn( migrationBuilder.DropColumn(
name: "Language", name: "Language",
schema: "cvSearch", schema: MigrationConstants.SchemaName,
table: "JobSearchTokens"); table: "JobSearchTokens");
migrationBuilder.DropColumn( migrationBuilder.DropColumn(
name: "Language", name: "Language",
schema: "cvSearch", schema: MigrationConstants.SchemaName,
table: "JobSearchSessions"); table: "JobSearchSessions");
} }
} }
+2 -2
View File
@@ -5,8 +5,8 @@ namespace EmailApi.Data;
public sealed class EmailApiDbContext : DbContext public sealed class EmailApiDbContext : DbContext
{ {
public const string SchemaName = "emailApi"; public const string SchemaName = MigrationConstants.SchemaName;
public const string MigrationTableName = "_Migrations"; public const string MigrationTableName = MigrationConstants.MigrationTableName;
public EmailApiDbContext(DbContextOptions<EmailApiDbContext> options) : base(options) { } public EmailApiDbContext(DbContextOptions<EmailApiDbContext> options) : base(options) { }
+11
View File
@@ -0,0 +1,11 @@
namespace EmailApi.Data;
/// <summary>
/// Schema constants used by EmailApiDbContext and migrations.
/// Centralized to avoid hardcoded strings and ensure consistency.
/// </summary>
public static class MigrationConstants
{
public const string SchemaName = "emailApi";
public const string MigrationTableName = "_Migrations";
}
@@ -1,5 +1,6 @@
using System; using System;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using EmailApi.Data;
#nullable disable #nullable disable
@@ -11,11 +12,11 @@ namespace EmailApi.Data.Migrations
/// <inheritdoc /> /// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder) protected override void Up(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.EnsureSchema(name: "emailApi"); migrationBuilder.EnsureSchema(name: MigrationConstants.SchemaName);
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "EmailTemplates", name: "EmailTemplates",
schema: "emailApi", schema: MigrationConstants.SchemaName,
columns: table => new columns: table => new
{ {
Key = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false), Key = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
@@ -39,7 +40,7 @@ namespace EmailApi.Data.Migrations
=> m.InsertData("EmailTemplates", => m.InsertData("EmailTemplates",
["Key", "Language", "Value", "Description", "OperatorCopy"], ["Key", "Language", "Value", "Description", "OperatorCopy"],
[key, lang, value, description, operatorCopy], [key, lang, value, description, operatorCopy],
"emailApi"); MigrationConstants.SchemaName);
// ── HTML shell (no operator copy — these are layout fragments, not addressable emails) ── // ── HTML shell (no operator copy — these are layout fragments, not addressable emails) ──
Row("email.html-shell.start", "*", Row("email.html-shell.start", "*",
@@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using EmailApi.Data;
#nullable disable #nullable disable
@@ -31,7 +32,7 @@ namespace EmailApi.Data.Migrations
=> m.InsertData("EmailTemplates", => m.InsertData("EmailTemplates",
["Key", "Language", "Value", "Description", "OperatorCopy"], ["Key", "Language", "Value", "Description", "OperatorCopy"],
[key, lang, value, description, operatorCopy], [key, lang, value, description, operatorCopy],
"emailApi"); MigrationConstants.SchemaName);
// ── HTML shell (no operator copy — these are layout fragments, not addressable emails) ── // ── HTML shell (no operator copy — these are layout fragments, not addressable emails) ──
Row("email.html-shell.start", "*", Row("email.html-shell.start", "*",
+11
View File
@@ -0,0 +1,11 @@
namespace MyAi.Data;
/// <summary>
/// Schema constants used by MyAiDbContext and migrations.
/// Centralized to avoid hardcoded strings and ensure consistency.
/// </summary>
public static class MigrationConstants
{
public const string SchemaName = "myAi";
public const string MigrationTableName = "_Migrations";
}
+2 -2
View File
@@ -5,8 +5,8 @@ namespace MyAi.Data;
public sealed class MyAiDbContext : DbContext public sealed class MyAiDbContext : DbContext
{ {
public const string SchemaName = "myAi"; public const string SchemaName = MigrationConstants.SchemaName;
public const string MigrationTableName = "_Migrations"; public const string MigrationTableName = MigrationConstants.MigrationTableName;
public MyAiDbContext(DbContextOptions<MyAiDbContext> options) : base(options) { } public MyAiDbContext(DbContextOptions<MyAiDbContext> options) : base(options) { }
@@ -1,5 +1,6 @@
using System; using System;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using MyAi.Data;
#nullable disable #nullable disable
@@ -12,11 +13,11 @@ namespace MyAi.Data.Migrations
protected override void Up(MigrationBuilder migrationBuilder) protected override void Up(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.EnsureSchema( migrationBuilder.EnsureSchema(
name: "myAi"); name: MigrationConstants.SchemaName);
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "Templates", name: "Templates",
schema: "myAi", schema: MigrationConstants.SchemaName,
columns: table => new columns: table => new
{ {
Key = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false), Key = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
@@ -36,7 +37,7 @@ namespace MyAi.Data.Migrations
private static void Seed(MigrationBuilder m) private static void Seed(MigrationBuilder m)
{ {
void Row(string key, string lang, string value, string description = "") void Row(string key, string lang, string value, string description = "")
=> m.InsertData("Templates", ["Key", "Language", "Value", "Description"], [key, lang, value, description], "myAi"); => m.InsertData("Templates", ["Key", "Language", "Value", "Description"], [key, lang, value, description], MigrationConstants.SchemaName);
// Match result email — subject // Match result email — subject
Row("email.match.subject", "en", "MyAi.ro CV Match: {{score}}% - {{jobLabel}}", "Subject for the CV match result email"); Row("email.match.subject", "en", "MyAi.ro CV Match: {{score}}% - {{jobLabel}}", "Subject for the CV match result email");
@@ -107,7 +108,7 @@ namespace MyAi.Data.Migrations
{ {
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Templates", name: "Templates",
schema: "myAi"); schema: MigrationConstants.SchemaName);
} }
} }
} }
@@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using MyAi.Data;
#nullable disable #nullable disable
@@ -12,7 +13,7 @@ namespace MyAi.Data.Migrations
{ {
void Update(string key, string lang, string value) void Update(string key, string lang, string value)
=> migrationBuilder.UpdateData("Templates", ["Key", "Language"], [key, lang], => migrationBuilder.UpdateData("Templates", ["Key", "Language"], [key, lang],
["Value"], [value], "myAi"); ["Value"], [value], MigrationConstants.SchemaName);
// email.match.body — en // email.match.body — en
Update("email.match.body", "en", Update("email.match.body", "en",
@@ -120,7 +121,7 @@ namespace MyAi.Data.Migrations
{ {
void Update(string key, string lang, string value) void Update(string key, string lang, string value)
=> migrationBuilder.UpdateData("Templates", ["Key", "Language"], [key, lang], => migrationBuilder.UpdateData("Templates", ["Key", "Language"], [key, lang],
["Value"], [value], "myAi"); ["Value"], [value], MigrationConstants.SchemaName);
Update("email.match.body", "en", Update("email.match.body", "en",
"CV Matcher result\n\nCV Document ID: {{cvDocumentId}}\nJob: {{jobLabel}}\nJob URL: {{jobUrl}}\nScore: {{score}}%\n\nSummary:\n{{summary}}\n\nStrengths:\n{{strengths}}\n\nGaps:\n{{gaps}}\n\nRecommendations:\n{{recommendations}}"); "CV Matcher result\n\nCV Document ID: {{cvDocumentId}}\nJob: {{jobLabel}}\nJob URL: {{jobUrl}}\nScore: {{score}}%\n\nSummary:\n{{summary}}\n\nStrengths:\n{{strengths}}\n\nGaps:\n{{gaps}}\n\nRecommendations:\n{{recommendations}}");
@@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using MyAi.Data;
#nullable disable #nullable disable
@@ -10,8 +11,8 @@ namespace MyAi.Data.Migrations
/// <inheritdoc /> /// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder) protected override void Up(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.Sql("DELETE FROM [myAi].[Templates] WHERE [Key] LIKE 'email.%'"); migrationBuilder.Sql($"DELETE FROM [{MigrationConstants.SchemaName}].[Templates] WHERE [Key] LIKE 'email.%'");
migrationBuilder.Sql("DELETE FROM [myAi].[Templates] WHERE [Key] LIKE 'ai.%'"); migrationBuilder.Sql($"DELETE FROM [{MigrationConstants.SchemaName}].[Templates] WHERE [Key] LIKE 'ai.%'");
} }
/// <inheritdoc /> /// <inheritdoc />
+11
View File
@@ -0,0 +1,11 @@
namespace Rag.Data;
/// <summary>
/// Schema constants used by RagDbContext and migrations.
/// Centralized to avoid hardcoded strings and ensure consistency.
/// </summary>
public static class MigrationConstants
{
public const string SchemaName = "rag";
public const string MigrationTableName = "_Migrations";
}
@@ -1,5 +1,6 @@
using System; using System;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Rag.Data;
#nullable disable #nullable disable
@@ -12,11 +13,11 @@ namespace Rag.Data.Migrations
protected override void Up(MigrationBuilder migrationBuilder) protected override void Up(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.EnsureSchema( migrationBuilder.EnsureSchema(
name: "rag"); name: MigrationConstants.SchemaName);
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "ChatCompletionCache", name: "ChatCompletionCache",
schema: "rag", schema: MigrationConstants.SchemaName,
columns: table => new columns: table => new
{ {
CacheKey = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false), CacheKey = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
@@ -32,7 +33,7 @@ namespace Rag.Data.Migrations
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "Documents", name: "Documents",
schema: "rag", schema: MigrationConstants.SchemaName,
columns: table => new columns: table => new
{ {
Id = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false), Id = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
@@ -52,7 +53,7 @@ namespace Rag.Data.Migrations
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "EmbeddingCache", name: "EmbeddingCache",
schema: "rag", schema: MigrationConstants.SchemaName,
columns: table => new columns: table => new
{ {
CacheKey = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false), CacheKey = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
@@ -68,7 +69,7 @@ namespace Rag.Data.Migrations
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "Chunks", name: "Chunks",
schema: "rag", schema: MigrationConstants.SchemaName,
columns: table => new columns: table => new
{ {
Id = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false), Id = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
@@ -91,25 +92,25 @@ namespace Rag.Data.Migrations
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_Chunks_DocumentId", name: "IX_Chunks_DocumentId",
schema: "rag", schema: MigrationConstants.SchemaName,
table: "Chunks", table: "Chunks",
column: "DocumentId"); column: "DocumentId");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_Documents_DocumentType", name: "IX_Documents_DocumentType",
schema: "rag", schema: MigrationConstants.SchemaName,
table: "Documents", table: "Documents",
column: "DocumentType"); column: "DocumentType");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_Documents_TextHash", name: "IX_Documents_TextHash",
schema: "rag", schema: MigrationConstants.SchemaName,
table: "Documents", table: "Documents",
column: "TextHash"); column: "TextHash");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_EmbeddingCache_TextHash", name: "IX_EmbeddingCache_TextHash",
schema: "rag", schema: MigrationConstants.SchemaName,
table: "EmbeddingCache", table: "EmbeddingCache",
column: "TextHash"); column: "TextHash");
} }
@@ -119,19 +120,19 @@ namespace Rag.Data.Migrations
{ {
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "ChatCompletionCache", name: "ChatCompletionCache",
schema: "rag"); schema: MigrationConstants.SchemaName);
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Chunks", name: "Chunks",
schema: "rag"); schema: MigrationConstants.SchemaName);
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "EmbeddingCache", name: "EmbeddingCache",
schema: "rag"); schema: MigrationConstants.SchemaName);
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Documents", name: "Documents",
schema: "rag"); schema: MigrationConstants.SchemaName);
} }
} }
} }
+2 -2
View File
@@ -5,8 +5,8 @@ namespace Rag.Data;
public sealed class RagDbContext : DbContext public sealed class RagDbContext : DbContext
{ {
public const string SchemaName = "rag"; public const string SchemaName = MigrationConstants.SchemaName;
public const string MigrationTableName = "_Migrations"; public const string MigrationTableName = MigrationConstants.MigrationTableName;
public RagDbContext(DbContextOptions<RagDbContext> options) : base(options) public RagDbContext(DbContextOptions<RagDbContext> options) : base(options)
{ {
@@ -1,6 +1,7 @@
using Rag.Data; using Rag.Data;
using Rag.Data.Entities; using Rag.Data.Entities;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Rag.Data.Repositories.Contracts; using Rag.Data.Repositories.Contracts;
using Rag.Models; using Rag.Models;
+1
View File
@@ -18,6 +18,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\shared-data\shared-data.csproj" /> <ProjectReference Include="..\shared-data\shared-data.csproj" />
<ProjectReference Include="..\rag-api-models\rag-api-models.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>