mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 19:54:55 +00:00
105 lines
3.7 KiB
C#
105 lines
3.7 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace Govor.Data.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class friendships : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.AddColumn<Guid>(
|
|
name: "PrivateChatId",
|
|
table: "Messages",
|
|
type: "uuid",
|
|
nullable: true);
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Friendships",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
RequesterId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
AddresseeId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Status = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Friendships", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Friendships_Users_AddresseeId",
|
|
column: x => x.AddresseeId,
|
|
principalTable: "Users",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
table.ForeignKey(
|
|
name: "FK_Friendships_Users_RequesterId",
|
|
column: x => x.RequesterId,
|
|
principalTable: "Users",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "PrivateChats",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
UserAId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
UserBId = table.Column<Guid>(type: "uuid", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_PrivateChats", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Messages_PrivateChatId",
|
|
table: "Messages",
|
|
column: "PrivateChatId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Friendships_AddresseeId",
|
|
table: "Friendships",
|
|
column: "AddresseeId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Friendships_RequesterId",
|
|
table: "Friendships",
|
|
column: "RequesterId");
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_Messages_PrivateChats_PrivateChatId",
|
|
table: "Messages",
|
|
column: "PrivateChatId",
|
|
principalTable: "PrivateChats",
|
|
principalColumn: "Id");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_Messages_PrivateChats_PrivateChatId",
|
|
table: "Messages");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Friendships");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "PrivateChats");
|
|
|
|
migrationBuilder.DropIndex(
|
|
name: "IX_Messages_PrivateChatId",
|
|
table: "Messages");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "PrivateChatId",
|
|
table: "Messages");
|
|
}
|
|
}
|
|
}
|