using System.Collections.Generic; using Foxnouns.Backend.Database.Models; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Foxnouns.Backend.Database.Migrations { /// [DbContext(typeof(DatabaseContext))] [Migration("20241003150352_AddSupportConversations")] public partial class AddSupportConversations : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "support_conversations", columns: table => new { id = table.Column(type: "bigint", nullable: false), user_id = table.Column(type: "bigint", nullable: false), title = table.Column(type: "text", nullable: false), assigned_to_id = table.Column(type: "bigint", nullable: true), status = table.Column(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(type: "bigint", nullable: false), conversation_id = table.Column(type: "bigint", nullable: false), user_id = table.Column(type: "bigint", nullable: false), is_anonymous = table.Column(type: "boolean", nullable: false), content = table.Column(type: "text", nullable: true), attachments = table.Column>( type: "jsonb", nullable: false ), history = table.Column>( 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" ); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable(name: "support_messages"); migrationBuilder.DropTable(name: "support_conversations"); } } }