mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 11:44:56 +00:00
76094af15b
+ tests + new services + InvitationDto and IInvitationReqest
278 lines
12 KiB
C#
278 lines
12 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace Govor.Data.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class InitialCreate : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "ChatGroups",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Name = table.Column<string>(type: "text", nullable: false),
|
|
InviteCode = table.Column<List<string>>(type: "text[]", nullable: false),
|
|
IsChannel = table.Column<bool>(type: "boolean", nullable: false),
|
|
IsPrivate = table.Column<bool>(type: "boolean", nullable: false),
|
|
Admins = table.Column<List<Guid>>(type: "uuid[]", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_ChatGroups", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "GroupAdmins",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
GroupId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
UserId = table.Column<Guid>(type: "uuid", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_GroupAdmins", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "GroupMemberships",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
GroupId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
UserId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
IsBanned = table.Column<bool>(type: "boolean", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_GroupMemberships", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Invitations",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
IsAdmin = table.Column<bool>(type: "boolean", nullable: false),
|
|
Code = table.Column<string>(type: "text", nullable: false),
|
|
Description = table.Column<string>(type: "text", nullable: false),
|
|
DateCreated = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
EndDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
MaxParticipants = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Invitations", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Messages",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
SenderId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
RecipientId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
RecipientType = table.Column<int>(type: "integer", nullable: false),
|
|
EncryptedContent = table.Column<string>(type: "text", nullable: false),
|
|
SentAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
IsEdited = table.Column<bool>(type: "boolean", nullable: false),
|
|
EditedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
|
|
ReplyToMessageId = table.Column<Guid>(type: "uuid", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Messages", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Messages_Messages_ReplyToMessageId",
|
|
column: x => x.ReplyToMessageId,
|
|
principalTable: "Messages",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Users",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Username = table.Column<string>(type: "text", nullable: false),
|
|
Description = table.Column<string>(type: "text", nullable: false),
|
|
PasswordHash = table.Column<string>(type: "text", nullable: false),
|
|
IconId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
CreatedOn = table.Column<DateOnly>(type: "date", nullable: false),
|
|
WasOnline = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
InviteId = table.Column<Guid>(type: "uuid", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Users", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Users_Invitations_InviteId",
|
|
column: x => x.InviteId,
|
|
principalTable: "Invitations",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "MediaAttachments",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
MessageId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Type = table.Column<string>(type: "text", nullable: false),
|
|
FilePath = table.Column<string>(type: "text", nullable: false),
|
|
MimeType = table.Column<string>(type: "text", nullable: false),
|
|
EncryptedKey = table.Column<string>(type: "character varying(512)", maxLength: 512, nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_MediaAttachments", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_MediaAttachments_Messages_MessageId",
|
|
column: x => x.MessageId,
|
|
principalTable: "Messages",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "MessageViews",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
MessageId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
UserId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
ViewedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_MessageViews", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_MessageViews_Messages_MessageId",
|
|
column: x => x.MessageId,
|
|
principalTable: "Messages",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Admins",
|
|
columns: table => new
|
|
{
|
|
UserId = table.Column<Guid>(type: "uuid", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Admins", x => x.UserId);
|
|
table.ForeignKey(
|
|
name: "FK_Admins_Users_UserId",
|
|
column: x => x.UserId,
|
|
principalTable: "Users",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "MessageReactions",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
MessageId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
UserId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
ReactionCode = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
|
|
ReactedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_MessageReactions", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_MessageReactions_Messages_MessageId",
|
|
column: x => x.MessageId,
|
|
principalTable: "Messages",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_MessageReactions_Users_UserId",
|
|
column: x => x.UserId,
|
|
principalTable: "Users",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_MediaAttachments_MessageId",
|
|
table: "MediaAttachments",
|
|
column: "MessageId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_MessageReactions_MessageId_UserId",
|
|
table: "MessageReactions",
|
|
columns: new[] { "MessageId", "UserId" },
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_MessageReactions_UserId",
|
|
table: "MessageReactions",
|
|
column: "UserId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Messages_ReplyToMessageId",
|
|
table: "Messages",
|
|
column: "ReplyToMessageId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_MessageViews_MessageId_UserId",
|
|
table: "MessageViews",
|
|
columns: new[] { "MessageId", "UserId" },
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Users_InviteId",
|
|
table: "Users",
|
|
column: "InviteId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "Admins");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "ChatGroups");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "GroupAdmins");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "GroupMemberships");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "MediaAttachments");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "MessageReactions");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "MessageViews");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Users");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Messages");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Invitations");
|
|
}
|
|
}
|
|
}
|