118 lines
4.7 KiB
C#
118 lines
4.7 KiB
C#
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");
|
|
}
|
|
}
|
|
}
|