144 lines
6 KiB
C#
144 lines
6 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace LANCommander.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AddChatModels : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "ChatThreads",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "TEXT", nullable: false),
|
|
CreatedOn = table.Column<DateTime>(type: "TEXT", nullable: false),
|
|
CreatedById = table.Column<Guid>(type: "TEXT", nullable: true),
|
|
UpdatedOn = table.Column<DateTime>(type: "TEXT", nullable: false),
|
|
UpdatedById = table.Column<Guid>(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<Guid>(type: "TEXT", nullable: false),
|
|
ThreadId = table.Column<Guid>(type: "TEXT", nullable: false),
|
|
Content = table.Column<string>(type: "TEXT", maxLength: 2000, nullable: false),
|
|
CreatedOn = table.Column<DateTime>(type: "TEXT", nullable: false),
|
|
CreatedById = table.Column<Guid>(type: "TEXT", nullable: true),
|
|
UpdatedOn = table.Column<DateTime>(type: "TEXT", nullable: false),
|
|
UpdatedById = table.Column<Guid>(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<Guid>(type: "TEXT", nullable: false),
|
|
ParticipantsId = table.Column<Guid>(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");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "ChatMessages");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "ChatThreadUser");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "ChatThreads");
|
|
}
|
|
}
|
|
}
|