using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Nuuru.Server.Migrations.PostgreSQL
{
///
public partial class AddFriendsAndEnemies : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn(
name: "BlockMentionsFromEnemies",
table: "UserSettings",
type: "boolean",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn(
name: "NotifyOnEnemyAdded",
table: "UserSettings",
type: "boolean",
nullable: false,
defaultValue: true);
migrationBuilder.AddColumn(
name: "NotifyOnFriendAdded",
table: "UserSettings",
type: "boolean",
nullable: false,
defaultValue: true);
migrationBuilder.AddColumn(
name: "NotifyOnFriendRemoved",
table: "UserSettings",
type: "boolean",
nullable: false,
defaultValue: true);
migrationBuilder.AddColumn(
name: "OnlyAllowDmsFromFriends",
table: "UserSettings",
type: "boolean",
nullable: false,
defaultValue: false);
migrationBuilder.CreateTable(
name: "FriendBlocks",
columns: table => new
{
Id = table.Column(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
BlockedUserId = table.Column(type: "uuid", nullable: false),
BlockedByUserId = table.Column(type: "uuid", nullable: false),
CreatedAt = table.Column(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_FriendBlocks", x => x.Id);
table.ForeignKey(
name: "FK_FriendBlocks_AspNetUsers_BlockedByUserId",
column: x => x.BlockedByUserId,
principalTable: "AspNetUsers",
principalColumn: "Id");
table.ForeignKey(
name: "FK_FriendBlocks_AspNetUsers_BlockedUserId",
column: x => x.BlockedUserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "RelationCooldowns",
columns: table => new
{
Id = table.Column(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
UserId = table.Column(type: "uuid", nullable: false),
TargetUserId = table.Column(type: "uuid", nullable: false),
LastActionAt = table.Column(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_RelationCooldowns", x => x.Id);
});
migrationBuilder.CreateTable(
name: "UserRelations",
columns: table => new
{
Id = table.Column(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
UserId = table.Column(type: "uuid", nullable: false),
TargetUserId = table.Column(type: "uuid", nullable: false),
Type = table.Column(type: "integer", nullable: false),
CreatedAt = table.Column(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_UserRelations", x => x.Id);
table.ForeignKey(
name: "FK_UserRelations_AspNetUsers_TargetUserId",
column: x => x.TargetUserId,
principalTable: "AspNetUsers",
principalColumn: "Id");
table.ForeignKey(
name: "FK_UserRelations_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_FriendBlocks_BlockedByUserId",
table: "FriendBlocks",
column: "BlockedByUserId");
migrationBuilder.CreateIndex(
name: "IX_FriendBlocks_BlockedUserId_BlockedByUserId",
table: "FriendBlocks",
columns: new[] { "BlockedUserId", "BlockedByUserId" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_RelationCooldowns_UserId_TargetUserId",
table: "RelationCooldowns",
columns: new[] { "UserId", "TargetUserId" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_UserRelations_TargetUserId_Type",
table: "UserRelations",
columns: new[] { "TargetUserId", "Type" });
migrationBuilder.CreateIndex(
name: "IX_UserRelations_UserId_TargetUserId_Type",
table: "UserRelations",
columns: new[] { "UserId", "TargetUserId", "Type" },
unique: true);
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "FriendBlocks");
migrationBuilder.DropTable(
name: "RelationCooldowns");
migrationBuilder.DropTable(
name: "UserRelations");
migrationBuilder.DropColumn(
name: "BlockMentionsFromEnemies",
table: "UserSettings");
migrationBuilder.DropColumn(
name: "NotifyOnEnemyAdded",
table: "UserSettings");
migrationBuilder.DropColumn(
name: "NotifyOnFriendAdded",
table: "UserSettings");
migrationBuilder.DropColumn(
name: "NotifyOnFriendRemoved",
table: "UserSettings");
migrationBuilder.DropColumn(
name: "OnlyAllowDmsFromFriends",
table: "UserSettings");
}
}
}