using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Govor.Data.Migrations { /// public partial class friendships : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AddColumn( name: "PrivateChatId", table: "Messages", type: "uuid", nullable: true); migrationBuilder.CreateTable( name: "Friendships", columns: table => new { Id = table.Column(type: "uuid", nullable: false), RequesterId = table.Column(type: "uuid", nullable: false), AddresseeId = table.Column(type: "uuid", nullable: false), Status = table.Column(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(type: "uuid", nullable: false), UserAId = table.Column(type: "uuid", nullable: false), UserBId = table.Column(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"); } /// 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"); } } }