using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace LANCommander.Migrations
{
///
public partial class AddChatModels : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "ChatThreads",
columns: table => new
{
Id = table.Column(type: "TEXT", nullable: false),
CreatedOn = table.Column(type: "TEXT", nullable: false),
CreatedById = table.Column(type: "TEXT", nullable: true),
UpdatedOn = table.Column(type: "TEXT", nullable: false),
UpdatedById = table.Column(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_ChatThreads", x => x.Id);
table.ForeignKey(
name: "FK_ChatThreads_Users_CreatedById",
column: x => x.CreatedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_ChatThreads_Users_UpdatedById",
column: x => x.UpdatedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
});
migrationBuilder.CreateTable(
name: "ChatMessages",
columns: table => new
{
Id = table.Column(type: "TEXT", nullable: false),
ThreadId = table.Column(type: "TEXT", nullable: false),
Content = table.Column(type: "TEXT", maxLength: 2000, nullable: false),
CreatedOn = table.Column(type: "TEXT", nullable: false),
CreatedById = table.Column(type: "TEXT", nullable: true),
UpdatedOn = table.Column(type: "TEXT", nullable: false),
UpdatedById = table.Column(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_ChatMessages", x => x.Id);
table.ForeignKey(
name: "FK_ChatMessages_ChatThreads_ThreadId",
column: x => x.ThreadId,
principalTable: "ChatThreads",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ChatMessages_Users_CreatedById",
column: x => x.CreatedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_ChatMessages_Users_UpdatedById",
column: x => x.UpdatedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
});
migrationBuilder.CreateTable(
name: "ChatThreadUser",
columns: table => new
{
ChatThreadsId = table.Column(type: "TEXT", nullable: false),
ParticipantsId = table.Column(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ChatThreadUser", x => new { x.ChatThreadsId, x.ParticipantsId });
table.ForeignKey(
name: "FK_ChatThreadUser_ChatThreads_ChatThreadsId",
column: x => x.ChatThreadsId,
principalTable: "ChatThreads",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ChatThreadUser_Users_ParticipantsId",
column: x => x.ParticipantsId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_ChatMessages_CreatedById",
table: "ChatMessages",
column: "CreatedById");
migrationBuilder.CreateIndex(
name: "IX_ChatMessages_ThreadId",
table: "ChatMessages",
column: "ThreadId");
migrationBuilder.CreateIndex(
name: "IX_ChatMessages_UpdatedById",
table: "ChatMessages",
column: "UpdatedById");
migrationBuilder.CreateIndex(
name: "IX_ChatThreads_CreatedById",
table: "ChatThreads",
column: "CreatedById");
migrationBuilder.CreateIndex(
name: "IX_ChatThreads_UpdatedById",
table: "ChatThreads",
column: "UpdatedById");
migrationBuilder.CreateIndex(
name: "IX_ChatThreadUser_ParticipantsId",
table: "ChatThreadUser",
column: "ParticipantsId");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ChatMessages");
migrationBuilder.DropTable(
name: "ChatThreadUser");
migrationBuilder.DropTable(
name: "ChatThreads");
}
}
}