Перевести ядро на единый контракт источника

Карточка, очередь и отсев работают с SourceItem (SourceRef + SourceContent); Telegram-поля убраны из домена, персистентности, конвейера и wire, остались только в адаптере приёма. Tenant-миграции пересозданы с нуля. Фронт переведён на generic source/content с просмотрщиком вложений.
This commit is contained in:
Rustam Khalimov
2026-09-11 14:58:54 +03:00
parent 770dba7257
commit ebc761d40e
94 changed files with 4150 additions and 9398 deletions
@@ -88,9 +88,9 @@ ContainersService containersService) : IColumnSuggester
List<string> texts = cards
.Where(card => card.Col != CardIds.Trash
&& card.Col != CardIds.Archive
&& card.SourceMsg.Trim().Length > 0)
&& (card.Content.Text ?? string.Empty).Trim().Length > 0)
.Take(SuggestHeuristics.KeywordsSampleLimit)
.Select(card => card.SourceMsg.Trim())
.Select(card => (card.Content.Text ?? string.Empty).Trim())
.ToList();
if (texts.Count < SuggestHeuristics.MinKeywordsSample)
{
@@ -115,7 +115,7 @@ ContainersService containersService) : IColumnSuggester
.Select(card => card.Id)
.ToHashSet(StringComparer.Ordinal);
Dictionary<string, string> textByCardId = inbox
.ToDictionary(card => card.Id, card => card.SourceMsg, StringComparer.Ordinal);
.ToDictionary(card => card.Id, card => card.Content.Text ?? string.Empty, StringComparer.Ordinal);
int created = 0;
foreach (SuggestedColumnPlan plan in plans)
@@ -1,49 +0,0 @@
// <auto-generated />
using System;
using Deal.Infrastructure.Persistence;
using Deal.Infrastructure.Persistence.Configurations;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Deal.Infrastructure.Migrations.TenantDb
{
[DbContext(typeof(TenantDbContext))]
[Migration("20260905193010_InitialTenant")]
partial class InitialTenant
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "10.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.TenantSettingEntity", b =>
{
b.Property<string>("Key")
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("ValueJson")
.IsRequired()
.HasColumnType("text");
b.HasKey("Key");
b.ToTable("settings", (string)null);
});
#pragma warning restore 612, 618
}
}
}
@@ -1,34 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Deal.Infrastructure.Migrations.TenantDb
{
/// <inheritdoc />
public partial class InitialTenant : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "settings",
columns: table => new
{
Key = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: false),
ValueJson = table.Column<string>(type: "text", nullable: false),
UpdatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_settings", x => x.Key);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "settings");
}
}
}
@@ -1,307 +0,0 @@
// <auto-generated />
using System;
using Deal.Infrastructure.Persistence;
using Deal.Infrastructure.Persistence.Configurations;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Deal.Infrastructure.Migrations.TenantDb
{
[DbContext(typeof(TenantDbContext))]
[Migration("20260906125058_TenantKanban")]
partial class TenantKanban
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "10.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.BoardEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<bool>("Collapsed")
.HasColumnType("boolean");
b.Property<string>("Color")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<string>("KeywordsJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Note")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Position")
.HasColumnType("integer");
b.Property<string>("Prompt")
.IsRequired()
.HasColumnType("text");
b.Property<string>("RulesJson")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("Suggested")
.HasColumnType("boolean");
b.Property<string>("VisibleFieldsJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Width")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("Suggested", "Position");
b.ToTable("Boards", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.CardEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<DateTimeOffset?>("ArchivedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("BudgetCur")
.IsRequired()
.HasColumnType("text");
b.Property<double?>("BudgetFrom")
.HasColumnType("double precision");
b.Property<double?>("BudgetTo")
.HasColumnType("double precision");
b.Property<string>("ChannelHandle")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ChannelHue")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ChannelName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Col")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<string>("Contact")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ContactsJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ConvCur")
.IsRequired()
.HasColumnType("text");
b.Property<double?>("ConvFrom")
.HasColumnType("double precision");
b.Property<double?>("ConvTo")
.HasColumnType("double precision");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<bool>("IsNew")
.HasColumnType("boolean");
b.Property<bool>("IsVacancy")
.HasColumnType("boolean");
b.Property<bool>("IsVacancyKnown")
.HasColumnType("boolean");
b.Property<string>("MatchHitsJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PrevCol")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("ReceivedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("SourceDialogId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("SourceMsg")
.IsRequired()
.HasColumnType("text");
b.Property<long?>("SourceMsgId")
.HasColumnType("bigint");
b.Property<string>("StackJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Summary")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("Col", "IsNew");
b.HasIndex("Col", "ReceivedAt")
.IsDescending(false, true);
b.ToTable("Cards", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.CardMoveEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("Action")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("FromCol")
.HasColumnType("text");
b.Property<string>("LeadId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ToCol")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("CardMoves", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.LeadCommentEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("By")
.IsRequired()
.HasColumnType("text");
b.Property<string>("CardId")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("CardId");
b.ToTable("LeadComments", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.MlOutboxEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<double>("Delta")
.HasColumnType("double precision");
b.Property<string>("Label")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("CreatedAt");
b.ToTable("MlOutbox", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.TenantSettingEntity", b =>
{
b.Property<string>("Key")
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("ValueJson")
.IsRequired()
.HasColumnType("text");
b.HasKey("Key");
b.ToTable("settings", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.LeadCommentEntity", b =>
{
b.HasOne("Deal.Infrastructure.Persistence.Entities.CardEntity", null)
.WithMany()
.HasForeignKey("CardId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}
@@ -1,172 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Deal.Infrastructure.Migrations.TenantDb
{
/// <inheritdoc />
public partial class TenantKanban : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Boards",
columns: table => new
{
Id = table.Column<string>(type: "text", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
Description = table.Column<string>(type: "text", nullable: false),
Color = table.Column<string>(type: "text", nullable: false),
Width = table.Column<string>(type: "text", nullable: false),
Position = table.Column<int>(type: "integer", nullable: false),
KeywordsJson = table.Column<string>(type: "text", nullable: false),
Prompt = table.Column<string>(type: "text", nullable: false),
VisibleFieldsJson = table.Column<string>(type: "text", nullable: false),
Collapsed = table.Column<bool>(type: "boolean", nullable: false),
Suggested = table.Column<bool>(type: "boolean", nullable: false),
RulesJson = table.Column<string>(type: "text", nullable: false),
Note = table.Column<string>(type: "text", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Boards", x => x.Id);
});
migrationBuilder.CreateTable(
name: "CardMoves",
columns: table => new
{
Id = table.Column<string>(type: "text", nullable: false),
LeadId = table.Column<string>(type: "text", nullable: false),
Action = table.Column<string>(type: "text", nullable: false),
FromCol = table.Column<string>(type: "text", nullable: true),
ToCol = table.Column<string>(type: "text", nullable: true),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CardMoves", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Cards",
columns: table => new
{
Id = table.Column<string>(type: "text", nullable: false),
Col = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: false),
IsNew = table.Column<bool>(type: "boolean", nullable: false),
IsVacancy = table.Column<bool>(type: "boolean", nullable: false),
IsVacancyKnown = table.Column<bool>(type: "boolean", nullable: false),
Title = table.Column<string>(type: "text", nullable: false),
Summary = table.Column<string>(type: "text", nullable: false),
StackJson = table.Column<string>(type: "text", nullable: false),
BudgetFrom = table.Column<double>(type: "double precision", nullable: true),
BudgetTo = table.Column<double>(type: "double precision", nullable: true),
BudgetCur = table.Column<string>(type: "text", nullable: false),
ConvFrom = table.Column<double>(type: "double precision", nullable: true),
ConvTo = table.Column<double>(type: "double precision", nullable: true),
ConvCur = table.Column<string>(type: "text", nullable: false),
Contact = table.Column<string>(type: "text", nullable: false),
ContactsJson = table.Column<string>(type: "text", nullable: false),
ChannelName = table.Column<string>(type: "text", nullable: false),
ChannelHandle = table.Column<string>(type: "text", nullable: false),
ChannelHue = table.Column<string>(type: "text", nullable: false),
ReceivedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
SourceMsg = table.Column<string>(type: "text", nullable: false),
SourceDialogId = table.Column<string>(type: "text", nullable: false),
SourceMsgId = table.Column<long>(type: "bigint", nullable: true),
PrevCol = table.Column<string>(type: "text", nullable: false),
ArchivedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
MatchHitsJson = table.Column<string>(type: "text", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Cards", x => x.Id);
});
migrationBuilder.CreateTable(
name: "MlOutbox",
columns: table => new
{
Id = table.Column<string>(type: "text", nullable: false),
Text = table.Column<string>(type: "text", nullable: false),
Label = table.Column<string>(type: "text", nullable: false),
Delta = table.Column<double>(type: "double precision", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_MlOutbox", x => x.Id);
});
migrationBuilder.CreateTable(
name: "LeadComments",
columns: table => new
{
Id = table.Column<string>(type: "text", nullable: false),
CardId = table.Column<string>(type: "text", nullable: false),
By = table.Column<string>(type: "text", nullable: false),
Text = table.Column<string>(type: "text", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_LeadComments", x => x.Id);
table.ForeignKey(
name: "FK_LeadComments_Cards_CardId",
column: x => x.CardId,
principalTable: "Cards",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Boards_Suggested_Position",
table: "Boards",
columns: new[] { "Suggested", "Position" });
migrationBuilder.CreateIndex(
name: "IX_Cards_Col_IsNew",
table: "Cards",
columns: new[] { "Col", "IsNew" });
migrationBuilder.CreateIndex(
name: "IX_Cards_Col_ReceivedAt",
table: "Cards",
columns: new[] { "Col", "ReceivedAt" },
descending: new[] { false, true });
migrationBuilder.CreateIndex(
name: "IX_LeadComments_CardId",
table: "LeadComments",
column: "CardId");
migrationBuilder.CreateIndex(
name: "IX_MlOutbox_CreatedAt",
table: "MlOutbox",
column: "CreatedAt");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Boards");
migrationBuilder.DropTable(
name: "CardMoves");
migrationBuilder.DropTable(
name: "LeadComments");
migrationBuilder.DropTable(
name: "MlOutbox");
migrationBuilder.DropTable(
name: "Cards");
}
}
}
@@ -1,462 +0,0 @@
// <auto-generated />
using System;
using Deal.Infrastructure.Persistence;
using Deal.Infrastructure.Persistence.Configurations;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using NpgsqlTypes;
#nullable disable
namespace Deal.Infrastructure.Migrations.TenantDb
{
[DbContext(typeof(TenantDbContext))]
[Migration("20260906165058_TenantPipeline")]
partial class TenantPipeline
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "10.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.BoardEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<bool>("Collapsed")
.HasColumnType("boolean");
b.Property<string>("Color")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<string>("KeywordsJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Note")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Position")
.HasColumnType("integer");
b.Property<string>("Prompt")
.IsRequired()
.HasColumnType("text");
b.Property<string>("RulesJson")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("Suggested")
.HasColumnType("boolean");
b.Property<string>("VisibleFieldsJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Width")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("Suggested", "Position");
b.ToTable("Boards", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.CardEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<DateTimeOffset?>("ArchivedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("BudgetCur")
.IsRequired()
.HasColumnType("text");
b.Property<double?>("BudgetFrom")
.HasColumnType("double precision");
b.Property<double?>("BudgetTo")
.HasColumnType("double precision");
b.Property<string>("ChannelHandle")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ChannelHue")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ChannelName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Col")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<string>("Contact")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ContactsJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ConvCur")
.IsRequired()
.HasColumnType("text");
b.Property<double?>("ConvFrom")
.HasColumnType("double precision");
b.Property<double?>("ConvTo")
.HasColumnType("double precision");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<bool>("IsNew")
.HasColumnType("boolean");
b.Property<bool>("IsVacancy")
.HasColumnType("boolean");
b.Property<bool>("IsVacancyKnown")
.HasColumnType("boolean");
b.Property<string>("MatchHitsJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PrevCol")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("ReceivedAt")
.HasColumnType("timestamp with time zone");
b.Property<NpgsqlTsVector>("SearchTsv")
.IsRequired()
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("tsvector")
.HasComputedColumnSql("to_tsvector('russian', coalesce(\"Title\",'')||' '||coalesce(\"Summary\",'')||' '||coalesce(\"SourceMsg\",'')||' '||coalesce(\"Contact\",''))", true);
b.Property<string>("SourceDialogId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("SourceMsg")
.IsRequired()
.HasColumnType("text");
b.Property<long?>("SourceMsgId")
.HasColumnType("bigint");
b.Property<string>("StackJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Summary")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("SearchTsv");
NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("SearchTsv"), "gin");
b.HasIndex("Col", "IsNew");
b.HasIndex("Col", "ReceivedAt")
.IsDescending(false, true);
b.ToTable("Cards", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.CardMoveEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("Action")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("FromCol")
.HasColumnType("text");
b.Property<string>("LeadId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ToCol")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("CardMoves", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.DedupEntryEntity", b =>
{
b.Property<string>("Hash")
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("LeadId")
.HasColumnType("text");
b.HasKey("Hash");
b.ToTable("DedupEntries", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.LeadCommentEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("By")
.IsRequired()
.HasColumnType("text");
b.Property<string>("CardId")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("CardId");
b.ToTable("LeadComments", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.MlOutboxEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<double>("Delta")
.HasColumnType("double precision");
b.Property<string>("Label")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("CreatedAt");
b.ToTable("MlOutbox", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.QueueItemEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("ChannelHandle")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ChannelHue")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ChannelName")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("DialogId")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("Force")
.HasColumnType("boolean");
b.Property<DateTimeOffset>("MsgAt")
.HasColumnType("timestamp with time zone");
b.Property<long?>("MsgId")
.HasColumnType("bigint");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("Status", "CreatedAt");
b.ToTable("QueueItems", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.RejectedItemEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("ChannelHandle")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ChannelHue")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ChannelName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("DialogId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Kw")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("MsgAt")
.HasColumnType("timestamp with time zone");
b.Property<long?>("MsgId")
.HasColumnType("bigint");
b.Property<string>("Reason")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("RejectedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("ReturnReason")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("Returned")
.HasColumnType("boolean");
b.Property<DateTimeOffset?>("ReturnedAt")
.HasColumnType("timestamp with time zone");
b.Property<NpgsqlTsVector>("SearchTsv")
.IsRequired()
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("tsvector")
.HasComputedColumnSql("to_tsvector('russian', coalesce(\"Text\",''))", true);
b.Property<string>("Source")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Stage")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("RejectedAt");
b.HasIndex("SearchTsv");
NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("SearchTsv"), "gin");
b.ToTable("RejectedItems", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.TenantSettingEntity", b =>
{
b.Property<string>("Key")
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("ValueJson")
.IsRequired()
.HasColumnType("text");
b.HasKey("Key");
b.ToTable("settings", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.LeadCommentEntity", b =>
{
b.HasOne("Deal.Infrastructure.Persistence.Entities.CardEntity", null)
.WithMany()
.HasForeignKey("CardId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}
@@ -1,128 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
using NpgsqlTypes;
#nullable disable
namespace Deal.Infrastructure.Migrations.TenantDb
{
/// <inheritdoc />
public partial class TenantPipeline : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<NpgsqlTsVector>(
name: "SearchTsv",
table: "Cards",
type: "tsvector",
nullable: false,
computedColumnSql: "to_tsvector('russian', coalesce(\"Title\",'')||' '||coalesce(\"Summary\",'')||' '||coalesce(\"SourceMsg\",'')||' '||coalesce(\"Contact\",''))",
stored: true);
migrationBuilder.CreateTable(
name: "DedupEntries",
columns: table => new
{
Hash = table.Column<string>(type: "text", nullable: false),
LeadId = table.Column<string>(type: "text", nullable: true),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_DedupEntries", x => x.Hash);
});
migrationBuilder.CreateTable(
name: "QueueItems",
columns: table => new
{
Id = table.Column<string>(type: "text", nullable: false),
DialogId = table.Column<string>(type: "text", nullable: false),
ChannelName = table.Column<string>(type: "text", nullable: false),
ChannelHandle = table.Column<string>(type: "text", nullable: false),
ChannelHue = table.Column<string>(type: "text", nullable: false),
Text = table.Column<string>(type: "text", nullable: false),
MsgId = table.Column<long>(type: "bigint", nullable: true),
MsgAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
Status = table.Column<string>(type: "text", nullable: false),
Force = table.Column<bool>(type: "boolean", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
UpdatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_QueueItems", x => x.Id);
});
migrationBuilder.CreateTable(
name: "RejectedItems",
columns: table => new
{
Id = table.Column<string>(type: "text", nullable: false),
DialogId = table.Column<string>(type: "text", nullable: false),
MsgId = table.Column<long>(type: "bigint", nullable: true),
ChannelName = table.Column<string>(type: "text", nullable: false),
ChannelHandle = table.Column<string>(type: "text", nullable: false),
ChannelHue = table.Column<string>(type: "text", nullable: false),
Text = table.Column<string>(type: "text", nullable: false),
Stage = table.Column<string>(type: "text", nullable: false),
Reason = table.Column<string>(type: "text", nullable: false),
Kw = table.Column<string>(type: "text", nullable: false),
Source = table.Column<string>(type: "text", nullable: false),
MsgAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
RejectedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
Returned = table.Column<bool>(type: "boolean", nullable: false),
ReturnedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
ReturnReason = table.Column<string>(type: "text", nullable: false),
SearchTsv = table.Column<NpgsqlTsVector>(type: "tsvector", nullable: false, computedColumnSql: "to_tsvector('russian', coalesce(\"Text\",''))", stored: true)
},
constraints: table =>
{
table.PrimaryKey("PK_RejectedItems", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_Cards_SearchTsv",
table: "Cards",
column: "SearchTsv")
.Annotation("Npgsql:IndexMethod", "gin");
migrationBuilder.CreateIndex(
name: "IX_QueueItems_Status_CreatedAt",
table: "QueueItems",
columns: new[] { "Status", "CreatedAt" });
migrationBuilder.CreateIndex(
name: "IX_RejectedItems_RejectedAt",
table: "RejectedItems",
column: "RejectedAt");
migrationBuilder.CreateIndex(
name: "IX_RejectedItems_SearchTsv",
table: "RejectedItems",
column: "SearchTsv")
.Annotation("Npgsql:IndexMethod", "gin");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "DedupEntries");
migrationBuilder.DropTable(
name: "QueueItems");
migrationBuilder.DropTable(
name: "RejectedItems");
migrationBuilder.DropIndex(
name: "IX_Cards_SearchTsv",
table: "Cards");
migrationBuilder.DropColumn(
name: "SearchTsv",
table: "Cards");
}
}
}
@@ -1,549 +0,0 @@
// <auto-generated />
using System;
using Deal.Infrastructure.Persistence;
using Deal.Infrastructure.Persistence.Configurations;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using NpgsqlTypes;
#nullable disable
namespace Deal.Infrastructure.Migrations.TenantDb
{
[DbContext(typeof(TenantDbContext))]
[Migration("20260906200342_TenantProjects")]
partial class TenantProjects
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "10.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.BoardEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<bool>("Collapsed")
.HasColumnType("boolean");
b.Property<string>("Color")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<string>("KeywordsJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Note")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Position")
.HasColumnType("integer");
b.Property<string>("Prompt")
.IsRequired()
.HasColumnType("text");
b.Property<string>("RulesJson")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("Suggested")
.HasColumnType("boolean");
b.Property<string>("VisibleFieldsJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Width")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("Suggested", "Position");
b.ToTable("Boards", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.CardEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<DateTimeOffset?>("ArchivedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("BudgetCur")
.IsRequired()
.HasColumnType("text");
b.Property<double?>("BudgetFrom")
.HasColumnType("double precision");
b.Property<double?>("BudgetTo")
.HasColumnType("double precision");
b.Property<string>("ChannelHandle")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ChannelHue")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ChannelName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Col")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<string>("Contact")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ContactsJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ConvCur")
.IsRequired()
.HasColumnType("text");
b.Property<double?>("ConvFrom")
.HasColumnType("double precision");
b.Property<double?>("ConvTo")
.HasColumnType("double precision");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<bool>("IsNew")
.HasColumnType("boolean");
b.Property<bool>("IsVacancy")
.HasColumnType("boolean");
b.Property<bool>("IsVacancyKnown")
.HasColumnType("boolean");
b.Property<string>("MatchHitsJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PrevCol")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("ReceivedAt")
.HasColumnType("timestamp with time zone");
b.Property<NpgsqlTsVector>("SearchTsv")
.IsRequired()
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("tsvector")
.HasComputedColumnSql("to_tsvector('russian', coalesce(\"Title\",'')||' '||coalesce(\"Summary\",'')||' '||coalesce(\"SourceMsg\",'')||' '||coalesce(\"Contact\",''))", true);
b.Property<string>("SourceDialogId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("SourceMsg")
.IsRequired()
.HasColumnType("text");
b.Property<long?>("SourceMsgId")
.HasColumnType("bigint");
b.Property<string>("StackJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Summary")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("SearchTsv");
NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("SearchTsv"), "gin");
b.HasIndex("Col", "IsNew");
b.HasIndex("Col", "ReceivedAt")
.IsDescending(false, true);
b.ToTable("Cards", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.CardMoveEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("Action")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("FromCol")
.HasColumnType("text");
b.Property<string>("LeadId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ToCol")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("CardMoves", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.DedupEntryEntity", b =>
{
b.Property<string>("Hash")
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("LeadId")
.HasColumnType("text");
b.HasKey("Hash");
b.ToTable("DedupEntries", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.LeadCommentEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("By")
.IsRequired()
.HasColumnType("text");
b.Property<string>("CardId")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("CardId");
b.ToTable("LeadComments", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.MlOutboxEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<double>("Delta")
.HasColumnType("double precision");
b.Property<string>("Label")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("CreatedAt");
b.ToTable("MlOutbox", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.ProjectCardEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("BudgetCur")
.IsRequired()
.HasColumnType("text");
b.Property<double?>("BudgetFrom")
.HasColumnType("double precision");
b.Property<double?>("BudgetTo")
.HasColumnType("double precision");
b.Property<string>("CommentsJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Contact")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("FilesJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("HistoryJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("LeadId")
.HasColumnType("text");
b.Property<string>("LinksJson")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("Local")
.HasColumnType("boolean");
b.Property<DateTimeOffset?>("ReminderAt")
.HasColumnType("timestamp with time zone");
b.Property<bool>("ReminderFired")
.HasColumnType("boolean");
b.Property<string>("StackJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Stage")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Summary")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<string>("TzText")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("LeadId")
.IsUnique()
.HasFilter("\"LeadId\" IS NOT NULL");
b.HasIndex("Stage");
b.HasIndex("UpdatedAt")
.IsDescending();
b.ToTable("ProjectCards", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.QueueItemEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("ChannelHandle")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ChannelHue")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ChannelName")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("DialogId")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("Force")
.HasColumnType("boolean");
b.Property<DateTimeOffset>("MsgAt")
.HasColumnType("timestamp with time zone");
b.Property<long?>("MsgId")
.HasColumnType("bigint");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("Status", "CreatedAt");
b.ToTable("QueueItems", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.RejectedItemEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("ChannelHandle")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ChannelHue")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ChannelName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("DialogId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Kw")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("MsgAt")
.HasColumnType("timestamp with time zone");
b.Property<long?>("MsgId")
.HasColumnType("bigint");
b.Property<string>("Reason")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("RejectedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("ReturnReason")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("Returned")
.HasColumnType("boolean");
b.Property<DateTimeOffset?>("ReturnedAt")
.HasColumnType("timestamp with time zone");
b.Property<NpgsqlTsVector>("SearchTsv")
.IsRequired()
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("tsvector")
.HasComputedColumnSql("to_tsvector('russian', coalesce(\"Text\",''))", true);
b.Property<string>("Source")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Stage")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("RejectedAt");
b.HasIndex("SearchTsv");
NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("SearchTsv"), "gin");
b.ToTable("RejectedItems", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.TenantSettingEntity", b =>
{
b.Property<string>("Key")
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("ValueJson")
.IsRequired()
.HasColumnType("text");
b.HasKey("Key");
b.ToTable("settings", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.LeadCommentEntity", b =>
{
b.HasOne("Deal.Infrastructure.Persistence.Entities.CardEntity", null)
.WithMany()
.HasForeignKey("CardId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}
@@ -1,69 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Deal.Infrastructure.Migrations.TenantDb
{
/// <inheritdoc />
public partial class TenantProjects : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "ProjectCards",
columns: table => new
{
Id = table.Column<string>(type: "text", nullable: false),
Stage = table.Column<string>(type: "text", nullable: false),
Local = table.Column<bool>(type: "boolean", nullable: false),
LeadId = table.Column<string>(type: "text", nullable: true),
Title = table.Column<string>(type: "text", nullable: false),
Summary = table.Column<string>(type: "text", nullable: false),
StackJson = table.Column<string>(type: "text", nullable: false),
BudgetFrom = table.Column<double>(type: "double precision", nullable: true),
BudgetTo = table.Column<double>(type: "double precision", nullable: true),
BudgetCur = table.Column<string>(type: "text", nullable: false),
Contact = table.Column<string>(type: "text", nullable: false),
CommentsJson = table.Column<string>(type: "text", nullable: false),
LinksJson = table.Column<string>(type: "text", nullable: false),
FilesJson = table.Column<string>(type: "text", nullable: false),
HistoryJson = table.Column<string>(type: "text", nullable: false),
TzText = table.Column<string>(type: "text", nullable: false),
ReminderAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
ReminderFired = table.Column<bool>(type: "boolean", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
UpdatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ProjectCards", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_ProjectCards_LeadId",
table: "ProjectCards",
column: "LeadId",
unique: true,
filter: "\"LeadId\" IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_ProjectCards_Stage",
table: "ProjectCards",
column: "Stage");
migrationBuilder.CreateIndex(
name: "IX_ProjectCards_UpdatedAt",
table: "ProjectCards",
column: "UpdatedAt",
descending: new bool[0]);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ProjectCards");
}
}
}
@@ -1,619 +0,0 @@
// <auto-generated />
using System;
using Deal.Infrastructure.Persistence;
using Deal.Infrastructure.Persistence.Configurations;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using NpgsqlTypes;
#nullable disable
namespace Deal.Infrastructure.Migrations.TenantDb
{
[DbContext(typeof(TenantDbContext))]
[Migration("20260907141242_TenantTelegram")]
partial class TenantTelegram
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "10.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.BoardEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<bool>("Collapsed")
.HasColumnType("boolean");
b.Property<string>("Color")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<string>("KeywordsJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Note")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Position")
.HasColumnType("integer");
b.Property<string>("Prompt")
.IsRequired()
.HasColumnType("text");
b.Property<string>("RulesJson")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("Suggested")
.HasColumnType("boolean");
b.Property<string>("VisibleFieldsJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Width")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("Suggested", "Position");
b.ToTable("Boards", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.CardEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<DateTimeOffset?>("ArchivedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("BudgetCur")
.IsRequired()
.HasColumnType("text");
b.Property<double?>("BudgetFrom")
.HasColumnType("double precision");
b.Property<double?>("BudgetTo")
.HasColumnType("double precision");
b.Property<string>("ChannelHandle")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ChannelHue")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ChannelName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Col")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<string>("Contact")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ContactsJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ConvCur")
.IsRequired()
.HasColumnType("text");
b.Property<double?>("ConvFrom")
.HasColumnType("double precision");
b.Property<double?>("ConvTo")
.HasColumnType("double precision");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<bool>("IsNew")
.HasColumnType("boolean");
b.Property<bool>("IsVacancy")
.HasColumnType("boolean");
b.Property<bool>("IsVacancyKnown")
.HasColumnType("boolean");
b.Property<string>("MatchHitsJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PrevCol")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("ReceivedAt")
.HasColumnType("timestamp with time zone");
b.Property<NpgsqlTsVector>("SearchTsv")
.IsRequired()
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("tsvector")
.HasComputedColumnSql("to_tsvector('russian', coalesce(\"Title\",'')||' '||coalesce(\"Summary\",'')||' '||coalesce(\"SourceMsg\",'')||' '||coalesce(\"Contact\",''))", true);
b.Property<string>("SourceDialogId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("SourceMsg")
.IsRequired()
.HasColumnType("text");
b.Property<long?>("SourceMsgId")
.HasColumnType("bigint");
b.Property<string>("StackJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Summary")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("SearchTsv");
NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("SearchTsv"), "gin");
b.HasIndex("Col", "IsNew");
b.HasIndex("Col", "ReceivedAt")
.IsDescending(false, true);
b.ToTable("Cards", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.CardMoveEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("Action")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("FromCol")
.HasColumnType("text");
b.Property<string>("LeadId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ToCol")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("CardMoves", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.DedupEntryEntity", b =>
{
b.Property<string>("Hash")
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("LeadId")
.HasColumnType("text");
b.HasKey("Hash");
b.ToTable("DedupEntries", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.DialogEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<bool>("Backfilled")
.HasColumnType("boolean");
b.Property<string>("Handle")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Hue")
.IsRequired()
.ValueGeneratedOnAdd()
.HasColumnType("text")
.HasDefaultValue("#666");
b.Property<string>("Kind")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset?>("LastAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("LastText")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("Monitor")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.ToTable("Dialogs", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.LeadCommentEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("By")
.IsRequired()
.HasColumnType("text");
b.Property<string>("CardId")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("CardId");
b.ToTable("LeadComments", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.MlOutboxEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<double>("Delta")
.HasColumnType("double precision");
b.Property<string>("Label")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("CreatedAt");
b.ToTable("MlOutbox", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.ProjectCardEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("BudgetCur")
.IsRequired()
.HasColumnType("text");
b.Property<double?>("BudgetFrom")
.HasColumnType("double precision");
b.Property<double?>("BudgetTo")
.HasColumnType("double precision");
b.Property<string>("CommentsJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Contact")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("FilesJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("HistoryJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("LeadId")
.HasColumnType("text");
b.Property<string>("LinksJson")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("Local")
.HasColumnType("boolean");
b.Property<DateTimeOffset?>("ReminderAt")
.HasColumnType("timestamp with time zone");
b.Property<bool>("ReminderFired")
.HasColumnType("boolean");
b.Property<string>("StackJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Stage")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Summary")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<string>("TzText")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("LeadId")
.IsUnique()
.HasFilter("\"LeadId\" IS NOT NULL");
b.HasIndex("Stage");
b.HasIndex("UpdatedAt")
.IsDescending();
b.ToTable("ProjectCards", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.QueueItemEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("ChannelHandle")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ChannelHue")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ChannelName")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("DialogId")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("Force")
.HasColumnType("boolean");
b.Property<DateTimeOffset>("MsgAt")
.HasColumnType("timestamp with time zone");
b.Property<long?>("MsgId")
.HasColumnType("bigint");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("Status", "CreatedAt");
b.ToTable("QueueItems", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.RejectedItemEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("ChannelHandle")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ChannelHue")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ChannelName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("DialogId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Kw")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("MsgAt")
.HasColumnType("timestamp with time zone");
b.Property<long?>("MsgId")
.HasColumnType("bigint");
b.Property<string>("Reason")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("RejectedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("ReturnReason")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("Returned")
.HasColumnType("boolean");
b.Property<DateTimeOffset?>("ReturnedAt")
.HasColumnType("timestamp with time zone");
b.Property<NpgsqlTsVector>("SearchTsv")
.IsRequired()
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("tsvector")
.HasComputedColumnSql("to_tsvector('russian', coalesce(\"Text\",''))", true);
b.Property<string>("Source")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Stage")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("RejectedAt");
b.HasIndex("SearchTsv");
NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("SearchTsv"), "gin");
b.ToTable("RejectedItems", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.TenantSettingEntity", b =>
{
b.Property<string>("Key")
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("ValueJson")
.IsRequired()
.HasColumnType("text");
b.HasKey("Key");
b.ToTable("settings", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.TgMessageEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("DialogId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("LeadId")
.HasColumnType("text");
b.Property<DateTimeOffset>("MsgAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DialogId", "MsgAt");
b.ToTable("TgMessages", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.LeadCommentEntity", b =>
{
b.HasOne("Deal.Infrastructure.Persistence.Entities.CardEntity", null)
.WithMany()
.HasForeignKey("CardId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}
@@ -1,64 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Deal.Infrastructure.Migrations.TenantDb
{
/// <inheritdoc />
public partial class TenantTelegram : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Dialogs",
columns: table => new
{
Id = table.Column<string>(type: "text", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
Handle = table.Column<string>(type: "text", nullable: false),
Kind = table.Column<string>(type: "text", nullable: false),
Hue = table.Column<string>(type: "text", nullable: false, defaultValue: "#666"),
Monitor = table.Column<bool>(type: "boolean", nullable: false),
LastText = table.Column<string>(type: "text", nullable: false),
LastAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
Backfilled = table.Column<bool>(type: "boolean", nullable: false),
UpdatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Dialogs", x => x.Id);
});
migrationBuilder.CreateTable(
name: "TgMessages",
columns: table => new
{
Id = table.Column<string>(type: "text", nullable: false),
DialogId = table.Column<string>(type: "text", nullable: false),
Text = table.Column<string>(type: "text", nullable: false),
MsgAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
LeadId = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_TgMessages", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_TgMessages_DialogId_MsgAt",
table: "TgMessages",
columns: new[] { "DialogId", "MsgAt" });
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Dialogs");
migrationBuilder.DropTable(
name: "TgMessages");
}
}
}
@@ -1,801 +0,0 @@
// <auto-generated />
using System;
using Deal.Infrastructure.Persistence;
using Deal.Infrastructure.Persistence.Configurations;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using NpgsqlTypes;
#nullable disable
namespace Deal.Infrastructure.Migrations.TenantDb
{
[DbContext(typeof(TenantDbContext))]
[Migration("20260907155333_TenantDiscovery")]
partial class TenantDiscovery
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "10.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.BoardEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<bool>("Collapsed")
.HasColumnType("boolean");
b.Property<string>("Color")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<string>("KeywordsJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Note")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Position")
.HasColumnType("integer");
b.Property<string>("Prompt")
.IsRequired()
.HasColumnType("text");
b.Property<string>("RulesJson")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("Suggested")
.HasColumnType("boolean");
b.Property<string>("VisibleFieldsJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Width")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("Suggested", "Position");
b.ToTable("Boards", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.CardEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<DateTimeOffset?>("ArchivedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("BudgetCur")
.IsRequired()
.HasColumnType("text");
b.Property<double?>("BudgetFrom")
.HasColumnType("double precision");
b.Property<double?>("BudgetTo")
.HasColumnType("double precision");
b.Property<string>("ChannelHandle")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ChannelHue")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ChannelName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Col")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<string>("Contact")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ContactsJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ConvCur")
.IsRequired()
.HasColumnType("text");
b.Property<double?>("ConvFrom")
.HasColumnType("double precision");
b.Property<double?>("ConvTo")
.HasColumnType("double precision");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<bool>("IsNew")
.HasColumnType("boolean");
b.Property<bool>("IsVacancy")
.HasColumnType("boolean");
b.Property<bool>("IsVacancyKnown")
.HasColumnType("boolean");
b.Property<string>("MatchHitsJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PrevCol")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("ReceivedAt")
.HasColumnType("timestamp with time zone");
b.Property<NpgsqlTsVector>("SearchTsv")
.IsRequired()
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("tsvector")
.HasComputedColumnSql("to_tsvector('russian', coalesce(\"Title\",'')||' '||coalesce(\"Summary\",'')||' '||coalesce(\"SourceMsg\",'')||' '||coalesce(\"Contact\",''))", true);
b.Property<string>("SourceDialogId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("SourceMsg")
.IsRequired()
.HasColumnType("text");
b.Property<long?>("SourceMsgId")
.HasColumnType("bigint");
b.Property<string>("StackJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Summary")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("SearchTsv");
NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("SearchTsv"), "gin");
b.HasIndex("Col", "IsNew");
b.HasIndex("Col", "ReceivedAt")
.IsDescending(false, true);
b.ToTable("Cards", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.CardMoveEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("Action")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("FromCol")
.HasColumnType("text");
b.Property<string>("LeadId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ToCol")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("CardMoves", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.DedupEntryEntity", b =>
{
b.Property<string>("Hash")
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("LeadId")
.HasColumnType("text");
b.HasKey("Hash");
b.ToTable("DedupEntries", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.DialogEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<bool>("Backfilled")
.HasColumnType("boolean");
b.Property<string>("Handle")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Hue")
.IsRequired()
.ValueGeneratedOnAdd()
.HasColumnType("text")
.HasDefaultValue("#666");
b.Property<string>("Kind")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset?>("LastAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("LastText")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("Monitor")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.ToTable("Dialogs", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.DiscBlacklistEntity", b =>
{
b.Property<string>("DialogId")
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Reason")
.IsRequired()
.HasColumnType("text");
b.HasKey("DialogId");
b.ToTable("DiscBlacklist", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.DiscCandidateEntity", b =>
{
b.Property<string>("DialogId")
.HasColumnType("text");
b.Property<bool>("AutoJoined")
.HasColumnType("boolean");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<double?>("FitRatio")
.HasColumnType("double precision");
b.Property<string>("Hue")
.IsRequired()
.HasColumnType("text");
b.Property<int>("JoinFailures")
.HasColumnType("integer");
b.Property<string>("Kind")
.IsRequired()
.HasColumnType("text");
b.Property<bool?>("LangRu")
.HasColumnType("boolean");
b.Property<string>("MarksJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int?>("Participants")
.HasColumnType("integer");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("text");
b.Property<string>("TaskId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("TopicsJson")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Username")
.IsRequired()
.HasColumnType("text");
b.HasKey("DialogId");
b.HasIndex("TaskId", "Status");
b.ToTable("DiscCandidates", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.DiscLogEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Event")
.IsRequired()
.HasColumnType("text");
b.Property<string>("TaskId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("TaskId", "CreatedAt");
b.ToTable("DiscLog", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.DiscTaskEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<bool>("AutoJoin")
.HasColumnType("boolean");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Evaluated")
.HasColumnType("integer");
b.Property<int>("Found")
.HasColumnType("integer");
b.Property<int>("Joined")
.HasColumnType("integer");
b.Property<string>("KeywordsJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Lang")
.IsRequired()
.HasColumnType("text");
b.Property<int>("MinSubscribers")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("PlanJoins")
.HasColumnType("integer");
b.Property<int>("Rejected")
.HasColumnType("integer");
b.Property<int>("SampleSize")
.HasColumnType("integer");
b.Property<bool>("SearchDone")
.HasColumnType("boolean");
b.Property<int>("SearchIdx")
.HasColumnType("integer");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Threshold")
.HasColumnType("integer");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.ToTable("DiscTasks", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.LeadCommentEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("By")
.IsRequired()
.HasColumnType("text");
b.Property<string>("CardId")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("CardId");
b.ToTable("LeadComments", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.MlOutboxEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<double>("Delta")
.HasColumnType("double precision");
b.Property<string>("Label")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("CreatedAt");
b.ToTable("MlOutbox", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.ProjectCardEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("BudgetCur")
.IsRequired()
.HasColumnType("text");
b.Property<double?>("BudgetFrom")
.HasColumnType("double precision");
b.Property<double?>("BudgetTo")
.HasColumnType("double precision");
b.Property<string>("CommentsJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Contact")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("FilesJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("HistoryJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("LeadId")
.HasColumnType("text");
b.Property<string>("LinksJson")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("Local")
.HasColumnType("boolean");
b.Property<DateTimeOffset?>("ReminderAt")
.HasColumnType("timestamp with time zone");
b.Property<bool>("ReminderFired")
.HasColumnType("boolean");
b.Property<string>("StackJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Stage")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Summary")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<string>("TzText")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("LeadId")
.IsUnique()
.HasFilter("\"LeadId\" IS NOT NULL");
b.HasIndex("Stage");
b.HasIndex("UpdatedAt")
.IsDescending();
b.ToTable("ProjectCards", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.QueueItemEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("ChannelHandle")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ChannelHue")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ChannelName")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("DialogId")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("Force")
.HasColumnType("boolean");
b.Property<DateTimeOffset>("MsgAt")
.HasColumnType("timestamp with time zone");
b.Property<long?>("MsgId")
.HasColumnType("bigint");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("Status", "CreatedAt");
b.ToTable("QueueItems", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.RejectedItemEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("ChannelHandle")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ChannelHue")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ChannelName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("DialogId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Kw")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("MsgAt")
.HasColumnType("timestamp with time zone");
b.Property<long?>("MsgId")
.HasColumnType("bigint");
b.Property<string>("Reason")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("RejectedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("ReturnReason")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("Returned")
.HasColumnType("boolean");
b.Property<DateTimeOffset?>("ReturnedAt")
.HasColumnType("timestamp with time zone");
b.Property<NpgsqlTsVector>("SearchTsv")
.IsRequired()
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("tsvector")
.HasComputedColumnSql("to_tsvector('russian', coalesce(\"Text\",''))", true);
b.Property<string>("Source")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Stage")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("RejectedAt");
b.HasIndex("SearchTsv");
NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("SearchTsv"), "gin");
b.ToTable("RejectedItems", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.TenantSettingEntity", b =>
{
b.Property<string>("Key")
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("ValueJson")
.IsRequired()
.HasColumnType("text");
b.HasKey("Key");
b.ToTable("settings", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.TgMessageEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("DialogId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("LeadId")
.HasColumnType("text");
b.Property<DateTimeOffset>("MsgAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DialogId", "MsgAt");
b.ToTable("TgMessages", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.LeadCommentEntity", b =>
{
b.HasOne("Deal.Infrastructure.Persistence.Entities.CardEntity", null)
.WithMany()
.HasForeignKey("CardId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}
@@ -1,124 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Deal.Infrastructure.Migrations.TenantDb
{
/// <inheritdoc />
public partial class TenantDiscovery : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "DiscBlacklist",
columns: table => new
{
DialogId = table.Column<string>(type: "text", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
Reason = table.Column<string>(type: "text", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_DiscBlacklist", x => x.DialogId);
});
migrationBuilder.CreateTable(
name: "DiscCandidates",
columns: table => new
{
DialogId = table.Column<string>(type: "text", nullable: false),
TaskId = table.Column<string>(type: "text", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
Username = table.Column<string>(type: "text", nullable: false),
Kind = table.Column<string>(type: "text", nullable: false),
Hue = table.Column<string>(type: "text", nullable: false),
Participants = table.Column<int>(type: "integer", nullable: true),
LangRu = table.Column<bool>(type: "boolean", nullable: true),
MarksJson = table.Column<string>(type: "text", nullable: false),
TopicsJson = table.Column<string>(type: "text", nullable: false),
FitRatio = table.Column<double>(type: "double precision", nullable: true),
Status = table.Column<string>(type: "text", nullable: false),
AutoJoined = table.Column<bool>(type: "boolean", nullable: false),
JoinFailures = table.Column<int>(type: "integer", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
UpdatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_DiscCandidates", x => x.DialogId);
});
migrationBuilder.CreateTable(
name: "DiscLog",
columns: table => new
{
Id = table.Column<string>(type: "text", nullable: false),
TaskId = table.Column<string>(type: "text", nullable: false),
Event = table.Column<string>(type: "text", nullable: false),
Text = table.Column<string>(type: "text", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_DiscLog", x => x.Id);
});
migrationBuilder.CreateTable(
name: "DiscTasks",
columns: table => new
{
Id = table.Column<string>(type: "text", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
Description = table.Column<string>(type: "text", nullable: false),
KeywordsJson = table.Column<string>(type: "text", nullable: false),
MinSubscribers = table.Column<int>(type: "integer", nullable: false),
Lang = table.Column<string>(type: "text", nullable: false),
Threshold = table.Column<int>(type: "integer", nullable: false),
SampleSize = table.Column<int>(type: "integer", nullable: false),
PlanJoins = table.Column<int>(type: "integer", nullable: false),
AutoJoin = table.Column<bool>(type: "boolean", nullable: false),
Status = table.Column<string>(type: "text", nullable: false),
SearchIdx = table.Column<int>(type: "integer", nullable: false),
SearchDone = table.Column<bool>(type: "boolean", nullable: false),
Found = table.Column<int>(type: "integer", nullable: false),
Evaluated = table.Column<int>(type: "integer", nullable: false),
Joined = table.Column<int>(type: "integer", nullable: false),
Rejected = table.Column<int>(type: "integer", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
UpdatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_DiscTasks", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_DiscCandidates_TaskId_Status",
table: "DiscCandidates",
columns: new[] { "TaskId", "Status" });
migrationBuilder.CreateIndex(
name: "IX_DiscLog_TaskId_CreatedAt",
table: "DiscLog",
columns: new[] { "TaskId", "CreatedAt" });
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "DiscBlacklist");
migrationBuilder.DropTable(
name: "DiscCandidates");
migrationBuilder.DropTable(
name: "DiscLog");
migrationBuilder.DropTable(
name: "DiscTasks");
}
}
}
@@ -1,879 +0,0 @@
// <auto-generated />
using System;
using Deal.Infrastructure.Persistence;
using Deal.Infrastructure.Persistence.Configurations;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using NpgsqlTypes;
#nullable disable
namespace Deal.Infrastructure.Migrations.TenantDb
{
[DbContext(typeof(TenantDbContext))]
[Migration("20260909222322_TenantContainers")]
partial class TenantContainers
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "10.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.BoardEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<bool>("Collapsed")
.HasColumnType("boolean");
b.Property<string>("Color")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<string>("KeywordsJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Note")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Position")
.HasColumnType("integer");
b.Property<string>("Prompt")
.IsRequired()
.HasColumnType("text");
b.Property<string>("RulesJson")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("Suggested")
.HasColumnType("boolean");
b.Property<string>("VisibleFieldsJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Width")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("Suggested", "Position");
b.ToTable("Boards", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.CardEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<DateTimeOffset?>("ArchivedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("BudgetCur")
.IsRequired()
.HasColumnType("text");
b.Property<double?>("BudgetFrom")
.HasColumnType("double precision");
b.Property<double?>("BudgetTo")
.HasColumnType("double precision");
b.Property<string>("ChannelHandle")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ChannelHue")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ChannelName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Col")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<string>("Contact")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ContactsJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ConvCur")
.IsRequired()
.HasColumnType("text");
b.Property<double?>("ConvFrom")
.HasColumnType("double precision");
b.Property<double?>("ConvTo")
.HasColumnType("double precision");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<bool>("IsNew")
.HasColumnType("boolean");
b.Property<bool>("IsVacancy")
.HasColumnType("boolean");
b.Property<bool>("IsVacancyKnown")
.HasColumnType("boolean");
b.Property<string>("MatchHitsJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PrevCol")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("ReceivedAt")
.HasColumnType("timestamp with time zone");
b.Property<NpgsqlTsVector>("SearchTsv")
.IsRequired()
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("tsvector")
.HasComputedColumnSql("to_tsvector('russian', coalesce(\"Title\",'')||' '||coalesce(\"Summary\",'')||' '||coalesce(\"SourceMsg\",'')||' '||coalesce(\"Contact\",''))", true);
b.Property<string>("SourceDialogId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("SourceMsg")
.IsRequired()
.HasColumnType("text");
b.Property<long?>("SourceMsgId")
.HasColumnType("bigint");
b.Property<string>("StackJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Summary")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("SearchTsv");
NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("SearchTsv"), "gin");
b.HasIndex("Col", "IsNew");
b.HasIndex("Col", "ReceivedAt")
.IsDescending(false, true);
b.ToTable("Cards", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.CardMoveEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("Action")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("FromCol")
.HasColumnType("text");
b.Property<string>("LeadId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ToCol")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("CardMoves", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.ContainerEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<bool>("Collapsed")
.HasColumnType("boolean");
b.Property<string>("Color")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<string>("KeywordsJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Kind")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Note")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PolicyJson")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Position")
.HasColumnType("integer");
b.Property<string>("RulesJson")
.IsRequired()
.HasColumnType("text");
b.Property<NpgsqlTsVector>("SearchTsv")
.IsRequired()
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("tsvector")
.HasComputedColumnSql("to_tsvector('russian', coalesce(\"Name\",'')||' '||coalesce(\"Description\",''))", true);
b.Property<string>("Space")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)");
b.Property<bool>("Suggested")
.HasColumnType("boolean");
b.Property<string>("VisibleFieldsJson")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("SearchTsv");
NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("SearchTsv"), "gin");
b.HasIndex("Space", "Position");
b.HasIndex("Suggested", "Position");
b.ToTable("Containers", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.DedupEntryEntity", b =>
{
b.Property<string>("Hash")
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("LeadId")
.HasColumnType("text");
b.HasKey("Hash");
b.ToTable("DedupEntries", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.DialogEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<bool>("Backfilled")
.HasColumnType("boolean");
b.Property<string>("Handle")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Hue")
.IsRequired()
.ValueGeneratedOnAdd()
.HasColumnType("text")
.HasDefaultValue("#666");
b.Property<string>("Kind")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset?>("LastAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("LastText")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("Monitor")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.ToTable("Dialogs", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.DiscBlacklistEntity", b =>
{
b.Property<string>("DialogId")
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Reason")
.IsRequired()
.HasColumnType("text");
b.HasKey("DialogId");
b.ToTable("DiscBlacklist", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.DiscCandidateEntity", b =>
{
b.Property<string>("DialogId")
.HasColumnType("text");
b.Property<bool>("AutoJoined")
.HasColumnType("boolean");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<double?>("FitRatio")
.HasColumnType("double precision");
b.Property<string>("Hue")
.IsRequired()
.HasColumnType("text");
b.Property<int>("JoinFailures")
.HasColumnType("integer");
b.Property<string>("Kind")
.IsRequired()
.HasColumnType("text");
b.Property<bool?>("LangRu")
.HasColumnType("boolean");
b.Property<string>("MarksJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int?>("Participants")
.HasColumnType("integer");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("text");
b.Property<string>("TaskId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("TopicsJson")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Username")
.IsRequired()
.HasColumnType("text");
b.HasKey("DialogId");
b.HasIndex("TaskId", "Status");
b.ToTable("DiscCandidates", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.DiscLogEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Event")
.IsRequired()
.HasColumnType("text");
b.Property<string>("TaskId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("TaskId", "CreatedAt");
b.ToTable("DiscLog", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.DiscTaskEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<bool>("AutoJoin")
.HasColumnType("boolean");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Evaluated")
.HasColumnType("integer");
b.Property<int>("Found")
.HasColumnType("integer");
b.Property<int>("Joined")
.HasColumnType("integer");
b.Property<string>("KeywordsJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Lang")
.IsRequired()
.HasColumnType("text");
b.Property<int>("MinSubscribers")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("PlanJoins")
.HasColumnType("integer");
b.Property<int>("Rejected")
.HasColumnType("integer");
b.Property<int>("SampleSize")
.HasColumnType("integer");
b.Property<bool>("SearchDone")
.HasColumnType("boolean");
b.Property<int>("SearchIdx")
.HasColumnType("integer");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Threshold")
.HasColumnType("integer");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.ToTable("DiscTasks", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.LeadCommentEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("By")
.IsRequired()
.HasColumnType("text");
b.Property<string>("CardId")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("CardId");
b.ToTable("LeadComments", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.MlOutboxEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<double>("Delta")
.HasColumnType("double precision");
b.Property<string>("Label")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("CreatedAt");
b.ToTable("MlOutbox", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.ProjectCardEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("BudgetCur")
.IsRequired()
.HasColumnType("text");
b.Property<double?>("BudgetFrom")
.HasColumnType("double precision");
b.Property<double?>("BudgetTo")
.HasColumnType("double precision");
b.Property<string>("CommentsJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Contact")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("FilesJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("HistoryJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("LeadId")
.HasColumnType("text");
b.Property<string>("LinksJson")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("Local")
.HasColumnType("boolean");
b.Property<DateTimeOffset?>("ReminderAt")
.HasColumnType("timestamp with time zone");
b.Property<bool>("ReminderFired")
.HasColumnType("boolean");
b.Property<string>("StackJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Stage")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Summary")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<string>("TzText")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("LeadId")
.IsUnique()
.HasFilter("\"LeadId\" IS NOT NULL");
b.HasIndex("Stage");
b.HasIndex("UpdatedAt")
.IsDescending();
b.ToTable("ProjectCards", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.QueueItemEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("ChannelHandle")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ChannelHue")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ChannelName")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("DialogId")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("Force")
.HasColumnType("boolean");
b.Property<DateTimeOffset>("MsgAt")
.HasColumnType("timestamp with time zone");
b.Property<long?>("MsgId")
.HasColumnType("bigint");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("Status", "CreatedAt");
b.ToTable("QueueItems", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.RejectedItemEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("ChannelHandle")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ChannelHue")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ChannelName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("DialogId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Kw")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("MsgAt")
.HasColumnType("timestamp with time zone");
b.Property<long?>("MsgId")
.HasColumnType("bigint");
b.Property<string>("Reason")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("RejectedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("ReturnReason")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("Returned")
.HasColumnType("boolean");
b.Property<DateTimeOffset?>("ReturnedAt")
.HasColumnType("timestamp with time zone");
b.Property<NpgsqlTsVector>("SearchTsv")
.IsRequired()
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("tsvector")
.HasComputedColumnSql("to_tsvector('russian', coalesce(\"Text\",''))", true);
b.Property<string>("Source")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Stage")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("RejectedAt");
b.HasIndex("SearchTsv");
NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("SearchTsv"), "gin");
b.ToTable("RejectedItems", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.TenantSettingEntity", b =>
{
b.Property<string>("Key")
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("ValueJson")
.IsRequired()
.HasColumnType("text");
b.HasKey("Key");
b.ToTable("settings", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.TgMessageEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("DialogId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("LeadId")
.HasColumnType("text");
b.Property<DateTimeOffset>("MsgAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DialogId", "MsgAt");
b.ToTable("TgMessages", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.LeadCommentEntity", b =>
{
b.HasOne("Deal.Infrastructure.Persistence.Entities.CardEntity", null)
.WithMany()
.HasForeignKey("CardId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}
@@ -1,68 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
using NpgsqlTypes;
#nullable disable
namespace Deal.Infrastructure.Migrations.TenantDb
{
/// <inheritdoc />
public partial class TenantContainers : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Containers",
columns: table => new
{
Id = table.Column<string>(type: "text", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
Description = table.Column<string>(type: "text", nullable: false),
Color = table.Column<string>(type: "text", nullable: false),
Position = table.Column<int>(type: "integer", nullable: false),
Kind = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
Space = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
KeywordsJson = table.Column<string>(type: "text", nullable: false),
VisibleFieldsJson = table.Column<string>(type: "text", nullable: false),
Collapsed = table.Column<bool>(type: "boolean", nullable: false),
Suggested = table.Column<bool>(type: "boolean", nullable: false),
RulesJson = table.Column<string>(type: "text", nullable: false),
Note = table.Column<string>(type: "text", nullable: false),
PolicyJson = table.Column<string>(type: "text", nullable: false),
SearchTsv = table.Column<NpgsqlTsVector>(type: "tsvector", nullable: false, computedColumnSql: "to_tsvector('russian', coalesce(\"Name\",'')||' '||coalesce(\"Description\",''))", stored: true),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Containers", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_Containers_SearchTsv",
table: "Containers",
column: "SearchTsv")
.Annotation("Npgsql:IndexMethod", "gin");
migrationBuilder.CreateIndex(
name: "IX_Containers_Space_Position",
table: "Containers",
columns: new[] { "Space", "Position" });
migrationBuilder.CreateIndex(
name: "IX_Containers_Suggested_Position",
table: "Containers",
columns: new[] { "Suggested", "Position" });
// Состав контейнеров по умолчанию НЕ сидируется миграцией: единственный источник —
// CardsDefaultContainers/CardIds, строки идемпотентно создаёт DefaultContainerProvisioner.EnsureAsync
// при провижининге тенанта (TenantProvisioningService) сразу после применения миграций.
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Containers");
}
}
}
@@ -1,823 +0,0 @@
// <auto-generated />
using System;
using Deal.Infrastructure.Persistence;
using Deal.Infrastructure.Persistence.Configurations;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using NpgsqlTypes;
#nullable disable
namespace Deal.Infrastructure.Migrations.TenantDb
{
[DbContext(typeof(TenantDbContext))]
[Migration("20260910132805_TenantUnifiedCard")]
partial class TenantUnifiedCard
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "10.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.BoardEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<bool>("Collapsed")
.HasColumnType("boolean");
b.Property<string>("Color")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<string>("KeywordsJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Note")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Position")
.HasColumnType("integer");
b.Property<string>("Prompt")
.IsRequired()
.HasColumnType("text");
b.Property<string>("RulesJson")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("Suggested")
.HasColumnType("boolean");
b.Property<string>("VisibleFieldsJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Width")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("Suggested", "Position");
b.ToTable("Boards", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.CardEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<DateTimeOffset?>("ArchivedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("BudgetCur")
.IsRequired()
.HasColumnType("text");
b.Property<double?>("BudgetFrom")
.HasColumnType("double precision");
b.Property<double?>("BudgetTo")
.HasColumnType("double precision");
b.Property<string>("ChannelHandle")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ChannelHue")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ChannelName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Col")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<string>("Contact")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ContactsJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ConvCur")
.IsRequired()
.HasColumnType("text");
b.Property<double?>("ConvFrom")
.HasColumnType("double precision");
b.Property<double?>("ConvTo")
.HasColumnType("double precision");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("FilesJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("HistoryJson")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsNew")
.HasColumnType("boolean");
b.Property<bool>("IsVacancy")
.HasColumnType("boolean");
b.Property<bool>("IsVacancyKnown")
.HasColumnType("boolean");
b.Property<string>("LinksJson")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("Local")
.HasColumnType("boolean");
b.Property<string>("MatchHitsJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PrevCol")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("ReceivedAt")
.HasColumnType("timestamp with time zone");
b.Property<DateTimeOffset?>("ReminderAt")
.HasColumnType("timestamp with time zone");
b.Property<bool>("ReminderFired")
.HasColumnType("boolean");
b.Property<NpgsqlTsVector>("SearchTsv")
.IsRequired()
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("tsvector")
.HasComputedColumnSql("to_tsvector('russian', coalesce(\"Title\",'')||' '||coalesce(\"Summary\",'')||' '||coalesce(\"SourceMsg\",'')||' '||coalesce(\"Contact\",''))", true);
b.Property<string>("SourceDialogId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("SourceMsg")
.IsRequired()
.HasColumnType("text");
b.Property<long?>("SourceMsgId")
.HasColumnType("bigint");
b.Property<string>("StackJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Summary")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<string>("TzText")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("SearchTsv");
NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("SearchTsv"), "gin");
b.HasIndex("UpdatedAt")
.IsDescending();
b.HasIndex("Col", "IsNew");
b.HasIndex("Col", "ReceivedAt")
.IsDescending(false, true);
b.ToTable("Cards", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.CardMoveEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("Action")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("FromCol")
.HasColumnType("text");
b.Property<string>("LeadId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ToCol")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("CardMoves", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.ContainerEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<bool>("Collapsed")
.HasColumnType("boolean");
b.Property<string>("Color")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<string>("KeywordsJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Kind")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Note")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PolicyJson")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Position")
.HasColumnType("integer");
b.Property<string>("RulesJson")
.IsRequired()
.HasColumnType("text");
b.Property<NpgsqlTsVector>("SearchTsv")
.IsRequired()
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("tsvector")
.HasComputedColumnSql("to_tsvector('russian', coalesce(\"Name\",'')||' '||coalesce(\"Description\",''))", true);
b.Property<string>("Space")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)");
b.Property<bool>("Suggested")
.HasColumnType("boolean");
b.Property<string>("VisibleFieldsJson")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("SearchTsv");
NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("SearchTsv"), "gin");
b.HasIndex("Space", "Position");
b.HasIndex("Suggested", "Position");
b.ToTable("Containers", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.DedupEntryEntity", b =>
{
b.Property<string>("Hash")
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("LeadId")
.HasColumnType("text");
b.HasKey("Hash");
b.ToTable("DedupEntries", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.DialogEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<bool>("Backfilled")
.HasColumnType("boolean");
b.Property<string>("Handle")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Hue")
.IsRequired()
.ValueGeneratedOnAdd()
.HasColumnType("text")
.HasDefaultValue("#666");
b.Property<string>("Kind")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset?>("LastAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("LastText")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("Monitor")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.ToTable("Dialogs", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.DiscBlacklistEntity", b =>
{
b.Property<string>("DialogId")
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Reason")
.IsRequired()
.HasColumnType("text");
b.HasKey("DialogId");
b.ToTable("DiscBlacklist", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.DiscCandidateEntity", b =>
{
b.Property<string>("DialogId")
.HasColumnType("text");
b.Property<bool>("AutoJoined")
.HasColumnType("boolean");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<double?>("FitRatio")
.HasColumnType("double precision");
b.Property<string>("Hue")
.IsRequired()
.HasColumnType("text");
b.Property<int>("JoinFailures")
.HasColumnType("integer");
b.Property<string>("Kind")
.IsRequired()
.HasColumnType("text");
b.Property<bool?>("LangRu")
.HasColumnType("boolean");
b.Property<string>("MarksJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int?>("Participants")
.HasColumnType("integer");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("text");
b.Property<string>("TaskId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("TopicsJson")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Username")
.IsRequired()
.HasColumnType("text");
b.HasKey("DialogId");
b.HasIndex("TaskId", "Status");
b.ToTable("DiscCandidates", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.DiscLogEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Event")
.IsRequired()
.HasColumnType("text");
b.Property<string>("TaskId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("TaskId", "CreatedAt");
b.ToTable("DiscLog", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.DiscTaskEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<bool>("AutoJoin")
.HasColumnType("boolean");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Evaluated")
.HasColumnType("integer");
b.Property<int>("Found")
.HasColumnType("integer");
b.Property<int>("Joined")
.HasColumnType("integer");
b.Property<string>("KeywordsJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Lang")
.IsRequired()
.HasColumnType("text");
b.Property<int>("MinSubscribers")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("PlanJoins")
.HasColumnType("integer");
b.Property<int>("Rejected")
.HasColumnType("integer");
b.Property<int>("SampleSize")
.HasColumnType("integer");
b.Property<bool>("SearchDone")
.HasColumnType("boolean");
b.Property<int>("SearchIdx")
.HasColumnType("integer");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Threshold")
.HasColumnType("integer");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.ToTable("DiscTasks", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.LeadCommentEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("By")
.IsRequired()
.HasColumnType("text");
b.Property<string>("CardId")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("CardId");
b.ToTable("LeadComments", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.MlOutboxEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<double>("Delta")
.HasColumnType("double precision");
b.Property<string>("Label")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("CreatedAt");
b.ToTable("MlOutbox", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.QueueItemEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("ChannelHandle")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ChannelHue")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ChannelName")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("DialogId")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("Force")
.HasColumnType("boolean");
b.Property<DateTimeOffset>("MsgAt")
.HasColumnType("timestamp with time zone");
b.Property<long?>("MsgId")
.HasColumnType("bigint");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("Status", "CreatedAt");
b.ToTable("QueueItems", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.RejectedItemEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("ChannelHandle")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ChannelHue")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ChannelName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("DialogId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Kw")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("MsgAt")
.HasColumnType("timestamp with time zone");
b.Property<long?>("MsgId")
.HasColumnType("bigint");
b.Property<string>("Reason")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("RejectedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("ReturnReason")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("Returned")
.HasColumnType("boolean");
b.Property<DateTimeOffset?>("ReturnedAt")
.HasColumnType("timestamp with time zone");
b.Property<NpgsqlTsVector>("SearchTsv")
.IsRequired()
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("tsvector")
.HasComputedColumnSql("to_tsvector('russian', coalesce(\"Text\",''))", true);
b.Property<string>("Source")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Stage")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("RejectedAt");
b.HasIndex("SearchTsv");
NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("SearchTsv"), "gin");
b.ToTable("RejectedItems", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.TenantSettingEntity", b =>
{
b.Property<string>("Key")
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("ValueJson")
.IsRequired()
.HasColumnType("text");
b.HasKey("Key");
b.ToTable("settings", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.TgMessageEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("DialogId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("LeadId")
.HasColumnType("text");
b.Property<DateTimeOffset>("MsgAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DialogId", "MsgAt");
b.ToTable("TgMessages", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.LeadCommentEntity", b =>
{
b.HasOne("Deal.Infrastructure.Persistence.Entities.CardEntity", null)
.WithMany()
.HasForeignKey("CardId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}
@@ -1,166 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Deal.Infrastructure.Migrations.TenantDb
{
/// <inheritdoc />
public partial class TenantUnifiedCard : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ProjectCards");
migrationBuilder.AddColumn<string>(
name: "FilesJson",
table: "Cards",
type: "text",
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<string>(
name: "HistoryJson",
table: "Cards",
type: "text",
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<string>(
name: "LinksJson",
table: "Cards",
type: "text",
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<bool>(
name: "Local",
table: "Cards",
type: "boolean",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<DateTimeOffset>(
name: "ReminderAt",
table: "Cards",
type: "timestamp with time zone",
nullable: true);
migrationBuilder.AddColumn<bool>(
name: "ReminderFired",
table: "Cards",
type: "boolean",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<string>(
name: "TzText",
table: "Cards",
type: "text",
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<DateTimeOffset>(
name: "UpdatedAt",
table: "Cards",
type: "timestamp with time zone",
nullable: false,
defaultValue: new DateTimeOffset(new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)));
migrationBuilder.CreateIndex(
name: "IX_Cards_UpdatedAt",
table: "Cards",
column: "UpdatedAt",
descending: new bool[0]);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_Cards_UpdatedAt",
table: "Cards");
migrationBuilder.DropColumn(
name: "FilesJson",
table: "Cards");
migrationBuilder.DropColumn(
name: "HistoryJson",
table: "Cards");
migrationBuilder.DropColumn(
name: "LinksJson",
table: "Cards");
migrationBuilder.DropColumn(
name: "Local",
table: "Cards");
migrationBuilder.DropColumn(
name: "ReminderAt",
table: "Cards");
migrationBuilder.DropColumn(
name: "ReminderFired",
table: "Cards");
migrationBuilder.DropColumn(
name: "TzText",
table: "Cards");
migrationBuilder.DropColumn(
name: "UpdatedAt",
table: "Cards");
migrationBuilder.CreateTable(
name: "ProjectCards",
columns: table => new
{
Id = table.Column<string>(type: "text", nullable: false),
BudgetCur = table.Column<string>(type: "text", nullable: false),
BudgetFrom = table.Column<double>(type: "double precision", nullable: true),
BudgetTo = table.Column<double>(type: "double precision", nullable: true),
CommentsJson = table.Column<string>(type: "text", nullable: false),
Contact = table.Column<string>(type: "text", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
FilesJson = table.Column<string>(type: "text", nullable: false),
HistoryJson = table.Column<string>(type: "text", nullable: false),
LeadId = table.Column<string>(type: "text", nullable: true),
LinksJson = table.Column<string>(type: "text", nullable: false),
Local = table.Column<bool>(type: "boolean", nullable: false),
ReminderAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
ReminderFired = table.Column<bool>(type: "boolean", nullable: false),
StackJson = table.Column<string>(type: "text", nullable: false),
Stage = table.Column<string>(type: "text", nullable: false),
Summary = table.Column<string>(type: "text", nullable: false),
Title = table.Column<string>(type: "text", nullable: false),
TzText = table.Column<string>(type: "text", nullable: false),
UpdatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ProjectCards", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_ProjectCards_LeadId",
table: "ProjectCards",
column: "LeadId",
unique: true,
filter: "\"LeadId\" IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_ProjectCards_Stage",
table: "ProjectCards",
column: "Stage");
migrationBuilder.CreateIndex(
name: "IX_ProjectCards_UpdatedAt",
table: "ProjectCards",
column: "UpdatedAt",
descending: new bool[0]);
}
}
}
@@ -1,763 +0,0 @@
// <auto-generated />
using System;
using Deal.Infrastructure.Persistence;
using Deal.Infrastructure.Persistence.Configurations;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using NpgsqlTypes;
#nullable disable
namespace Deal.Infrastructure.Migrations.TenantDb
{
[DbContext(typeof(TenantDbContext))]
[Migration("20260910134104_TenantContainerRegistry")]
partial class TenantContainerRegistry
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "10.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.CardEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<DateTimeOffset?>("ArchivedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("BudgetCur")
.IsRequired()
.HasColumnType("text");
b.Property<double?>("BudgetFrom")
.HasColumnType("double precision");
b.Property<double?>("BudgetTo")
.HasColumnType("double precision");
b.Property<string>("ChannelHandle")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ChannelHue")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ChannelName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Col")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<string>("Contact")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ContactsJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ConvCur")
.IsRequired()
.HasColumnType("text");
b.Property<double?>("ConvFrom")
.HasColumnType("double precision");
b.Property<double?>("ConvTo")
.HasColumnType("double precision");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("FilesJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("HistoryJson")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsNew")
.HasColumnType("boolean");
b.Property<bool>("IsVacancy")
.HasColumnType("boolean");
b.Property<bool>("IsVacancyKnown")
.HasColumnType("boolean");
b.Property<string>("LinksJson")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("Local")
.HasColumnType("boolean");
b.Property<string>("MatchHitsJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PrevCol")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("ReceivedAt")
.HasColumnType("timestamp with time zone");
b.Property<DateTimeOffset?>("ReminderAt")
.HasColumnType("timestamp with time zone");
b.Property<bool>("ReminderFired")
.HasColumnType("boolean");
b.Property<NpgsqlTsVector>("SearchTsv")
.IsRequired()
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("tsvector")
.HasComputedColumnSql("to_tsvector('russian', coalesce(\"Title\",'')||' '||coalesce(\"Summary\",'')||' '||coalesce(\"SourceMsg\",'')||' '||coalesce(\"Contact\",''))", true);
b.Property<string>("SourceDialogId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("SourceMsg")
.IsRequired()
.HasColumnType("text");
b.Property<long?>("SourceMsgId")
.HasColumnType("bigint");
b.Property<string>("StackJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Summary")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<string>("TzText")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("SearchTsv");
NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("SearchTsv"), "gin");
b.HasIndex("UpdatedAt")
.IsDescending();
b.HasIndex("Col", "IsNew");
b.HasIndex("Col", "ReceivedAt")
.IsDescending(false, true);
b.ToTable("Cards", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.CardMoveEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("Action")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("FromCol")
.HasColumnType("text");
b.Property<string>("LeadId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ToCol")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("CardMoves", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.ContainerEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<bool>("Collapsed")
.HasColumnType("boolean");
b.Property<string>("Color")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<string>("KeywordsJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Kind")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Note")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PolicyJson")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Position")
.HasColumnType("integer");
b.Property<string>("RulesJson")
.IsRequired()
.HasColumnType("text");
b.Property<NpgsqlTsVector>("SearchTsv")
.IsRequired()
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("tsvector")
.HasComputedColumnSql("to_tsvector('russian', coalesce(\"Name\",'')||' '||coalesce(\"Description\",''))", true);
b.Property<string>("Space")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)");
b.Property<bool>("Suggested")
.HasColumnType("boolean");
b.Property<string>("VisibleFieldsJson")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("SearchTsv");
NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("SearchTsv"), "gin");
b.HasIndex("Space", "Position");
b.HasIndex("Suggested", "Position");
b.ToTable("Containers", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.DedupEntryEntity", b =>
{
b.Property<string>("Hash")
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("LeadId")
.HasColumnType("text");
b.HasKey("Hash");
b.ToTable("DedupEntries", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.DialogEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<bool>("Backfilled")
.HasColumnType("boolean");
b.Property<string>("Handle")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Hue")
.IsRequired()
.ValueGeneratedOnAdd()
.HasColumnType("text")
.HasDefaultValue("#666");
b.Property<string>("Kind")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset?>("LastAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("LastText")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("Monitor")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.ToTable("Dialogs", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.DiscBlacklistEntity", b =>
{
b.Property<string>("DialogId")
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Reason")
.IsRequired()
.HasColumnType("text");
b.HasKey("DialogId");
b.ToTable("DiscBlacklist", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.DiscCandidateEntity", b =>
{
b.Property<string>("DialogId")
.HasColumnType("text");
b.Property<bool>("AutoJoined")
.HasColumnType("boolean");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<double?>("FitRatio")
.HasColumnType("double precision");
b.Property<string>("Hue")
.IsRequired()
.HasColumnType("text");
b.Property<int>("JoinFailures")
.HasColumnType("integer");
b.Property<string>("Kind")
.IsRequired()
.HasColumnType("text");
b.Property<bool?>("LangRu")
.HasColumnType("boolean");
b.Property<string>("MarksJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int?>("Participants")
.HasColumnType("integer");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("text");
b.Property<string>("TaskId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("TopicsJson")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Username")
.IsRequired()
.HasColumnType("text");
b.HasKey("DialogId");
b.HasIndex("TaskId", "Status");
b.ToTable("DiscCandidates", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.DiscLogEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Event")
.IsRequired()
.HasColumnType("text");
b.Property<string>("TaskId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("TaskId", "CreatedAt");
b.ToTable("DiscLog", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.DiscTaskEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<bool>("AutoJoin")
.HasColumnType("boolean");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Evaluated")
.HasColumnType("integer");
b.Property<int>("Found")
.HasColumnType("integer");
b.Property<int>("Joined")
.HasColumnType("integer");
b.Property<string>("KeywordsJson")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Lang")
.IsRequired()
.HasColumnType("text");
b.Property<int>("MinSubscribers")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("PlanJoins")
.HasColumnType("integer");
b.Property<int>("Rejected")
.HasColumnType("integer");
b.Property<int>("SampleSize")
.HasColumnType("integer");
b.Property<bool>("SearchDone")
.HasColumnType("boolean");
b.Property<int>("SearchIdx")
.HasColumnType("integer");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Threshold")
.HasColumnType("integer");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.ToTable("DiscTasks", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.LeadCommentEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("By")
.IsRequired()
.HasColumnType("text");
b.Property<string>("CardId")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("CardId");
b.ToTable("LeadComments", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.MlOutboxEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<double>("Delta")
.HasColumnType("double precision");
b.Property<string>("Label")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("CreatedAt");
b.ToTable("MlOutbox", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.QueueItemEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("ChannelHandle")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ChannelHue")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ChannelName")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("DialogId")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("Force")
.HasColumnType("boolean");
b.Property<DateTimeOffset>("MsgAt")
.HasColumnType("timestamp with time zone");
b.Property<long?>("MsgId")
.HasColumnType("bigint");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("Status", "CreatedAt");
b.ToTable("QueueItems", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.RejectedItemEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("ChannelHandle")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ChannelHue")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ChannelName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("DialogId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Kw")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("MsgAt")
.HasColumnType("timestamp with time zone");
b.Property<long?>("MsgId")
.HasColumnType("bigint");
b.Property<string>("Reason")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("RejectedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("ReturnReason")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("Returned")
.HasColumnType("boolean");
b.Property<DateTimeOffset?>("ReturnedAt")
.HasColumnType("timestamp with time zone");
b.Property<NpgsqlTsVector>("SearchTsv")
.IsRequired()
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("tsvector")
.HasComputedColumnSql("to_tsvector('russian', coalesce(\"Text\",''))", true);
b.Property<string>("Source")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Stage")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("RejectedAt");
b.HasIndex("SearchTsv");
NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("SearchTsv"), "gin");
b.ToTable("RejectedItems", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.TenantSettingEntity", b =>
{
b.Property<string>("Key")
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("ValueJson")
.IsRequired()
.HasColumnType("text");
b.HasKey("Key");
b.ToTable("settings", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.TgMessageEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("DialogId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("LeadId")
.HasColumnType("text");
b.Property<DateTimeOffset>("MsgAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DialogId", "MsgAt");
b.ToTable("TgMessages", (string)null);
});
modelBuilder.Entity("Deal.Infrastructure.Persistence.Entities.LeadCommentEntity", b =>
{
b.HasOne("Deal.Infrastructure.Persistence.Entities.CardEntity", null)
.WithMany()
.HasForeignKey("CardId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}
@@ -1,50 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Deal.Infrastructure.Migrations.TenantDb
{
/// <inheritdoc />
public partial class TenantContainerRegistry : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Boards");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Boards",
columns: table => new
{
Id = table.Column<string>(type: "text", nullable: false),
Collapsed = table.Column<bool>(type: "boolean", nullable: false),
Color = table.Column<string>(type: "text", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
Description = table.Column<string>(type: "text", nullable: false),
KeywordsJson = table.Column<string>(type: "text", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
Note = table.Column<string>(type: "text", nullable: false),
Position = table.Column<int>(type: "integer", nullable: false),
Prompt = table.Column<string>(type: "text", nullable: false),
RulesJson = table.Column<string>(type: "text", nullable: false),
Suggested = table.Column<bool>(type: "boolean", nullable: false),
VisibleFieldsJson = table.Column<string>(type: "text", nullable: false),
Width = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Boards", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_Boards_Suggested_Position",
table: "Boards",
columns: new[] { "Suggested", "Position" });
}
}
}
@@ -1,40 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Deal.Infrastructure.Migrations.TenantDb
{
/// <inheritdoc />
public partial class TenantContainerCleanup : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "KeywordsJson",
table: "Containers");
migrationBuilder.DropColumn(
name: "VisibleFieldsJson",
table: "Containers");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "KeywordsJson",
table: "Containers",
type: "text",
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<string>(
name: "VisibleFieldsJson",
table: "Containers",
type: "text",
nullable: false,
defaultValue: "");
}
}
}
@@ -12,6 +12,9 @@ public sealed class CardConfiguration : IEntityTypeConfiguration<CardEntity>
// Максимальная длина Col: служебные значения + id доски (короткие строки b_...).
private const int ColMaxLength = 200;
// Максимальная длина вида источника.
private const int SourceKindMaxLength = 64;
public void Configure(EntityTypeBuilder<CardEntity> builder)
{
builder.ToTable("Cards");
@@ -27,7 +30,12 @@ public sealed class CardConfiguration : IEntityTypeConfiguration<CardEntity>
builder.Property(x => x.LinksJson).HasColumnType("text");
builder.Property(x => x.FilesJson).HasColumnType("text");
builder.Property(x => x.HistoryJson).HasColumnType("text");
builder.Property(x => x.SourceMsg).HasColumnType("text");
builder.Property(x => x.SourceKind).HasMaxLength(SourceKindMaxLength);
builder.Property(x => x.SourceExternalId).HasColumnType("text");
builder.Property(x => x.SourceOriginRef).HasColumnType("text");
builder.Property(x => x.SourceJson).HasColumnType("text");
builder.Property(x => x.ContentJson).HasColumnType("text");
builder.Property(x => x.SourceText).HasColumnType("text");
// Выборка колонки сортируется по времени получения (received_at DESC); счётчик новых — по (col, is_new).
builder.HasIndex(x => new { x.Col, x.ReceivedAt }).IsDescending(false, true);
@@ -38,7 +46,7 @@ public sealed class CardConfiguration : IEntityTypeConfiguration<CardEntity>
builder.Property(x => x.SearchTsv)
.HasComputedColumnSql(
"to_tsvector('russian', coalesce(\"Title\",'')||' '||coalesce(\"Summary\",'')||' '||coalesce(\"SourceMsg\",'')||' '||coalesce(\"Contact\",''))",
"to_tsvector('russian', coalesce(\"Title\",'')||' '||coalesce(\"Summary\",'')||' '||coalesce(\"SourceText\",'')||' '||coalesce(\"Contact\",''))",
stored: true);
builder.HasIndex(x => x.SearchTsv).HasMethod("gin");
}
@@ -16,8 +16,14 @@ public sealed class QueueItemConfiguration : IEntityTypeConfiguration<QueueItemE
builder.HasKey(x => x.Id);
builder.Property(x => x.Text).HasColumnType("text");
builder.Property(x => x.SourceKey).HasColumnType("text");
builder.Property(x => x.SourceJson).HasColumnType("text");
builder.Property(x => x.ContentJson).HasColumnType("text");
// Выборка pump'а идёт по статусу и времени постановки (status='new', лимит 12).
builder.HasIndex(x => new { x.Status, x.CreatedAt });
// Дубль-гвард приёма ищет строку по ключу записи источника.
builder.HasIndex(x => x.SourceKey);
}
}
@@ -18,6 +18,9 @@ public sealed class RejectedItemConfiguration : IEntityTypeConfiguration<Rejecte
builder.Property(x => x.Text).HasColumnType("text");
builder.Property(x => x.Reason).HasColumnType("text");
builder.Property(x => x.Kw).HasColumnType("text");
builder.Property(x => x.SourceKey).HasColumnType("text");
builder.Property(x => x.SourceJson).HasColumnType("text");
builder.Property(x => x.ContentJson).HasColumnType("text");
builder.Property(x => x.SearchTsv)
.HasComputedColumnSql("to_tsvector('russian', coalesce(\"Text\",''))", stored: true);
@@ -92,40 +92,40 @@ public sealed class CardEntity
/// </summary>
public string ContactsJson { get; set; } = "[]";
/// <summary>
/// Имя канала/диалога-источника.
/// </summary>
public string ChannelName { get; set; } = string.Empty;
/// <summary>
/// Handle канала-источника.
/// </summary>
public string ChannelHandle { get; set; } = string.Empty;
/// <summary>
/// Цвет канала-источника
/// </summary>
public string ChannelHue { get; set; } = "#666";
/// <summary>
/// Время получения исходного сообщения
/// </summary>
public DateTimeOffset ReceivedAt { get; set; }
/// <summary>
/// Текст исходного сообщения
/// Вид источника
/// </summary>
public string SourceMsg { get; set; } = string.Empty;
public string SourceKind { get; set; } = string.Empty;
/// <summary>
/// Id диалога исходного сообщения
/// Идентификатор записи в источнике
/// </summary>
public string SourceDialogId { get; set; } = string.Empty;
public string SourceExternalId { get; set; } = string.Empty;
/// <summary>
/// Id исходного сообщения в Telegram, либо null.
/// Ссылка на оригинал в источнике
/// </summary>
public long? SourceMsgId { get; set; }
public string SourceOriginRef { get; set; } = string.Empty;
/// <summary>
/// Ссылка на источник, сериализованная в JSON
/// </summary>
public string SourceJson { get; set; } = string.Empty;
/// <summary>
/// Содержимое источника, сериализованное в JSON
/// </summary>
public string ContentJson { get; set; } = string.Empty;
/// <summary>
/// Текст источника для полнотекстового поиска
/// </summary>
public string SourceText { get; set; } = string.Empty;
/// <summary>
/// Предыдущая колонка
@@ -11,35 +11,25 @@ public sealed class QueueItemEntity
public string Id { get; set; } = string.Empty;
/// <summary>
/// Id диалога-источника
/// Ключ дедупликации записи источника
/// </summary>
public string DialogId { get; set; } = string.Empty;
public string SourceKey { get; set; } = string.Empty;
/// <summary>
/// Имя канала/диалога-источника.
/// Ссылка на источник, сериализованная в JSON
/// </summary>
public string ChannelName { get; set; } = string.Empty;
public string SourceJson { get; set; } = string.Empty;
/// <summary>
/// Handle канала-источника.
/// Содержимое источника, сериализованное в JSON
/// </summary>
public string ChannelHandle { get; set; } = string.Empty;
/// <summary>
/// Цвет канала-источника
/// </summary>
public string ChannelHue { get; set; } = "#666";
public string ContentJson { get; set; } = string.Empty;
/// <summary>
/// Текст сообщения
/// </summary>
public string Text { get; set; } = string.Empty;
/// <summary>
/// Id исходного сообщения в Telegram, либо null
/// </summary>
public long? MsgId { get; set; }
/// <summary>
/// Время получения исходного сообщения
/// </summary>
@@ -13,29 +13,19 @@ public sealed class RejectedItemEntity
public string Id { get; set; } = string.Empty;
/// <summary>
/// Id диалога-источника
/// Ключ дедупликации записи источника
/// </summary>
public string DialogId { get; set; } = string.Empty;
public string SourceKey { get; set; } = string.Empty;
/// <summary>
/// Id исходного сообщения в Telegram, либо null.
/// Ссылка на источник, сериализованная в JSON
/// </summary>
public long? MsgId { get; set; }
public string SourceJson { get; set; } = string.Empty;
/// <summary>
/// Имя канала/диалога-источника.
/// Содержимое источника, сериализованное в JSON
/// </summary>
public string ChannelName { get; set; } = string.Empty;
/// <summary>
/// Handle канала-источника.
/// </summary>
public string ChannelHandle { get; set; } = string.Empty;
/// <summary>
/// Цвет канала-источника
/// </summary>
public string ChannelHue { get; set; } = "#666";
public string ContentJson { get; set; } = string.Empty;
/// <summary>
/// Текст сообщения
@@ -0,0 +1,462 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using NpgsqlTypes;
#nullable disable
namespace Deal.Infrastructure.Persistence.Migrations.TenantDb
{
/// <inheritdoc />
public partial class InitialTenant : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "CardMoves",
columns: table => new
{
Id = table.Column<string>(type: "text", nullable: false),
LeadId = table.Column<string>(type: "text", nullable: false),
Action = table.Column<string>(type: "text", nullable: false),
FromCol = table.Column<string>(type: "text", nullable: true),
ToCol = table.Column<string>(type: "text", nullable: true),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CardMoves", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Cards",
columns: table => new
{
Id = table.Column<string>(type: "text", nullable: false),
Col = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: false),
IsNew = table.Column<bool>(type: "boolean", nullable: false),
Local = table.Column<bool>(type: "boolean", nullable: false),
IsVacancy = table.Column<bool>(type: "boolean", nullable: false),
IsVacancyKnown = table.Column<bool>(type: "boolean", nullable: false),
Title = table.Column<string>(type: "text", nullable: false),
Summary = table.Column<string>(type: "text", nullable: false),
StackJson = table.Column<string>(type: "text", nullable: false),
BudgetFrom = table.Column<double>(type: "double precision", nullable: true),
BudgetTo = table.Column<double>(type: "double precision", nullable: true),
BudgetCur = table.Column<string>(type: "text", nullable: false),
ConvFrom = table.Column<double>(type: "double precision", nullable: true),
ConvTo = table.Column<double>(type: "double precision", nullable: true),
ConvCur = table.Column<string>(type: "text", nullable: false),
Contact = table.Column<string>(type: "text", nullable: false),
ContactsJson = table.Column<string>(type: "text", nullable: false),
ReceivedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
SourceKind = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
SourceExternalId = table.Column<string>(type: "text", nullable: false),
SourceOriginRef = table.Column<string>(type: "text", nullable: false),
SourceJson = table.Column<string>(type: "text", nullable: false),
ContentJson = table.Column<string>(type: "text", nullable: false),
SourceText = table.Column<string>(type: "text", nullable: false),
PrevCol = table.Column<string>(type: "text", nullable: false),
ArchivedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
MatchHitsJson = table.Column<string>(type: "text", nullable: false),
LinksJson = table.Column<string>(type: "text", nullable: false),
FilesJson = table.Column<string>(type: "text", nullable: false),
HistoryJson = table.Column<string>(type: "text", nullable: false),
TzText = table.Column<string>(type: "text", nullable: false),
ReminderAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
ReminderFired = table.Column<bool>(type: "boolean", nullable: false),
SearchTsv = table.Column<NpgsqlTsVector>(type: "tsvector", nullable: false, computedColumnSql: "to_tsvector('russian', coalesce(\"Title\",'')||' '||coalesce(\"Summary\",'')||' '||coalesce(\"SourceText\",'')||' '||coalesce(\"Contact\",''))", stored: true),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
UpdatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Cards", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Containers",
columns: table => new
{
Id = table.Column<string>(type: "text", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
Description = table.Column<string>(type: "text", nullable: false),
Color = table.Column<string>(type: "text", nullable: false),
Position = table.Column<int>(type: "integer", nullable: false),
Kind = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
Space = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
Collapsed = table.Column<bool>(type: "boolean", nullable: false),
Suggested = table.Column<bool>(type: "boolean", nullable: false),
RulesJson = table.Column<string>(type: "text", nullable: false),
Note = table.Column<string>(type: "text", nullable: false),
PolicyJson = table.Column<string>(type: "text", nullable: false),
SearchTsv = table.Column<NpgsqlTsVector>(type: "tsvector", nullable: false, computedColumnSql: "to_tsvector('russian', coalesce(\"Name\",'')||' '||coalesce(\"Description\",''))", stored: true),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Containers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "DedupEntries",
columns: table => new
{
Hash = table.Column<string>(type: "text", nullable: false),
LeadId = table.Column<string>(type: "text", nullable: true),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_DedupEntries", x => x.Hash);
});
migrationBuilder.CreateTable(
name: "Dialogs",
columns: table => new
{
Id = table.Column<string>(type: "text", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
Handle = table.Column<string>(type: "text", nullable: false),
Kind = table.Column<string>(type: "text", nullable: false),
Hue = table.Column<string>(type: "text", nullable: false, defaultValue: "#666"),
Monitor = table.Column<bool>(type: "boolean", nullable: false),
LastText = table.Column<string>(type: "text", nullable: false),
LastAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
Backfilled = table.Column<bool>(type: "boolean", nullable: false),
UpdatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Dialogs", x => x.Id);
});
migrationBuilder.CreateTable(
name: "DiscBlacklist",
columns: table => new
{
DialogId = table.Column<string>(type: "text", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
Reason = table.Column<string>(type: "text", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_DiscBlacklist", x => x.DialogId);
});
migrationBuilder.CreateTable(
name: "DiscCandidates",
columns: table => new
{
DialogId = table.Column<string>(type: "text", nullable: false),
TaskId = table.Column<string>(type: "text", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
Username = table.Column<string>(type: "text", nullable: false),
Kind = table.Column<string>(type: "text", nullable: false),
Hue = table.Column<string>(type: "text", nullable: false),
Participants = table.Column<int>(type: "integer", nullable: true),
LangRu = table.Column<bool>(type: "boolean", nullable: true),
MarksJson = table.Column<string>(type: "text", nullable: false),
TopicsJson = table.Column<string>(type: "text", nullable: false),
FitRatio = table.Column<double>(type: "double precision", nullable: true),
Status = table.Column<string>(type: "text", nullable: false),
AutoJoined = table.Column<bool>(type: "boolean", nullable: false),
JoinFailures = table.Column<int>(type: "integer", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
UpdatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_DiscCandidates", x => x.DialogId);
});
migrationBuilder.CreateTable(
name: "DiscLog",
columns: table => new
{
Id = table.Column<string>(type: "text", nullable: false),
TaskId = table.Column<string>(type: "text", nullable: false),
Event = table.Column<string>(type: "text", nullable: false),
Text = table.Column<string>(type: "text", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_DiscLog", x => x.Id);
});
migrationBuilder.CreateTable(
name: "DiscTasks",
columns: table => new
{
Id = table.Column<string>(type: "text", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
Description = table.Column<string>(type: "text", nullable: false),
KeywordsJson = table.Column<string>(type: "text", nullable: false),
MinSubscribers = table.Column<int>(type: "integer", nullable: false),
Lang = table.Column<string>(type: "text", nullable: false),
Threshold = table.Column<int>(type: "integer", nullable: false),
SampleSize = table.Column<int>(type: "integer", nullable: false),
PlanJoins = table.Column<int>(type: "integer", nullable: false),
AutoJoin = table.Column<bool>(type: "boolean", nullable: false),
Status = table.Column<string>(type: "text", nullable: false),
SearchIdx = table.Column<int>(type: "integer", nullable: false),
SearchDone = table.Column<bool>(type: "boolean", nullable: false),
Found = table.Column<int>(type: "integer", nullable: false),
Evaluated = table.Column<int>(type: "integer", nullable: false),
Joined = table.Column<int>(type: "integer", nullable: false),
Rejected = table.Column<int>(type: "integer", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
UpdatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_DiscTasks", x => x.Id);
});
migrationBuilder.CreateTable(
name: "MlOutbox",
columns: table => new
{
Id = table.Column<string>(type: "text", nullable: false),
Text = table.Column<string>(type: "text", nullable: false),
Label = table.Column<string>(type: "text", nullable: false),
Delta = table.Column<double>(type: "double precision", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_MlOutbox", x => x.Id);
});
migrationBuilder.CreateTable(
name: "QueueItems",
columns: table => new
{
Id = table.Column<string>(type: "text", nullable: false),
SourceKey = table.Column<string>(type: "text", nullable: false),
SourceJson = table.Column<string>(type: "text", nullable: false),
ContentJson = table.Column<string>(type: "text", nullable: false),
Text = table.Column<string>(type: "text", nullable: false),
MsgAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
Status = table.Column<string>(type: "text", nullable: false),
Force = table.Column<bool>(type: "boolean", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
UpdatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_QueueItems", x => x.Id);
});
migrationBuilder.CreateTable(
name: "RejectedItems",
columns: table => new
{
Id = table.Column<string>(type: "text", nullable: false),
SourceKey = table.Column<string>(type: "text", nullable: false),
SourceJson = table.Column<string>(type: "text", nullable: false),
ContentJson = table.Column<string>(type: "text", nullable: false),
Text = table.Column<string>(type: "text", nullable: false),
Stage = table.Column<string>(type: "text", nullable: false),
Reason = table.Column<string>(type: "text", nullable: false),
Kw = table.Column<string>(type: "text", nullable: false),
Source = table.Column<string>(type: "text", nullable: false),
MsgAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
RejectedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
Returned = table.Column<bool>(type: "boolean", nullable: false),
ReturnedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
ReturnReason = table.Column<string>(type: "text", nullable: false),
SearchTsv = table.Column<NpgsqlTsVector>(type: "tsvector", nullable: false, computedColumnSql: "to_tsvector('russian', coalesce(\"Text\",''))", stored: true)
},
constraints: table =>
{
table.PrimaryKey("PK_RejectedItems", x => x.Id);
});
migrationBuilder.CreateTable(
name: "settings",
columns: table => new
{
Key = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: false),
ValueJson = table.Column<string>(type: "text", nullable: false),
UpdatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_settings", x => x.Key);
});
migrationBuilder.CreateTable(
name: "TgMessages",
columns: table => new
{
Id = table.Column<string>(type: "text", nullable: false),
DialogId = table.Column<string>(type: "text", nullable: false),
Text = table.Column<string>(type: "text", nullable: false),
MsgAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
LeadId = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_TgMessages", x => x.Id);
});
migrationBuilder.CreateTable(
name: "LeadComments",
columns: table => new
{
Id = table.Column<string>(type: "text", nullable: false),
CardId = table.Column<string>(type: "text", nullable: false),
By = table.Column<string>(type: "text", nullable: false),
Text = table.Column<string>(type: "text", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_LeadComments", x => x.Id);
table.ForeignKey(
name: "FK_LeadComments_Cards_CardId",
column: x => x.CardId,
principalTable: "Cards",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Cards_Col_IsNew",
table: "Cards",
columns: new[] { "Col", "IsNew" });
migrationBuilder.CreateIndex(
name: "IX_Cards_Col_ReceivedAt",
table: "Cards",
columns: new[] { "Col", "ReceivedAt" },
descending: new[] { false, true });
migrationBuilder.CreateIndex(
name: "IX_Cards_SearchTsv",
table: "Cards",
column: "SearchTsv")
.Annotation("Npgsql:IndexMethod", "gin");
migrationBuilder.CreateIndex(
name: "IX_Cards_UpdatedAt",
table: "Cards",
column: "UpdatedAt",
descending: new bool[0]);
migrationBuilder.CreateIndex(
name: "IX_Containers_SearchTsv",
table: "Containers",
column: "SearchTsv")
.Annotation("Npgsql:IndexMethod", "gin");
migrationBuilder.CreateIndex(
name: "IX_Containers_Space_Position",
table: "Containers",
columns: new[] { "Space", "Position" });
migrationBuilder.CreateIndex(
name: "IX_Containers_Suggested_Position",
table: "Containers",
columns: new[] { "Suggested", "Position" });
migrationBuilder.CreateIndex(
name: "IX_DiscCandidates_TaskId_Status",
table: "DiscCandidates",
columns: new[] { "TaskId", "Status" });
migrationBuilder.CreateIndex(
name: "IX_DiscLog_TaskId_CreatedAt",
table: "DiscLog",
columns: new[] { "TaskId", "CreatedAt" });
migrationBuilder.CreateIndex(
name: "IX_LeadComments_CardId",
table: "LeadComments",
column: "CardId");
migrationBuilder.CreateIndex(
name: "IX_MlOutbox_CreatedAt",
table: "MlOutbox",
column: "CreatedAt");
migrationBuilder.CreateIndex(
name: "IX_QueueItems_SourceKey",
table: "QueueItems",
column: "SourceKey");
migrationBuilder.CreateIndex(
name: "IX_QueueItems_Status_CreatedAt",
table: "QueueItems",
columns: new[] { "Status", "CreatedAt" });
migrationBuilder.CreateIndex(
name: "IX_RejectedItems_RejectedAt",
table: "RejectedItems",
column: "RejectedAt");
migrationBuilder.CreateIndex(
name: "IX_RejectedItems_SearchTsv",
table: "RejectedItems",
column: "SearchTsv")
.Annotation("Npgsql:IndexMethod", "gin");
migrationBuilder.CreateIndex(
name: "IX_TgMessages_DialogId_MsgAt",
table: "TgMessages",
columns: new[] { "DialogId", "MsgAt" });
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "CardMoves");
migrationBuilder.DropTable(
name: "Containers");
migrationBuilder.DropTable(
name: "DedupEntries");
migrationBuilder.DropTable(
name: "Dialogs");
migrationBuilder.DropTable(
name: "DiscBlacklist");
migrationBuilder.DropTable(
name: "DiscCandidates");
migrationBuilder.DropTable(
name: "DiscLog");
migrationBuilder.DropTable(
name: "DiscTasks");
migrationBuilder.DropTable(
name: "LeadComments");
migrationBuilder.DropTable(
name: "MlOutbox");
migrationBuilder.DropTable(
name: "QueueItems");
migrationBuilder.DropTable(
name: "RejectedItems");
migrationBuilder.DropTable(
name: "settings");
migrationBuilder.DropTable(
name: "TgMessages");
migrationBuilder.DropTable(
name: "Cards");
}
}
}
@@ -1,4 +1,5 @@
using Deal.Infrastructure.Persistence.Entities;
using Deal.Modules.Cards.Application.Sources;
using Deal.Modules.Kanban.Application.Models;
using Microsoft.EntityFrameworkCore;
@@ -49,7 +50,7 @@ public sealed partial class KanbanStore
AND ("SearchTsv" @@ plainto_tsquery('russian', {query})
OR lower("Title") LIKE {pattern}
OR lower("Summary") LIKE {pattern}
OR lower("SourceMsg") LIKE {pattern}
OR lower("SourceText") LIKE {pattern}
OR lower("Contact") LIKE {pattern})
ORDER BY ts_rank("SearchTsv", plainto_tsquery('russian', {query})) DESC, "ReceivedAt" DESC
LIMIT {limit}
@@ -76,18 +77,21 @@ public sealed partial class KanbanStore
/// <inheritdoc />
public async Task<CardDto?> GetCardBySourceAsync(
string dialogId,
long msgId,
SourceRef source,
CancellationToken ct)
{
if (string.IsNullOrEmpty(dialogId))
if (string.IsNullOrEmpty(source.Kind))
{
return null;
}
string externalId = source.ExternalId ?? string.Empty;
string originRef = source.OriginRef ?? string.Empty;
CardEntity? entity = await _dbContext.Cards
.AsNoTracking()
.Where(card => card.SourceDialogId == dialogId && card.SourceMsgId == msgId)
.Where(card => card.SourceKind == source.Kind
&& card.SourceExternalId == externalId
&& card.SourceOriginRef == originRef)
.OrderByDescending(card => card.ReceivedAt)
.FirstOrDefaultAsync(ct);
if (entity is null)
@@ -71,10 +71,10 @@ public sealed partial class KanbanStore
card => card.Id,
(move, card) => new { move, card })
.Where(joined => (joined.move.Action == MoveAction || joined.move.Action == RestoreAction)
&& joined.card.SourceMsg.Length > 0)
&& joined.card.SourceText.Length > 0)
.OrderByDescending(joined => joined.move.CreatedAt)
.Take(limit)
.Select(joined => new AiMarkupExampleDto(joined.card.SourceMsg, joined.move.ToCol!))
.Select(joined => new AiMarkupExampleDto(joined.card.SourceText, joined.move.ToCol!))
.ToListAsync(ct);
}
@@ -123,7 +123,7 @@ public sealed partial class KanbanStore
{
List<CardEntity> entities = await _dbContext.Cards
.AsNoTracking()
.Where(card => card.Col == CardIds.Inbox && card.SourceMsg != string.Empty)
.Where(card => card.Col == CardIds.Inbox && card.SourceText != string.Empty)
.OrderByDescending(card => card.ReceivedAt)
.ToListAsync(ct);
return entities.Select(card => ToCardDto(card, Array.Empty<CardCommentDto>())).ToList();
@@ -1,6 +1,7 @@
using System.Text.Json;
using Deal.Infrastructure.Persistence.Entities;
using Deal.Modules.Cards.Application.Models;
using Deal.Modules.Cards.Application.Sources;
using Deal.Modules.Kanban.Application.Abstractions;
using Deal.Modules.Kanban.Application.Models;
using Deal.Modules.Kanban.Application.Services;
@@ -120,11 +121,8 @@ public sealed partial class KanbanStore : ICardStore
IsVacancyKnown = entity.IsVacancyKnown,
Title = entity.Title,
Summary = entity.Summary,
Source = new CardSourceDto(
Kind: ResolveSourceKind(entity),
DisplayName: entity.ChannelName,
OriginRef: entity.SourceDialogId,
ReceivedAt: entity.ReceivedAt.ToUnixTimeMilliseconds()),
Source = FromJsonOr(entity.SourceJson, SourceRefs.Empty),
Content = FromJsonOr(entity.ContentJson, new SourceContent { Text = entity.SourceText }),
Stack = ToJsonList<string>(entity.StackJson),
Budget = entity.BudgetCur.Length == 0
? null
@@ -134,12 +132,8 @@ public sealed partial class KanbanStore : ICardStore
: new CardBudgetDto(entity.ConvFrom, entity.ConvTo, entity.ConvCur),
Contact = entity.Contact,
Contacts = ToJsonList<CardContactDto>(entity.ContactsJson),
Channel = new CardChannelDto(entity.ChannelName, entity.ChannelHandle, entity.ChannelHue),
Time = HumanAge(entity.ReceivedAt),
ReceivedAtMs = entity.ReceivedAt.ToUnixTimeMilliseconds(),
SourceMsg = entity.SourceMsg,
SourceDialogId = entity.SourceDialogId,
SourceMsgId = entity.SourceMsgId,
PrevCol = entity.PrevCol,
MatchHits = ToJsonList<MatchHitDto>(entity.MatchHitsJson),
Comments = comments,
@@ -152,17 +146,22 @@ public sealed partial class KanbanStore : ICardStore
UpdatedAtMs = entity.UpdatedAt.ToUnixTimeMilliseconds(),
};
// Вид источника карточки (производная проекция): local/telegram/other.
// entity: Строка карточки.
// Возвращает: Вид источника (строка wire-контракта).
private static string ResolveSourceKind(CardEntity entity)
// Разбирает одиночный JSON-объект; пустая/битая строка — запасное значение.
private static T FromJsonOr<T>(string json, T fallback)
{
if (entity.Local)
if (string.IsNullOrWhiteSpace(json))
{
return "local";
return fallback;
}
return entity.ChannelName.Length > 0 || entity.SourceDialogId.Length > 0 ? "telegram" : "other";
try
{
return JsonSerializer.Deserialize<T>(json, JsonOptions) ?? fallback;
}
catch (JsonException)
{
return fallback;
}
}
// Маппинг снимка (write-модель создания карточки) в строку Cards; CreatedAt — UTC-now.
@@ -185,13 +184,13 @@ public sealed partial class KanbanStore : ICardStore
ConvCur = snapshot.ConvCur,
Contact = snapshot.Contact,
ContactsJson = ToJson(snapshot.Contacts),
ChannelName = snapshot.ChannelName,
ChannelHandle = snapshot.ChannelHandle,
ChannelHue = snapshot.ChannelHue,
ReceivedAt = snapshot.ReceivedAt,
SourceMsg = snapshot.SourceMsg,
SourceDialogId = snapshot.SourceDialogId,
SourceMsgId = snapshot.SourceMsgId,
SourceKind = snapshot.Source.Kind,
SourceExternalId = snapshot.Source.ExternalId ?? string.Empty,
SourceOriginRef = snapshot.Source.OriginRef ?? string.Empty,
SourceJson = ToJson(snapshot.Source),
ContentJson = ToJson(snapshot.Content),
SourceText = snapshot.Content.Text ?? string.Empty,
PrevCol = snapshot.PrevCol,
ArchivedAt = snapshot.ArchivedAt,
MatchHitsJson = ToJson(snapshot.MatchHits),
@@ -1,4 +1,6 @@
using System.Text.Json;
using Deal.Infrastructure.Persistence.Entities;
using Deal.Modules.Cards.Application.Sources;
using Deal.Modules.Kanban.Application.Models;
using Deal.Modules.Pipeline.Application.Abstractions;
using Deal.Modules.Pipeline.Application.Models;
@@ -11,17 +13,21 @@ namespace Deal.Infrastructure.Persistence.Repositories;
/// </summary>
public sealed class PipelineStore(TenantDbContext dbContext) : IPipelineStore
{
// ── Очередь (QueueItems) ───────────────────────────────────────────────
private static readonly JsonSerializerOptions JsonOptions = new()
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
PropertyNameCaseInsensitive = true,
};
// ── Очередь (QueueItems) ───────────────────────────────────────
/// <inheritdoc />
public Task<bool> ExistsDuplicateAsync(
string dialogId,
long? msgId,
SourceRef source,
CancellationToken ct)
{
return msgId is null
? Task.FromResult(false)
: dbContext.QueueItems.AnyAsync(item => item.DialogId == dialogId && item.MsgId == msgId, ct);
string key = source.DedupeKey();
return dbContext.QueueItems.AnyAsync(item => item.SourceKey == key, ct);
}
/// <inheritdoc />
@@ -89,16 +95,19 @@ public sealed class PipelineStore(TenantDbContext dbContext) : IPipelineStore
string id = record.DeterministicId ?? PrefixId.New(PipelineIdPrefixes.Rejected);
DateTimeOffset rejectedAt = DateTimeOffset.UtcNow;
string sourceKey = record.Source.DedupeKey();
string sourceJson = ToJson(record.Source);
string contentJson = ToJson(record.Content);
await dbContext.Database.ExecuteSqlInterpolatedAsync(
$"""
INSERT INTO "RejectedItems" ("Id", "DialogId", "MsgId", "ChannelName", "ChannelHandle", "ChannelHue", "Text", "Stage", "Reason", "Kw", "Source", "MsgAt", "RejectedAt", "Returned", "ReturnReason")
VALUES ({id}, {record.DialogId}, {record.MsgId}, {record.ChannelName}, {record.ChannelHandle}, {record.ChannelHue}, {record.Text}, {record.Stage}, {record.Reason}, {record.Kw}, {record.Source}, {FromEpochMs(record.MsgAtMs)}, {rejectedAt}, false, {string.Empty})
INSERT INTO "RejectedItems" ("Id", "SourceKey", "SourceJson", "ContentJson", "Text", "Stage", "Reason", "Kw", "Source", "MsgAt", "RejectedAt", "Returned", "ReturnReason")
VALUES ({id}, {sourceKey}, {sourceJson}, {contentJson}, {record.Text}, {record.Stage}, {record.Reason}, {record.Kw}, {record.DecidedBy}, {FromEpochMs(record.MsgAtMs)}, {rejectedAt}, false, {string.Empty})
ON CONFLICT ("Id") DO UPDATE SET
"SourceKey" = excluded."SourceKey",
"SourceJson" = excluded."SourceJson",
"ContentJson" = excluded."ContentJson",
"Text" = excluded."Text",
"ChannelName" = excluded."ChannelName",
"ChannelHandle" = excluded."ChannelHandle",
"ChannelHue" = excluded."ChannelHue",
"Stage" = excluded."Stage",
"Reason" = excluded."Reason",
"Kw" = excluded."Kw",
@@ -156,8 +165,7 @@ public sealed class PipelineStore(TenantDbContext dbContext) : IPipelineStore
.AsNoTracking()
.Where(item => EF.Functions.Like(item.Text.ToLower(), pattern)
|| EF.Functions.Like(item.Reason.ToLower(), pattern)
|| EF.Functions.Like(item.Kw.ToLower(), pattern)
|| EF.Functions.Like(item.ChannelName.ToLower(), pattern))
|| EF.Functions.Like(item.Kw.ToLower(), pattern))
.OrderByDescending(item => item.RejectedAt)
.Take(limitLike)
.ToListAsync(ct);
@@ -274,11 +282,10 @@ public sealed class PipelineStore(TenantDbContext dbContext) : IPipelineStore
private static QueueItemDto ToQueueItemDto(QueueItemEntity entity) => new()
{
Id = entity.Id,
DialogId = entity.DialogId,
MsgId = entity.MsgId,
Source = FromJsonOr(entity.SourceJson, SourceRefs.Empty),
Content = FromJsonOr(entity.ContentJson, new SourceContent()),
Text = entity.Text,
Status = entity.Status,
Channel = new PipelineChannelDto(entity.ChannelName, entity.ChannelHandle, entity.ChannelHue),
MsgAtMs = entity.MsgAt.ToUnixTimeMilliseconds(),
QueuedAtMs = entity.CreatedAt.ToUnixTimeMilliseconds(),
Force = entity.Force,
@@ -291,13 +298,11 @@ public sealed class PipelineStore(TenantDbContext dbContext) : IPipelineStore
return new QueueItemEntity
{
Id = item.Id,
DialogId = item.DialogId,
MsgId = item.MsgId,
SourceKey = item.Source.DedupeKey(),
SourceJson = ToJson(item.Source),
ContentJson = ToJson(item.Content),
Text = item.Text,
Status = item.Status,
ChannelName = item.Channel.Name,
ChannelHandle = item.Channel.Handle,
ChannelHue = item.Channel.Hue,
MsgAt = FromEpochMs(item.MsgAtMs),
CreatedAt = queuedAt,
UpdatedAt = queuedAt,
@@ -308,16 +313,15 @@ public sealed class PipelineStore(TenantDbContext dbContext) : IPipelineStore
private static RejectedItemDto ToRejectedItemDto(RejectedItemEntity entity) => new()
{
Id = entity.Id,
DialogId = entity.DialogId,
MsgId = entity.MsgId,
Source = FromJsonOr(entity.SourceJson, SourceRefs.Empty),
Content = FromJsonOr(entity.ContentJson, new SourceContent()),
Text = entity.Text,
Stage = entity.Stage,
StageLabel = PipelineRejectConstants.StageLabel(entity.Stage),
Reason = entity.Reason,
Kw = entity.Kw,
Source = entity.Source,
SourceLabel = PipelineRejectConstants.SourceLabel(entity.Source),
Channel = new PipelineChannelDto(entity.ChannelName, entity.ChannelHandle, entity.ChannelHue),
DecidedBy = entity.Source,
DecidedByLabel = PipelineRejectConstants.SourceLabel(entity.Source),
MsgAtMs = entity.MsgAt.ToUnixTimeMilliseconds(),
RejectedAtMs = entity.RejectedAt.ToUnixTimeMilliseconds(),
Returned = entity.Returned,
@@ -327,4 +331,25 @@ public sealed class PipelineStore(TenantDbContext dbContext) : IPipelineStore
// epoch-ms → DateTimeOffset (UTC-момент для timestamptz-колонки).
private static DateTimeOffset FromEpochMs(long epochMs) => DateTimeOffset.FromUnixTimeMilliseconds(epochMs);
// Сериализует значение в JSON (camelCase, конвенция value_json).
private static string ToJson<T>(T value) => JsonSerializer.Serialize(value, JsonOptions);
// Разбирает одиночный JSON-объект; пустая/битая строка — запасное значение.
private static T FromJsonOr<T>(string json, T fallback)
{
if (string.IsNullOrWhiteSpace(json))
{
return fallback;
}
try
{
return JsonSerializer.Deserialize<T>(json, JsonOptions) ?? fallback;
}
catch (JsonException)
{
return fallback;
}
}
}