fix(backend): add missing domain foreign keys
This commit is contained in:
2173
backend/src/Socialize.Api/Migrations/20260507185052_AddMissingDomainForeignKeys.Designer.cs
generated
Normal file
2173
backend/src/Socialize.Api/Migrations/20260507185052_AddMissingDomainForeignKeys.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,405 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Socialize.Api.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
internal partial class AddMissingDomainForeignKeys : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_FeedbackReports_CampaignId",
|
||||||
|
table: "FeedbackReports",
|
||||||
|
column: "CampaignId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_FeedbackReports_ClientId",
|
||||||
|
table: "FeedbackReports",
|
||||||
|
column: "ClientId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_FeedbackReports_ContentItemId",
|
||||||
|
table: "FeedbackReports",
|
||||||
|
column: "ContentItemId");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_ApprovalDecisions_ApprovalRequests_ApprovalRequestId",
|
||||||
|
table: "ApprovalDecisions",
|
||||||
|
column: "ApprovalRequestId",
|
||||||
|
principalTable: "ApprovalRequests",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_ApprovalRequests_ApprovalWorkflowInstances_WorkflowInstance~",
|
||||||
|
table: "ApprovalRequests",
|
||||||
|
column: "WorkflowInstanceId",
|
||||||
|
principalTable: "ApprovalWorkflowInstances",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_ApprovalRequests_ContentItems_ContentItemId",
|
||||||
|
table: "ApprovalRequests",
|
||||||
|
column: "ContentItemId",
|
||||||
|
principalTable: "ContentItems",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_ApprovalRequests_Workspaces_WorkspaceId",
|
||||||
|
table: "ApprovalRequests",
|
||||||
|
column: "WorkspaceId",
|
||||||
|
principalTable: "Workspaces",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_ApprovalWorkflowInstances_ContentItems_ContentItemId",
|
||||||
|
table: "ApprovalWorkflowInstances",
|
||||||
|
column: "ContentItemId",
|
||||||
|
principalTable: "ContentItems",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_ApprovalWorkflowInstances_Workspaces_WorkspaceId",
|
||||||
|
table: "ApprovalWorkflowInstances",
|
||||||
|
column: "WorkspaceId",
|
||||||
|
principalTable: "Workspaces",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_AssetRevisions_Assets_AssetId",
|
||||||
|
table: "AssetRevisions",
|
||||||
|
column: "AssetId",
|
||||||
|
principalTable: "Assets",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Assets_ContentItems_ContentItemId",
|
||||||
|
table: "Assets",
|
||||||
|
column: "ContentItemId",
|
||||||
|
principalTable: "ContentItems",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Assets_Workspaces_WorkspaceId",
|
||||||
|
table: "Assets",
|
||||||
|
column: "WorkspaceId",
|
||||||
|
principalTable: "Workspaces",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Campaigns_Clients_ClientId",
|
||||||
|
table: "Campaigns",
|
||||||
|
column: "ClientId",
|
||||||
|
principalTable: "Clients",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Campaigns_Workspaces_WorkspaceId",
|
||||||
|
table: "Campaigns",
|
||||||
|
column: "WorkspaceId",
|
||||||
|
principalTable: "Workspaces",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Channels_Workspaces_WorkspaceId",
|
||||||
|
table: "Channels",
|
||||||
|
column: "WorkspaceId",
|
||||||
|
principalTable: "Workspaces",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Clients_Workspaces_WorkspaceId",
|
||||||
|
table: "Clients",
|
||||||
|
column: "WorkspaceId",
|
||||||
|
principalTable: "Workspaces",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Comments_Comments_ParentCommentId",
|
||||||
|
table: "Comments",
|
||||||
|
column: "ParentCommentId",
|
||||||
|
principalTable: "Comments",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Comments_ContentItems_ContentItemId",
|
||||||
|
table: "Comments",
|
||||||
|
column: "ContentItemId",
|
||||||
|
principalTable: "ContentItems",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Comments_Workspaces_WorkspaceId",
|
||||||
|
table: "Comments",
|
||||||
|
column: "WorkspaceId",
|
||||||
|
principalTable: "Workspaces",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_ContentItemActivityEntries_ContentItems_ContentItemId",
|
||||||
|
table: "ContentItemActivityEntries",
|
||||||
|
column: "ContentItemId",
|
||||||
|
principalTable: "ContentItems",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_ContentItemActivityEntries_Workspaces_WorkspaceId",
|
||||||
|
table: "ContentItemActivityEntries",
|
||||||
|
column: "WorkspaceId",
|
||||||
|
principalTable: "Workspaces",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_ContentItemRevisions_ContentItems_ContentItemId",
|
||||||
|
table: "ContentItemRevisions",
|
||||||
|
column: "ContentItemId",
|
||||||
|
principalTable: "ContentItems",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_ContentItems_Campaigns_CampaignId",
|
||||||
|
table: "ContentItems",
|
||||||
|
column: "CampaignId",
|
||||||
|
principalTable: "Campaigns",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_ContentItems_Clients_ClientId",
|
||||||
|
table: "ContentItems",
|
||||||
|
column: "ClientId",
|
||||||
|
principalTable: "Clients",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_ContentItems_Workspaces_WorkspaceId",
|
||||||
|
table: "ContentItems",
|
||||||
|
column: "WorkspaceId",
|
||||||
|
principalTable: "Workspaces",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_FeedbackReports_Campaigns_CampaignId",
|
||||||
|
table: "FeedbackReports",
|
||||||
|
column: "CampaignId",
|
||||||
|
principalTable: "Campaigns",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.SetNull);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_FeedbackReports_Clients_ClientId",
|
||||||
|
table: "FeedbackReports",
|
||||||
|
column: "ClientId",
|
||||||
|
principalTable: "Clients",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.SetNull);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_FeedbackReports_ContentItems_ContentItemId",
|
||||||
|
table: "FeedbackReports",
|
||||||
|
column: "ContentItemId",
|
||||||
|
principalTable: "ContentItems",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.SetNull);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_FeedbackReports_Workspaces_WorkspaceId",
|
||||||
|
table: "FeedbackReports",
|
||||||
|
column: "WorkspaceId",
|
||||||
|
principalTable: "Workspaces",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.SetNull);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_NotificationEvents_ContentItems_ContentItemId",
|
||||||
|
table: "NotificationEvents",
|
||||||
|
column: "ContentItemId",
|
||||||
|
principalTable: "ContentItems",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.SetNull);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_NotificationEvents_Workspaces_WorkspaceId",
|
||||||
|
table: "NotificationEvents",
|
||||||
|
column: "WorkspaceId",
|
||||||
|
principalTable: "Workspaces",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_WorkspaceApprovalStepConfigurations_Workspaces_WorkspaceId",
|
||||||
|
table: "WorkspaceApprovalStepConfigurations",
|
||||||
|
column: "WorkspaceId",
|
||||||
|
principalTable: "Workspaces",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_WorkspaceInvites_Workspaces_WorkspaceId",
|
||||||
|
table: "WorkspaceInvites",
|
||||||
|
column: "WorkspaceId",
|
||||||
|
principalTable: "Workspaces",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_ApprovalDecisions_ApprovalRequests_ApprovalRequestId",
|
||||||
|
table: "ApprovalDecisions");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_ApprovalRequests_ApprovalWorkflowInstances_WorkflowInstance~",
|
||||||
|
table: "ApprovalRequests");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_ApprovalRequests_ContentItems_ContentItemId",
|
||||||
|
table: "ApprovalRequests");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_ApprovalRequests_Workspaces_WorkspaceId",
|
||||||
|
table: "ApprovalRequests");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_ApprovalWorkflowInstances_ContentItems_ContentItemId",
|
||||||
|
table: "ApprovalWorkflowInstances");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_ApprovalWorkflowInstances_Workspaces_WorkspaceId",
|
||||||
|
table: "ApprovalWorkflowInstances");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_AssetRevisions_Assets_AssetId",
|
||||||
|
table: "AssetRevisions");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Assets_ContentItems_ContentItemId",
|
||||||
|
table: "Assets");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Assets_Workspaces_WorkspaceId",
|
||||||
|
table: "Assets");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Campaigns_Clients_ClientId",
|
||||||
|
table: "Campaigns");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Campaigns_Workspaces_WorkspaceId",
|
||||||
|
table: "Campaigns");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Channels_Workspaces_WorkspaceId",
|
||||||
|
table: "Channels");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Clients_Workspaces_WorkspaceId",
|
||||||
|
table: "Clients");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Comments_Comments_ParentCommentId",
|
||||||
|
table: "Comments");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Comments_ContentItems_ContentItemId",
|
||||||
|
table: "Comments");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Comments_Workspaces_WorkspaceId",
|
||||||
|
table: "Comments");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_ContentItemActivityEntries_ContentItems_ContentItemId",
|
||||||
|
table: "ContentItemActivityEntries");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_ContentItemActivityEntries_Workspaces_WorkspaceId",
|
||||||
|
table: "ContentItemActivityEntries");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_ContentItemRevisions_ContentItems_ContentItemId",
|
||||||
|
table: "ContentItemRevisions");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_ContentItems_Campaigns_CampaignId",
|
||||||
|
table: "ContentItems");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_ContentItems_Clients_ClientId",
|
||||||
|
table: "ContentItems");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_ContentItems_Workspaces_WorkspaceId",
|
||||||
|
table: "ContentItems");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_FeedbackReports_Campaigns_CampaignId",
|
||||||
|
table: "FeedbackReports");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_FeedbackReports_Clients_ClientId",
|
||||||
|
table: "FeedbackReports");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_FeedbackReports_ContentItems_ContentItemId",
|
||||||
|
table: "FeedbackReports");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_FeedbackReports_Workspaces_WorkspaceId",
|
||||||
|
table: "FeedbackReports");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_NotificationEvents_ContentItems_ContentItemId",
|
||||||
|
table: "NotificationEvents");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_NotificationEvents_Workspaces_WorkspaceId",
|
||||||
|
table: "NotificationEvents");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_WorkspaceApprovalStepConfigurations_Workspaces_WorkspaceId",
|
||||||
|
table: "WorkspaceApprovalStepConfigurations");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_WorkspaceInvites_Workspaces_WorkspaceId",
|
||||||
|
table: "WorkspaceInvites");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_FeedbackReports_CampaignId",
|
||||||
|
table: "FeedbackReports");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_FeedbackReports_ClientId",
|
||||||
|
table: "FeedbackReports");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_FeedbackReports_ContentItemId",
|
||||||
|
table: "FeedbackReports");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1359,6 +1359,12 @@ namespace Socialize.Api.Migrations
|
|||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("CampaignId");
|
||||||
|
|
||||||
|
b.HasIndex("ClientId");
|
||||||
|
|
||||||
|
b.HasIndex("ContentItemId");
|
||||||
|
|
||||||
b.HasIndex("LastActivityAt");
|
b.HasIndex("LastActivityAt");
|
||||||
|
|
||||||
b.HasIndex("ReporterUserId");
|
b.HasIndex("ReporterUserId");
|
||||||
@@ -1856,6 +1862,83 @@ namespace Socialize.Api.Migrations
|
|||||||
.IsRequired();
|
.IsRequired();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Socialize.Api.Modules.Approvals.Data.ApprovalDecision", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Socialize.Api.Modules.Approvals.Data.ApprovalRequest", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ApprovalRequestId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Socialize.Api.Modules.Approvals.Data.ApprovalRequest", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Socialize.Api.Modules.ContentItems.Data.ContentItem", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ContentItemId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("Socialize.Api.Modules.Approvals.Data.ApprovalWorkflowInstance", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("WorkflowInstanceId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
|
|
||||||
|
b.HasOne("Socialize.Api.Modules.Workspaces.Data.Workspace", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("WorkspaceId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Socialize.Api.Modules.Approvals.Data.ApprovalWorkflowInstance", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Socialize.Api.Modules.ContentItems.Data.ContentItem", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ContentItemId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("Socialize.Api.Modules.Workspaces.Data.Workspace", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("WorkspaceId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Socialize.Api.Modules.Approvals.Data.WorkspaceApprovalStepConfiguration", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Socialize.Api.Modules.Workspaces.Data.Workspace", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("WorkspaceId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Socialize.Api.Modules.Assets.Data.Asset", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Socialize.Api.Modules.ContentItems.Data.ContentItem", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ContentItemId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("Socialize.Api.Modules.Workspaces.Data.Workspace", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("WorkspaceId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Socialize.Api.Modules.Assets.Data.AssetRevision", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Socialize.Api.Modules.Assets.Data.Asset", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("AssetId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Socialize.Api.Modules.CalendarIntegrations.Data.CalendarEvent", b =>
|
modelBuilder.Entity("Socialize.Api.Modules.CalendarIntegrations.Data.CalendarEvent", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("Socialize.Api.Modules.CalendarIntegrations.Data.CalendarSource", null)
|
b.HasOne("Socialize.Api.Modules.CalendarIntegrations.Data.CalendarSource", null)
|
||||||
@@ -1865,6 +1948,104 @@ namespace Socialize.Api.Migrations
|
|||||||
.IsRequired();
|
.IsRequired();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Socialize.Api.Modules.Campaigns.Data.Campaign", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Socialize.Api.Modules.Clients.Data.Client", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ClientId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("Socialize.Api.Modules.Workspaces.Data.Workspace", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("WorkspaceId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Socialize.Api.Modules.Channels.Data.Channel", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Socialize.Api.Modules.Workspaces.Data.Workspace", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("WorkspaceId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Socialize.Api.Modules.Clients.Data.Client", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Socialize.Api.Modules.Workspaces.Data.Workspace", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("WorkspaceId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Socialize.Api.Modules.Comments.Data.Comment", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Socialize.Api.Modules.ContentItems.Data.ContentItem", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ContentItemId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("Socialize.Api.Modules.Comments.Data.Comment", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ParentCommentId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
|
|
||||||
|
b.HasOne("Socialize.Api.Modules.Workspaces.Data.Workspace", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("WorkspaceId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Socialize.Api.Modules.ContentItems.Data.ContentItem", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Socialize.Api.Modules.Campaigns.Data.Campaign", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("CampaignId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("Socialize.Api.Modules.Clients.Data.Client", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ClientId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("Socialize.Api.Modules.Workspaces.Data.Workspace", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("WorkspaceId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Socialize.Api.Modules.ContentItems.Data.ContentItemActivityEntry", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Socialize.Api.Modules.ContentItems.Data.ContentItem", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ContentItemId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("Socialize.Api.Modules.Workspaces.Data.Workspace", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("WorkspaceId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Socialize.Api.Modules.ContentItems.Data.ContentItemRevision", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Socialize.Api.Modules.ContentItems.Data.ContentItem", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ContentItemId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Socialize.Api.Modules.Feedback.Data.FeedbackActivityEntry", b =>
|
modelBuilder.Entity("Socialize.Api.Modules.Feedback.Data.FeedbackActivityEntry", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("Socialize.Api.Modules.Feedback.Data.FeedbackReport", "FeedbackReport")
|
b.HasOne("Socialize.Api.Modules.Feedback.Data.FeedbackReport", "FeedbackReport")
|
||||||
@@ -1887,6 +2068,29 @@ namespace Socialize.Api.Migrations
|
|||||||
b.Navigation("FeedbackReport");
|
b.Navigation("FeedbackReport");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Socialize.Api.Modules.Feedback.Data.FeedbackReport", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Socialize.Api.Modules.Campaigns.Data.Campaign", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("CampaignId")
|
||||||
|
.OnDelete(DeleteBehavior.SetNull);
|
||||||
|
|
||||||
|
b.HasOne("Socialize.Api.Modules.Clients.Data.Client", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ClientId")
|
||||||
|
.OnDelete(DeleteBehavior.SetNull);
|
||||||
|
|
||||||
|
b.HasOne("Socialize.Api.Modules.ContentItems.Data.ContentItem", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ContentItemId")
|
||||||
|
.OnDelete(DeleteBehavior.SetNull);
|
||||||
|
|
||||||
|
b.HasOne("Socialize.Api.Modules.Workspaces.Data.Workspace", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("WorkspaceId")
|
||||||
|
.OnDelete(DeleteBehavior.SetNull);
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Socialize.Api.Modules.Feedback.Data.FeedbackScreenshot", b =>
|
modelBuilder.Entity("Socialize.Api.Modules.Feedback.Data.FeedbackScreenshot", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("Socialize.Api.Modules.Feedback.Data.FeedbackReport", "FeedbackReport")
|
b.HasOne("Socialize.Api.Modules.Feedback.Data.FeedbackReport", "FeedbackReport")
|
||||||
@@ -1909,6 +2113,20 @@ namespace Socialize.Api.Migrations
|
|||||||
b.Navigation("FeedbackReport");
|
b.Navigation("FeedbackReport");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Socialize.Api.Modules.Notifications.Data.NotificationEvent", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Socialize.Api.Modules.ContentItems.Data.ContentItem", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ContentItemId")
|
||||||
|
.OnDelete(DeleteBehavior.SetNull);
|
||||||
|
|
||||||
|
b.HasOne("Socialize.Api.Modules.Workspaces.Data.Workspace", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("WorkspaceId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Socialize.Api.Modules.Organizations.Data.OrganizationMembership", b =>
|
modelBuilder.Entity("Socialize.Api.Modules.Organizations.Data.OrganizationMembership", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("Socialize.Api.Modules.Organizations.Data.Organization", null)
|
b.HasOne("Socialize.Api.Modules.Organizations.Data.Organization", null)
|
||||||
@@ -1927,6 +2145,15 @@ namespace Socialize.Api.Migrations
|
|||||||
.IsRequired();
|
.IsRequired();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Socialize.Api.Modules.Workspaces.Data.WorkspaceInvite", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Socialize.Api.Modules.Workspaces.Data.Workspace", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("WorkspaceId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Socialize.Api.Modules.Feedback.Data.FeedbackReport", b =>
|
modelBuilder.Entity("Socialize.Api.Modules.Feedback.Data.FeedbackReport", b =>
|
||||||
{
|
{
|
||||||
b.Navigation("ActivityEntries");
|
b.Navigation("ActivityEntries");
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Socialize.Api.Modules.ContentItems.Data;
|
||||||
|
using Socialize.Api.Modules.Workspaces.Data;
|
||||||
|
|
||||||
namespace Socialize.Api.Modules.Approvals.Data;
|
namespace Socialize.Api.Modules.Approvals.Data;
|
||||||
|
|
||||||
@@ -20,6 +22,14 @@ internal static class ApprovalModelConfiguration
|
|||||||
workflowInstance.HasIndex(x => new { x.ContentItemId, x.State })
|
workflowInstance.HasIndex(x => new { x.ContentItemId, x.State })
|
||||||
.IsUnique()
|
.IsUnique()
|
||||||
.HasFilter("\"State\" = 'Pending'");
|
.HasFilter("\"State\" = 'Pending'");
|
||||||
|
workflowInstance.HasOne<Workspace>()
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(x => x.WorkspaceId)
|
||||||
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
|
workflowInstance.HasOne<ContentItem>()
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(x => x.ContentItemId)
|
||||||
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity<ApprovalRequest>(approvalRequest =>
|
modelBuilder.Entity<ApprovalRequest>(approvalRequest =>
|
||||||
@@ -40,6 +50,18 @@ internal static class ApprovalModelConfiguration
|
|||||||
approvalRequest.HasIndex(x => x.ContentItemId);
|
approvalRequest.HasIndex(x => x.ContentItemId);
|
||||||
approvalRequest.HasIndex(x => x.WorkflowInstanceId);
|
approvalRequest.HasIndex(x => x.WorkflowInstanceId);
|
||||||
approvalRequest.HasIndex(x => x.ReviewerEmail);
|
approvalRequest.HasIndex(x => x.ReviewerEmail);
|
||||||
|
approvalRequest.HasOne<Workspace>()
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(x => x.WorkspaceId)
|
||||||
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
|
approvalRequest.HasOne<ContentItem>()
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(x => x.ContentItemId)
|
||||||
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
|
approvalRequest.HasOne<ApprovalWorkflowInstance>()
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(x => x.WorkflowInstanceId)
|
||||||
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity<ApprovalDecision>(approvalDecision =>
|
modelBuilder.Entity<ApprovalDecision>(approvalDecision =>
|
||||||
@@ -54,6 +76,10 @@ internal static class ApprovalModelConfiguration
|
|||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasDefaultValueSql("CURRENT_TIMESTAMP");
|
.HasDefaultValueSql("CURRENT_TIMESTAMP");
|
||||||
approvalDecision.HasIndex(x => x.ApprovalRequestId);
|
approvalDecision.HasIndex(x => x.ApprovalRequestId);
|
||||||
|
approvalDecision.HasOne<ApprovalRequest>()
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(x => x.ApprovalRequestId)
|
||||||
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity<WorkspaceApprovalStepConfiguration>(approvalStep =>
|
modelBuilder.Entity<WorkspaceApprovalStepConfiguration>(approvalStep =>
|
||||||
@@ -69,6 +95,10 @@ internal static class ApprovalModelConfiguration
|
|||||||
.HasDefaultValueSql("CURRENT_TIMESTAMP");
|
.HasDefaultValueSql("CURRENT_TIMESTAMP");
|
||||||
approvalStep.HasIndex(x => x.WorkspaceId);
|
approvalStep.HasIndex(x => x.WorkspaceId);
|
||||||
approvalStep.HasIndex(x => new { x.WorkspaceId, x.SortOrder }).IsUnique();
|
approvalStep.HasIndex(x => new { x.WorkspaceId, x.SortOrder }).IsUnique();
|
||||||
|
approvalStep.HasOne<Workspace>()
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(x => x.WorkspaceId)
|
||||||
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
});
|
});
|
||||||
|
|
||||||
return modelBuilder;
|
return modelBuilder;
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Socialize.Api.Modules.ContentItems.Data;
|
||||||
|
using Socialize.Api.Modules.Workspaces.Data;
|
||||||
|
|
||||||
namespace Socialize.Api.Modules.Assets.Data;
|
namespace Socialize.Api.Modules.Assets.Data;
|
||||||
|
|
||||||
@@ -21,6 +23,14 @@ internal static class AssetModelConfiguration
|
|||||||
.HasDefaultValueSql("CURRENT_TIMESTAMP");
|
.HasDefaultValueSql("CURRENT_TIMESTAMP");
|
||||||
asset.HasIndex(x => x.WorkspaceId);
|
asset.HasIndex(x => x.WorkspaceId);
|
||||||
asset.HasIndex(x => x.ContentItemId);
|
asset.HasIndex(x => x.ContentItemId);
|
||||||
|
asset.HasOne<Workspace>()
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(x => x.WorkspaceId)
|
||||||
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
|
asset.HasOne<ContentItem>()
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(x => x.ContentItemId)
|
||||||
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity<AssetRevision>(revision =>
|
modelBuilder.Entity<AssetRevision>(revision =>
|
||||||
@@ -35,6 +45,10 @@ internal static class AssetModelConfiguration
|
|||||||
.HasDefaultValueSql("CURRENT_TIMESTAMP");
|
.HasDefaultValueSql("CURRENT_TIMESTAMP");
|
||||||
revision.HasIndex(x => x.AssetId);
|
revision.HasIndex(x => x.AssetId);
|
||||||
revision.HasIndex(x => new { x.AssetId, x.RevisionNumber }).IsUnique();
|
revision.HasIndex(x => new { x.AssetId, x.RevisionNumber }).IsUnique();
|
||||||
|
revision.HasOne<Asset>()
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(x => x.AssetId)
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
});
|
});
|
||||||
|
|
||||||
return modelBuilder;
|
return modelBuilder;
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Socialize.Api.Modules.Clients.Data;
|
||||||
|
using Socialize.Api.Modules.Workspaces.Data;
|
||||||
|
|
||||||
namespace Socialize.Api.Modules.Campaigns.Data;
|
namespace Socialize.Api.Modules.Campaigns.Data;
|
||||||
|
|
||||||
@@ -20,6 +22,14 @@ internal static class CampaignModelConfiguration
|
|||||||
campaign.HasIndex(x => new { x.ClientId, x.Name }).IsUnique();
|
campaign.HasIndex(x => new { x.ClientId, x.Name }).IsUnique();
|
||||||
campaign.HasIndex(x => x.WorkspaceId);
|
campaign.HasIndex(x => x.WorkspaceId);
|
||||||
campaign.HasIndex(x => x.ClientId);
|
campaign.HasIndex(x => x.ClientId);
|
||||||
|
campaign.HasOne<Workspace>()
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(x => x.WorkspaceId)
|
||||||
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
|
campaign.HasOne<Client>()
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(x => x.ClientId)
|
||||||
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
});
|
});
|
||||||
|
|
||||||
return modelBuilder;
|
return modelBuilder;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Socialize.Api.Modules.Workspaces.Data;
|
||||||
|
|
||||||
namespace Socialize.Api.Modules.Channels.Data;
|
namespace Socialize.Api.Modules.Channels.Data;
|
||||||
|
|
||||||
@@ -19,6 +20,10 @@ internal static class ChannelModelConfiguration
|
|||||||
.HasDefaultValueSql("CURRENT_TIMESTAMP");
|
.HasDefaultValueSql("CURRENT_TIMESTAMP");
|
||||||
channel.HasIndex(x => x.WorkspaceId);
|
channel.HasIndex(x => x.WorkspaceId);
|
||||||
channel.HasIndex(x => new { x.WorkspaceId, x.Network, x.Name }).IsUnique();
|
channel.HasIndex(x => new { x.WorkspaceId, x.Network, x.Name }).IsUnique();
|
||||||
|
channel.HasOne<Workspace>()
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(x => x.WorkspaceId)
|
||||||
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
});
|
});
|
||||||
|
|
||||||
return modelBuilder;
|
return modelBuilder;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Socialize.Api.Modules.Workspaces.Data;
|
||||||
|
|
||||||
namespace Socialize.Api.Modules.Clients.Data;
|
namespace Socialize.Api.Modules.Clients.Data;
|
||||||
|
|
||||||
@@ -21,6 +22,10 @@ internal static class ClientModelConfiguration
|
|||||||
.HasDefaultValueSql("CURRENT_TIMESTAMP");
|
.HasDefaultValueSql("CURRENT_TIMESTAMP");
|
||||||
client.HasIndex(x => new { x.WorkspaceId, x.Name }).IsUnique();
|
client.HasIndex(x => new { x.WorkspaceId, x.Name }).IsUnique();
|
||||||
client.HasIndex(x => x.WorkspaceId);
|
client.HasIndex(x => x.WorkspaceId);
|
||||||
|
client.HasOne<Workspace>()
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(x => x.WorkspaceId)
|
||||||
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
});
|
});
|
||||||
|
|
||||||
return modelBuilder;
|
return modelBuilder;
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Socialize.Api.Modules.ContentItems.Data;
|
||||||
|
using Socialize.Api.Modules.Workspaces.Data;
|
||||||
|
|
||||||
namespace Socialize.Api.Modules.Comments.Data;
|
namespace Socialize.Api.Modules.Comments.Data;
|
||||||
|
|
||||||
@@ -24,6 +26,18 @@ internal static class CommentModelConfiguration
|
|||||||
comment.HasIndex(x => x.WorkspaceId);
|
comment.HasIndex(x => x.WorkspaceId);
|
||||||
comment.HasIndex(x => x.ContentItemId);
|
comment.HasIndex(x => x.ContentItemId);
|
||||||
comment.HasIndex(x => x.ParentCommentId);
|
comment.HasIndex(x => x.ParentCommentId);
|
||||||
|
comment.HasOne<Workspace>()
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(x => x.WorkspaceId)
|
||||||
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
|
comment.HasOne<ContentItem>()
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(x => x.ContentItemId)
|
||||||
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
|
comment.HasOne<Comment>()
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(x => x.ParentCommentId)
|
||||||
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
});
|
});
|
||||||
|
|
||||||
return modelBuilder;
|
return modelBuilder;
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Socialize.Api.Modules.Campaigns.Data;
|
||||||
|
using Socialize.Api.Modules.Clients.Data;
|
||||||
|
using Socialize.Api.Modules.Workspaces.Data;
|
||||||
|
|
||||||
namespace Socialize.Api.Modules.ContentItems.Data;
|
namespace Socialize.Api.Modules.ContentItems.Data;
|
||||||
|
|
||||||
@@ -22,6 +25,18 @@ internal static class ContentItemModelConfiguration
|
|||||||
contentItem.HasIndex(x => x.WorkspaceId);
|
contentItem.HasIndex(x => x.WorkspaceId);
|
||||||
contentItem.HasIndex(x => x.ClientId);
|
contentItem.HasIndex(x => x.ClientId);
|
||||||
contentItem.HasIndex(x => x.CampaignId);
|
contentItem.HasIndex(x => x.CampaignId);
|
||||||
|
contentItem.HasOne<Workspace>()
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(x => x.WorkspaceId)
|
||||||
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
|
contentItem.HasOne<Client>()
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(x => x.ClientId)
|
||||||
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
|
contentItem.HasOne<Campaign>()
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(x => x.CampaignId)
|
||||||
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity<ContentItemRevision>(revision =>
|
modelBuilder.Entity<ContentItemRevision>(revision =>
|
||||||
@@ -39,6 +54,10 @@ internal static class ContentItemModelConfiguration
|
|||||||
.HasDefaultValueSql("CURRENT_TIMESTAMP");
|
.HasDefaultValueSql("CURRENT_TIMESTAMP");
|
||||||
revision.HasIndex(x => x.ContentItemId);
|
revision.HasIndex(x => x.ContentItemId);
|
||||||
revision.HasIndex(x => new { x.ContentItemId, x.RevisionNumber }).IsUnique();
|
revision.HasIndex(x => new { x.ContentItemId, x.RevisionNumber }).IsUnique();
|
||||||
|
revision.HasOne<ContentItem>()
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(x => x.ContentItemId)
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity<ContentItemActivityEntry>(entry =>
|
modelBuilder.Entity<ContentItemActivityEntry>(entry =>
|
||||||
@@ -56,6 +75,14 @@ internal static class ContentItemModelConfiguration
|
|||||||
entry.HasIndex(x => x.WorkspaceId);
|
entry.HasIndex(x => x.WorkspaceId);
|
||||||
entry.HasIndex(x => x.ContentItemId);
|
entry.HasIndex(x => x.ContentItemId);
|
||||||
entry.HasIndex(x => new { x.ContentItemId, x.CreatedAt });
|
entry.HasIndex(x => new { x.ContentItemId, x.CreatedAt });
|
||||||
|
entry.HasOne<Workspace>()
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(x => x.WorkspaceId)
|
||||||
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
|
entry.HasOne<ContentItem>()
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(x => x.ContentItemId)
|
||||||
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
});
|
});
|
||||||
|
|
||||||
return modelBuilder;
|
return modelBuilder;
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Socialize.Api.Modules.Campaigns.Data;
|
||||||
|
using Socialize.Api.Modules.Clients.Data;
|
||||||
|
using Socialize.Api.Modules.ContentItems.Data;
|
||||||
|
using Socialize.Api.Modules.Workspaces.Data;
|
||||||
|
|
||||||
namespace Socialize.Api.Modules.Feedback.Data;
|
namespace Socialize.Api.Modules.Feedback.Data;
|
||||||
|
|
||||||
@@ -29,6 +33,22 @@ internal static class FeedbackModelConfiguration
|
|||||||
feedback.HasIndex(x => x.Type);
|
feedback.HasIndex(x => x.Type);
|
||||||
feedback.HasIndex(x => x.WorkspaceId);
|
feedback.HasIndex(x => x.WorkspaceId);
|
||||||
feedback.HasIndex(x => x.LastActivityAt);
|
feedback.HasIndex(x => x.LastActivityAt);
|
||||||
|
feedback.HasOne<Workspace>()
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(x => x.WorkspaceId)
|
||||||
|
.OnDelete(DeleteBehavior.SetNull);
|
||||||
|
feedback.HasOne<Client>()
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(x => x.ClientId)
|
||||||
|
.OnDelete(DeleteBehavior.SetNull);
|
||||||
|
feedback.HasOne<Campaign>()
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(x => x.CampaignId)
|
||||||
|
.OnDelete(DeleteBehavior.SetNull);
|
||||||
|
feedback.HasOne<ContentItem>()
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(x => x.ContentItemId)
|
||||||
|
.OnDelete(DeleteBehavior.SetNull);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity<FeedbackTag>(tag =>
|
modelBuilder.Entity<FeedbackTag>(tag =>
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Socialize.Api.Modules.ContentItems.Data;
|
||||||
|
using Socialize.Api.Modules.Workspaces.Data;
|
||||||
|
|
||||||
namespace Socialize.Api.Modules.Notifications.Data;
|
namespace Socialize.Api.Modules.Notifications.Data;
|
||||||
|
|
||||||
@@ -22,6 +24,14 @@ internal static class NotificationModelConfiguration
|
|||||||
notificationEvent.HasIndex(x => x.ContentItemId);
|
notificationEvent.HasIndex(x => x.ContentItemId);
|
||||||
notificationEvent.HasIndex(x => x.RecipientUserId);
|
notificationEvent.HasIndex(x => x.RecipientUserId);
|
||||||
notificationEvent.HasIndex(x => x.CreatedAt);
|
notificationEvent.HasIndex(x => x.CreatedAt);
|
||||||
|
notificationEvent.HasOne<Workspace>()
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(x => x.WorkspaceId)
|
||||||
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
|
notificationEvent.HasOne<ContentItem>()
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(x => x.ContentItemId)
|
||||||
|
.OnDelete(DeleteBehavior.SetNull);
|
||||||
});
|
});
|
||||||
|
|
||||||
return modelBuilder;
|
return modelBuilder;
|
||||||
|
|||||||
@@ -41,6 +41,10 @@ internal static class WorkspaceModelConfiguration
|
|||||||
.HasDefaultValueSql("CURRENT_TIMESTAMP");
|
.HasDefaultValueSql("CURRENT_TIMESTAMP");
|
||||||
workspaceInvite.HasIndex(x => x.WorkspaceId);
|
workspaceInvite.HasIndex(x => x.WorkspaceId);
|
||||||
workspaceInvite.HasIndex(x => new { x.WorkspaceId, x.Email, x.Status });
|
workspaceInvite.HasIndex(x => new { x.WorkspaceId, x.Email, x.Status });
|
||||||
|
workspaceInvite.HasOne<Workspace>()
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(x => x.WorkspaceId)
|
||||||
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
});
|
});
|
||||||
|
|
||||||
return modelBuilder;
|
return modelBuilder;
|
||||||
|
|||||||
@@ -14,11 +14,6 @@ SVG_FILE="${OUT_DIR}/database-diagram.svg"
|
|||||||
PNG_FILE="${OUT_DIR}/database-diagram.png"
|
PNG_FILE="${OUT_DIR}/database-diagram.png"
|
||||||
HTML_FILE="${OUT_DIR}/database-diagram.html"
|
HTML_FILE="${OUT_DIR}/database-diagram.html"
|
||||||
|
|
||||||
if ! command -v psql >/dev/null 2>&1; then
|
|
||||||
echo "psql is required to generate the database diagram." >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
export PGCONNECT_TIMEOUT="${PGCONNECT_TIMEOUT:-5}"
|
export PGCONNECT_TIMEOUT="${PGCONNECT_TIMEOUT:-5}"
|
||||||
export PGHOST="${PGHOST:-localhost}"
|
export PGHOST="${PGHOST:-localhost}"
|
||||||
export PGPORT="${PGPORT:-5433}"
|
export PGPORT="${PGPORT:-5433}"
|
||||||
@@ -38,6 +33,11 @@ else
|
|||||||
PSQL=(psql "${PSQL_ARGS[@]}")
|
PSQL=(psql "${PSQL_ARGS[@]}")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ "${PSQL[0]}" == "psql" ]] && ! command -v psql >/dev/null 2>&1; then
|
||||||
|
echo "psql is required to generate the database diagram when not using the local Docker container." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Reading schema from ${CONNECTION_LABEL}..."
|
echo "Reading schema from ${CONNECTION_LABEL}..."
|
||||||
|
|
||||||
if ! "${PSQL[@]}" -c "select 1" >/dev/null 2>&1; then
|
if ! "${PSQL[@]}" -c "select 1" >/dev/null 2>&1; then
|
||||||
@@ -50,9 +50,31 @@ fi
|
|||||||
SELECT
|
SELECT
|
||||||
c.table_schema || '.' || c.table_name AS table_id,
|
c.table_schema || '.' || c.table_name AS table_id,
|
||||||
c.column_name,
|
c.column_name,
|
||||||
c.udt_name,
|
CASE
|
||||||
|
WHEN c.data_type = 'character varying'
|
||||||
|
THEN 'varchar(' || c.character_maximum_length || ')'
|
||||||
|
WHEN c.data_type = 'character'
|
||||||
|
THEN 'char(' || c.character_maximum_length || ')'
|
||||||
|
WHEN c.data_type = 'text'
|
||||||
|
THEN 'text'
|
||||||
|
WHEN c.data_type = 'numeric' AND c.numeric_precision IS NOT NULL AND c.numeric_scale IS NOT NULL
|
||||||
|
THEN 'numeric(' || c.numeric_precision || ',' || c.numeric_scale || ')'
|
||||||
|
WHEN c.data_type = 'numeric' AND c.numeric_precision IS NOT NULL
|
||||||
|
THEN 'numeric(' || c.numeric_precision || ')'
|
||||||
|
WHEN c.data_type = 'timestamp with time zone'
|
||||||
|
THEN 'timestamptz'
|
||||||
|
WHEN c.data_type = 'timestamp without time zone'
|
||||||
|
THEN 'timestamp'
|
||||||
|
WHEN c.data_type = 'USER-DEFINED'
|
||||||
|
THEN c.udt_name
|
||||||
|
ELSE c.data_type
|
||||||
|
END AS formatted_type,
|
||||||
c.is_nullable,
|
c.is_nullable,
|
||||||
CASE WHEN pk.column_name IS NULL THEN '' ELSE 'PK' END AS key_type
|
concat_ws(' ',
|
||||||
|
CASE WHEN pk.column_name IS NULL THEN NULL ELSE 'PK' END,
|
||||||
|
CASE WHEN fk.column_name IS NULL THEN NULL ELSE 'FK' END,
|
||||||
|
CASE WHEN ix.column_name IS NULL THEN NULL ELSE 'IX' END
|
||||||
|
) AS column_markers
|
||||||
FROM information_schema.columns c
|
FROM information_schema.columns c
|
||||||
LEFT JOIN (
|
LEFT JOIN (
|
||||||
SELECT
|
SELECT
|
||||||
@@ -69,6 +91,39 @@ LEFT JOIN (
|
|||||||
ON pk.table_schema = c.table_schema
|
ON pk.table_schema = c.table_schema
|
||||||
AND pk.table_name = c.table_name
|
AND pk.table_name = c.table_name
|
||||||
AND pk.column_name = c.column_name
|
AND pk.column_name = c.column_name
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT DISTINCT
|
||||||
|
kcu.table_schema,
|
||||||
|
kcu.table_name,
|
||||||
|
kcu.column_name
|
||||||
|
FROM information_schema.table_constraints tc
|
||||||
|
JOIN information_schema.key_column_usage kcu
|
||||||
|
ON kcu.constraint_catalog = tc.constraint_catalog
|
||||||
|
AND kcu.constraint_schema = tc.constraint_schema
|
||||||
|
AND kcu.constraint_name = tc.constraint_name
|
||||||
|
WHERE tc.constraint_type = 'FOREIGN KEY'
|
||||||
|
) fk
|
||||||
|
ON fk.table_schema = c.table_schema
|
||||||
|
AND fk.table_name = c.table_name
|
||||||
|
AND fk.column_name = c.column_name
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT DISTINCT
|
||||||
|
indexed_schema.nspname AS table_schema,
|
||||||
|
indexed_table.relname AS table_name,
|
||||||
|
indexed_attribute.attname AS column_name
|
||||||
|
FROM pg_catalog.pg_index index_definition
|
||||||
|
JOIN pg_catalog.pg_class indexed_table
|
||||||
|
ON indexed_table.oid = index_definition.indrelid
|
||||||
|
JOIN pg_catalog.pg_namespace indexed_schema
|
||||||
|
ON indexed_schema.oid = indexed_table.relnamespace
|
||||||
|
JOIN pg_catalog.pg_attribute indexed_attribute
|
||||||
|
ON indexed_attribute.attrelid = indexed_table.oid
|
||||||
|
AND indexed_attribute.attnum = ANY(index_definition.indkey)
|
||||||
|
WHERE indexed_schema.nspname = 'public'
|
||||||
|
) ix
|
||||||
|
ON ix.table_schema = c.table_schema
|
||||||
|
AND ix.table_name = c.table_name
|
||||||
|
AND ix.column_name = c.column_name
|
||||||
WHERE c.table_schema = 'public'
|
WHERE c.table_schema = 'public'
|
||||||
AND c.table_name <> '__EFMigrationsHistory'
|
AND c.table_name <> '__EFMigrationsHistory'
|
||||||
ORDER BY c.table_name, c.ordinal_position;
|
ORDER BY c.table_name, c.ordinal_position;
|
||||||
@@ -81,7 +136,27 @@ SELECT
|
|||||||
kcu.column_name AS child_column,
|
kcu.column_name AS child_column,
|
||||||
ccu.table_schema || '.' || ccu.table_name AS parent_table,
|
ccu.table_schema || '.' || ccu.table_name AS parent_table,
|
||||||
ccu.column_name AS parent_column,
|
ccu.column_name AS parent_column,
|
||||||
col.is_nullable
|
col.is_nullable,
|
||||||
|
CASE
|
||||||
|
WHEN EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM pg_catalog.pg_index unique_index
|
||||||
|
JOIN pg_catalog.pg_class unique_table
|
||||||
|
ON unique_table.oid = unique_index.indrelid
|
||||||
|
JOIN pg_catalog.pg_namespace unique_schema
|
||||||
|
ON unique_schema.oid = unique_table.relnamespace
|
||||||
|
JOIN pg_catalog.pg_attribute unique_attribute
|
||||||
|
ON unique_attribute.attrelid = unique_table.oid
|
||||||
|
AND unique_attribute.attnum = ANY(unique_index.indkey)
|
||||||
|
WHERE unique_schema.nspname = kcu.table_schema
|
||||||
|
AND unique_table.relname = kcu.table_name
|
||||||
|
AND unique_attribute.attname = kcu.column_name
|
||||||
|
AND unique_index.indisunique
|
||||||
|
AND unique_index.indnatts = 1
|
||||||
|
)
|
||||||
|
THEN 'YES'
|
||||||
|
ELSE 'NO'
|
||||||
|
END AS child_column_is_unique
|
||||||
FROM information_schema.table_constraints tc
|
FROM information_schema.table_constraints tc
|
||||||
JOIN information_schema.key_column_usage kcu
|
JOIN information_schema.key_column_usage kcu
|
||||||
ON kcu.constraint_catalog = tc.constraint_catalog
|
ON kcu.constraint_catalog = tc.constraint_catalog
|
||||||
@@ -119,11 +194,18 @@ node_id() {
|
|||||||
printf '%s' "$value"
|
printf '%s' "$value"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dot_label_escape() {
|
||||||
|
local value="$1"
|
||||||
|
value="${value//\\/\\\\}"
|
||||||
|
value="${value//\"/\\\"}"
|
||||||
|
printf '%s' "$value"
|
||||||
|
}
|
||||||
|
|
||||||
declare -A TABLE_COLUMNS
|
declare -A TABLE_COLUMNS
|
||||||
declare -A TABLE_SEEN
|
declare -A TABLE_SEEN
|
||||||
declare -a TABLE_ORDER
|
declare -a TABLE_ORDER
|
||||||
|
|
||||||
while IFS=$'\t' read -r table_name column_name column_type nullable key_type; do
|
while IFS=$'\t' read -r table_name column_name column_type nullable column_markers; do
|
||||||
[[ -n "$table_name" ]] || continue
|
[[ -n "$table_name" ]] || continue
|
||||||
|
|
||||||
if [[ -z "${TABLE_SEEN[$table_name]:-}" ]]; then
|
if [[ -z "${TABLE_SEEN[$table_name]:-}" ]]; then
|
||||||
@@ -133,11 +215,12 @@ while IFS=$'\t' read -r table_name column_name column_type nullable key_type; do
|
|||||||
|
|
||||||
label="$(html_escape "$column_name")"
|
label="$(html_escape "$column_name")"
|
||||||
type_label="$(html_escape "$column_type")"
|
type_label="$(html_escape "$column_type")"
|
||||||
suffix=""
|
marker_label="$(html_escape "$column_markers")"
|
||||||
[[ "$key_type" == "PK" ]] && suffix=" <FONT POINT-SIZE=\"10\">PK</FONT>"
|
[[ -n "$marker_label" ]] || marker_label=" "
|
||||||
[[ "$nullable" == "YES" ]] && suffix="${suffix} <FONT POINT-SIZE=\"10\">nullable</FONT>"
|
nullable_label=""
|
||||||
|
[[ "$nullable" == "YES" ]] && nullable_label=' <FONT POINT-SIZE="10">nullable</FONT>'
|
||||||
|
|
||||||
TABLE_COLUMNS["$table_name"]+=$' <TR><TD ALIGN="LEFT" PORT="'$(html_escape "$column_name")$'"><FONT FACE="monospace">'"${label}"$'</FONT></TD><TD ALIGN="LEFT"><FONT POINT-SIZE="10">'"${type_label}${suffix}"$'</FONT></TD></TR>\n'
|
TABLE_COLUMNS["$table_name"]+=$' <TR><TD ALIGN="LEFT"><FONT POINT-SIZE="10">'"${marker_label}"$'</FONT></TD><TD ALIGN="LEFT" PORT="'$(html_escape "$column_name")$'"><FONT FACE="monospace">'"${label}"$'</FONT></TD><TD ALIGN="LEFT"><FONT POINT-SIZE="10">'"${type_label}${nullable_label}"$'</FONT></TD></TR>\n'
|
||||||
done < "$TABLES_TSV"
|
done < "$TABLES_TSV"
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -149,7 +232,7 @@ digraph database {
|
|||||||
pad=0.4,
|
pad=0.4,
|
||||||
nodesep=0.6,
|
nodesep=0.6,
|
||||||
ranksep=1.0,
|
ranksep=1.0,
|
||||||
splines=ortho,
|
splines=spline,
|
||||||
overlap=false
|
overlap=false
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -162,9 +245,26 @@ digraph database {
|
|||||||
color="#64748b",
|
color="#64748b",
|
||||||
arrowsize=0.7,
|
arrowsize=0.7,
|
||||||
fontname="Arial",
|
fontname="Arial",
|
||||||
fontsize=10
|
fontsize=10,
|
||||||
|
labeldistance=1.8,
|
||||||
|
labelangle=22
|
||||||
];
|
];
|
||||||
|
|
||||||
|
legend [label=<
|
||||||
|
<TABLE BORDER="1" CELLBORDER="0" CELLSPACING="0" CELLPADDING="6" COLOR="#94a3b8">
|
||||||
|
<TR><TD BGCOLOR="#334155" COLSPAN="2"><FONT COLOR="white"><B>Legend</B></FONT></TD></TR>
|
||||||
|
<TR><TD ALIGN="LEFT">PK</TD><TD ALIGN="LEFT">primary key column</TD></TR>
|
||||||
|
<TR><TD ALIGN="LEFT">FK</TD><TD ALIGN="LEFT">foreign key column</TD></TR>
|
||||||
|
<TR><TD ALIGN="LEFT">IX</TD><TD ALIGN="LEFT">indexed column</TD></TR>
|
||||||
|
<TR><TD ALIGN="LEFT">solid line</TD><TD ALIGN="LEFT">required FK</TD></TR>
|
||||||
|
<TR><TD ALIGN="LEFT">dashed line</TD><TD ALIGN="LEFT">nullable FK</TD></TR>
|
||||||
|
<TR><TD ALIGN="LEFT">1</TD><TD ALIGN="LEFT">exactly one referenced row</TD></TR>
|
||||||
|
<TR><TD ALIGN="LEFT">0..1</TD><TD ALIGN="LEFT">zero or one referencing row</TD></TR>
|
||||||
|
<TR><TD ALIGN="LEFT">0..*</TD><TD ALIGN="LEFT">zero or many referencing rows</TD></TR>
|
||||||
|
<TR><TD ALIGN="LEFT" COLSPAN="2">Edges point from referenced table to referencing table.</TD></TR>
|
||||||
|
</TABLE>
|
||||||
|
>];
|
||||||
|
|
||||||
DOT
|
DOT
|
||||||
|
|
||||||
for table_name in "${TABLE_ORDER[@]}"; do
|
for table_name in "${TABLE_ORDER[@]}"; do
|
||||||
@@ -172,20 +272,22 @@ DOT
|
|||||||
title="$(html_escape "${table_name#public.}")"
|
title="$(html_escape "${table_name#public.}")"
|
||||||
printf ' %s [label=<\n' "$id"
|
printf ' %s [label=<\n' "$id"
|
||||||
printf ' <TABLE BORDER="1" CELLBORDER="1" CELLSPACING="0" CELLPADDING="6" COLOR="#94a3b8">\n'
|
printf ' <TABLE BORDER="1" CELLBORDER="1" CELLSPACING="0" CELLPADDING="6" COLOR="#94a3b8">\n'
|
||||||
printf ' <TR><TD BGCOLOR="#0f766e" COLSPAN="2"><FONT COLOR="white"><B>%s</B></FONT></TD></TR>\n' "$title"
|
printf ' <TR><TD BGCOLOR="#0f766e" COLSPAN="3"><FONT COLOR="white"><B>%s</B></FONT></TD></TR>\n' "$title"
|
||||||
printf '%s' "${TABLE_COLUMNS[$table_name]}"
|
printf '%s' "${TABLE_COLUMNS[$table_name]}"
|
||||||
printf ' </TABLE>\n'
|
printf ' </TABLE>\n'
|
||||||
printf ' >];\n\n'
|
printf ' >];\n\n'
|
||||||
done
|
done
|
||||||
|
|
||||||
while IFS=$'\t' read -r constraint_name child_table child_column parent_table parent_column nullable; do
|
while IFS=$'\t' read -r constraint_name child_table child_column parent_table parent_column nullable child_column_is_unique; do
|
||||||
[[ -n "$constraint_name" ]] || continue
|
[[ -n "$constraint_name" ]] || continue
|
||||||
child_id="$(node_id "$child_table")"
|
child_id="$(node_id "$child_table")"
|
||||||
parent_id="$(node_id "$parent_table")"
|
parent_id="$(node_id "$parent_table")"
|
||||||
label="$(html_escape "${child_column} -> ${parent_column}")"
|
child_cardinality="0..*"
|
||||||
|
[[ "$child_column_is_unique" == "YES" ]] && child_cardinality="0..1"
|
||||||
|
label="$(dot_label_escape "${parent_column} -> ${child_column}")"
|
||||||
style="solid"
|
style="solid"
|
||||||
[[ "$nullable" == "YES" ]] && style="dashed"
|
[[ "$nullable" == "YES" ]] && style="dashed"
|
||||||
printf ' %s -> %s [label="%s", style="%s"];\n' "$child_id" "$parent_id" "$label" "$style"
|
printf ' %s -> %s [label="%s", taillabel="1", headlabel="%s", style="%s"];\n' "$parent_id" "$child_id" "$label" "$child_cardinality" "$style"
|
||||||
done < "$RELATIONS_TSV"
|
done < "$RELATIONS_TSV"
|
||||||
|
|
||||||
printf '}\n'
|
printf '}\n'
|
||||||
@@ -219,14 +321,18 @@ cat > "$HTML_FILE" <<HTML
|
|||||||
position: sticky;
|
position: sticky;
|
||||||
top: 0;
|
top: 0;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
display: flex;
|
|
||||||
gap: 16px;
|
|
||||||
align-items: center;
|
|
||||||
padding: 12px 16px;
|
padding: 12px 16px;
|
||||||
border-bottom: 1px solid #cbd5e1;
|
border-bottom: 1px solid #cbd5e1;
|
||||||
background: #ffffff;
|
background: #ffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.bar {
|
||||||
|
display: flex;
|
||||||
|
gap: 16px;
|
||||||
|
align-items: center;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
header h1 {
|
header h1 {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
@@ -239,6 +345,29 @@ cat > "$HTML_FILE" <<HTML
|
|||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.legend {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 8px 16px;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
font-size: 13px;
|
||||||
|
color: #334155;
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.line {
|
||||||
|
display: inline-block;
|
||||||
|
width: 28px;
|
||||||
|
margin-right: 6px;
|
||||||
|
border-top: 2px solid #64748b;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.line.dashed {
|
||||||
|
border-top-style: dashed;
|
||||||
|
}
|
||||||
|
|
||||||
main {
|
main {
|
||||||
padding: 16px;
|
padding: 16px;
|
||||||
}
|
}
|
||||||
@@ -260,10 +389,20 @@ cat > "$HTML_FILE" <<HTML
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<header>
|
<header>
|
||||||
<h1>Socialize Database Diagram</h1>
|
<div class="bar">
|
||||||
<a href="./database-diagram.svg">SVG</a>
|
<h1>Socialize Database Diagram</h1>
|
||||||
<a href="./database-diagram.png">PNG</a>
|
<a href="./database-diagram.svg">SVG</a>
|
||||||
<a href="./database-diagram.dot">DOT</a>
|
<a href="./database-diagram.png">PNG</a>
|
||||||
|
<a href="./database-diagram.dot">DOT</a>
|
||||||
|
</div>
|
||||||
|
<ul class="legend">
|
||||||
|
<li><span class="line"></span>required FK</li>
|
||||||
|
<li><span class="line dashed"></span>nullable FK</li>
|
||||||
|
<li><strong>1</strong>: exactly one referenced row</li>
|
||||||
|
<li><strong>0..1</strong>: zero or one referencing row</li>
|
||||||
|
<li><strong>0..*</strong>: zero or many referencing rows</li>
|
||||||
|
<li>Edges point from referenced table to referencing table.</li>
|
||||||
|
</ul>
|
||||||
</header>
|
</header>
|
||||||
<main>
|
<main>
|
||||||
<div class="canvas">
|
<div class="canvas">
|
||||||
|
|||||||
Reference in New Issue
Block a user