feat(backend): add support conversations
This commit is contained in:
parent
a4ca0902a3
commit
ed3159c05d
12 changed files with 620 additions and 0 deletions
|
@ -0,0 +1,118 @@
|
|||
using System.Collections.Generic;
|
||||
using Foxnouns.Backend.Database.Models;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Foxnouns.Backend.Database.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
[DbContext(typeof(DatabaseContext))]
|
||||
[Migration("20241003150352_AddSupportConversations")]
|
||||
public partial class AddSupportConversations : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "support_conversations",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<long>(type: "bigint", nullable: false),
|
||||
user_id = table.Column<long>(type: "bigint", nullable: false),
|
||||
title = table.Column<string>(type: "text", nullable: false),
|
||||
assigned_to_id = table.Column<long>(type: "bigint", nullable: true),
|
||||
status = table.Column<int>(type: "integer", nullable: false),
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("pk_support_conversations", x => x.id);
|
||||
table.ForeignKey(
|
||||
name: "fk_support_conversations_users_assigned_to_id",
|
||||
column: x => x.assigned_to_id,
|
||||
principalTable: "users",
|
||||
principalColumn: "id"
|
||||
);
|
||||
table.ForeignKey(
|
||||
name: "fk_support_conversations_users_user_id",
|
||||
column: x => x.user_id,
|
||||
principalTable: "users",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "support_messages",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<long>(type: "bigint", nullable: false),
|
||||
conversation_id = table.Column<long>(type: "bigint", nullable: false),
|
||||
user_id = table.Column<long>(type: "bigint", nullable: false),
|
||||
is_anonymous = table.Column<bool>(type: "boolean", nullable: false),
|
||||
content = table.Column<string>(type: "text", nullable: true),
|
||||
attachments = table.Column<List<SupportMessage.Attachment>>(
|
||||
type: "jsonb",
|
||||
nullable: false
|
||||
),
|
||||
history = table.Column<List<SupportMessage.HistoryEntry>>(
|
||||
type: "jsonb",
|
||||
nullable: false
|
||||
),
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("pk_support_messages", x => x.id);
|
||||
table.ForeignKey(
|
||||
name: "fk_support_messages_support_conversations_conversation_id",
|
||||
column: x => x.conversation_id,
|
||||
principalTable: "support_conversations",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade
|
||||
);
|
||||
table.ForeignKey(
|
||||
name: "fk_support_messages_users_user_id",
|
||||
column: x => x.user_id,
|
||||
principalTable: "users",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_support_conversations_assigned_to_id",
|
||||
table: "support_conversations",
|
||||
column: "assigned_to_id"
|
||||
);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_support_conversations_user_id",
|
||||
table: "support_conversations",
|
||||
column: "user_id"
|
||||
);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_support_messages_conversation_id",
|
||||
table: "support_messages",
|
||||
column: "conversation_id"
|
||||
);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_support_messages_user_id",
|
||||
table: "support_messages",
|
||||
column: "user_id"
|
||||
);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(name: "support_messages");
|
||||
|
||||
migrationBuilder.DropTable(name: "support_conversations");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -266,6 +266,85 @@ namespace Foxnouns.Backend.Database.Migrations
|
|||
b.ToTable("pride_flags", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Foxnouns.Backend.Database.Models.SupportConversation", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.HasColumnType("bigint")
|
||||
.HasColumnName("id");
|
||||
|
||||
b.Property<long?>("AssignedToId")
|
||||
.HasColumnType("bigint")
|
||||
.HasColumnName("assigned_to_id");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("status");
|
||||
|
||||
b.Property<string>("Title")
|
||||
.IsRequired()
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("title");
|
||||
|
||||
b.Property<long>("UserId")
|
||||
.HasColumnType("bigint")
|
||||
.HasColumnName("user_id");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk_support_conversations");
|
||||
|
||||
b.HasIndex("AssignedToId")
|
||||
.HasDatabaseName("ix_support_conversations_assigned_to_id");
|
||||
|
||||
b.HasIndex("UserId")
|
||||
.HasDatabaseName("ix_support_conversations_user_id");
|
||||
|
||||
b.ToTable("support_conversations", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Foxnouns.Backend.Database.Models.SupportMessage", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.HasColumnType("bigint")
|
||||
.HasColumnName("id");
|
||||
|
||||
b.Property<List<SupportMessage.Attachment>>("Attachments")
|
||||
.IsRequired()
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("attachments");
|
||||
|
||||
b.Property<string>("Content")
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("content");
|
||||
|
||||
b.Property<long>("ConversationId")
|
||||
.HasColumnType("bigint")
|
||||
.HasColumnName("conversation_id");
|
||||
|
||||
b.Property<List<SupportMessage.HistoryEntry>>("History")
|
||||
.IsRequired()
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("history");
|
||||
|
||||
b.Property<bool>("IsAnonymous")
|
||||
.HasColumnType("boolean")
|
||||
.HasColumnName("is_anonymous");
|
||||
|
||||
b.Property<long>("UserId")
|
||||
.HasColumnType("bigint")
|
||||
.HasColumnName("user_id");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk_support_messages");
|
||||
|
||||
b.HasIndex("ConversationId")
|
||||
.HasDatabaseName("ix_support_messages_conversation_id");
|
||||
|
||||
b.HasIndex("UserId")
|
||||
.HasDatabaseName("ix_support_messages_user_id");
|
||||
|
||||
b.ToTable("support_messages", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Foxnouns.Backend.Database.Models.TemporaryKey", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
|
@ -542,6 +621,46 @@ namespace Foxnouns.Backend.Database.Migrations
|
|||
.HasConstraintName("fk_pride_flags_users_user_id");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Foxnouns.Backend.Database.Models.SupportConversation", b =>
|
||||
{
|
||||
b.HasOne("Foxnouns.Backend.Database.Models.User", "AssignedTo")
|
||||
.WithMany()
|
||||
.HasForeignKey("AssignedToId")
|
||||
.HasConstraintName("fk_support_conversations_users_assigned_to_id");
|
||||
|
||||
b.HasOne("Foxnouns.Backend.Database.Models.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("fk_support_conversations_users_user_id");
|
||||
|
||||
b.Navigation("AssignedTo");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Foxnouns.Backend.Database.Models.SupportMessage", b =>
|
||||
{
|
||||
b.HasOne("Foxnouns.Backend.Database.Models.SupportConversation", "Conversation")
|
||||
.WithMany()
|
||||
.HasForeignKey("ConversationId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("fk_support_messages_support_conversations_conversation_id");
|
||||
|
||||
b.HasOne("Foxnouns.Backend.Database.Models.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("fk_support_messages_users_user_id");
|
||||
|
||||
b.Navigation("Conversation");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Foxnouns.Backend.Database.Models.Token", b =>
|
||||
{
|
||||
b.HasOne("Foxnouns.Backend.Database.Models.Application", "Application")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue