2023-06-01 00:03:23 -04:00
|
|
|
|
using System;
|
|
|
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
|
|
|
|
|
|
|
|
#nullable disable
|
|
|
|
|
|
|
|
|
|
namespace vassago.Migrations
|
|
|
|
|
{
|
|
|
|
|
/// <inheritdoc />
|
2023-07-04 12:58:21 -04:00
|
|
|
|
public partial class initial : Migration
|
2023-06-01 00:03:23 -04:00
|
|
|
|
{
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
|
|
|
{
|
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
|
name: "PermissionSettings",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
|
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
2023-07-04 12:58:21 -04:00
|
|
|
|
MaxAttachmentBytes = table.Column<decimal>(type: "numeric(20,0)", nullable: true),
|
2023-06-01 00:03:23 -04:00
|
|
|
|
MaxTextChars = table.Column<long>(type: "bigint", nullable: true),
|
|
|
|
|
LinksAllowed = table.Column<bool>(type: "boolean", nullable: true),
|
2023-07-04 12:58:21 -04:00
|
|
|
|
ReactionsPossible = table.Column<bool>(type: "boolean", nullable: true),
|
2023-06-01 00:03:23 -04:00
|
|
|
|
LewdnessFilterLevel = table.Column<int>(type: "integer", nullable: true),
|
|
|
|
|
MeannessFilterLevel = table.Column<int>(type: "integer", nullable: true)
|
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_PermissionSettings", x => x.Id);
|
|
|
|
|
});
|
|
|
|
|
|
2023-07-04 12:58:21 -04:00
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
|
name: "Users",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false)
|
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_Users", x => x.Id);
|
|
|
|
|
});
|
|
|
|
|
|
2023-06-01 00:03:23 -04:00
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
|
name: "Channels",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
2023-07-04 12:58:21 -04:00
|
|
|
|
ExternalId = table.Column<string>(type: "text", nullable: true),
|
2023-06-01 00:03:23 -04:00
|
|
|
|
DisplayName = table.Column<string>(type: "text", nullable: true),
|
|
|
|
|
IsDM = table.Column<bool>(type: "boolean", nullable: false),
|
2023-07-04 12:58:21 -04:00
|
|
|
|
PermissionsId = table.Column<int>(type: "integer", nullable: true),
|
2023-06-01 00:03:23 -04:00
|
|
|
|
ParentChannelId = table.Column<Guid>(type: "uuid", nullable: true),
|
2023-07-04 12:58:21 -04:00
|
|
|
|
Protocol = table.Column<string>(type: "text", nullable: true)
|
2023-06-01 00:03:23 -04:00
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_Channels", x => x.Id);
|
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_Channels_Channels_ParentChannelId",
|
|
|
|
|
column: x => x.ParentChannelId,
|
|
|
|
|
principalTable: "Channels",
|
|
|
|
|
principalColumn: "Id");
|
|
|
|
|
table.ForeignKey(
|
2023-07-04 12:58:21 -04:00
|
|
|
|
name: "FK_Channels_PermissionSettings_PermissionsId",
|
|
|
|
|
column: x => x.PermissionsId,
|
2023-06-01 00:03:23 -04:00
|
|
|
|
principalTable: "PermissionSettings",
|
|
|
|
|
principalColumn: "Id");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable(
|
2023-07-04 12:58:21 -04:00
|
|
|
|
name: "Accounts",
|
2023-06-01 00:03:23 -04:00
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
2023-07-04 12:58:21 -04:00
|
|
|
|
ExternalId = table.Column<string>(type: "text", nullable: true),
|
2023-06-05 14:55:48 -04:00
|
|
|
|
Username = table.Column<string>(type: "text", nullable: true),
|
2023-07-04 12:58:21 -04:00
|
|
|
|
DisplayName = table.Column<string>(type: "text", nullable: true),
|
2023-06-01 00:03:23 -04:00
|
|
|
|
IsBot = table.Column<bool>(type: "boolean", nullable: false),
|
2023-07-04 12:58:21 -04:00
|
|
|
|
SeenInChannelId = table.Column<Guid>(type: "uuid", nullable: true),
|
|
|
|
|
PermissionTags = table.Column<int[]>(type: "integer[]", nullable: true),
|
|
|
|
|
Protocol = table.Column<string>(type: "text", nullable: true),
|
|
|
|
|
IsUserId = table.Column<Guid>(type: "uuid", nullable: true)
|
2023-06-01 00:03:23 -04:00
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
2023-07-04 12:58:21 -04:00
|
|
|
|
table.PrimaryKey("PK_Accounts", x => x.Id);
|
2023-06-01 00:03:23 -04:00
|
|
|
|
table.ForeignKey(
|
2023-07-04 12:58:21 -04:00
|
|
|
|
name: "FK_Accounts_Channels_SeenInChannelId",
|
|
|
|
|
column: x => x.SeenInChannelId,
|
2023-06-01 00:03:23 -04:00
|
|
|
|
principalTable: "Channels",
|
|
|
|
|
principalColumn: "Id");
|
|
|
|
|
table.ForeignKey(
|
2023-07-04 12:58:21 -04:00
|
|
|
|
name: "FK_Accounts_Users_IsUserId",
|
|
|
|
|
column: x => x.IsUserId,
|
2023-06-01 00:03:23 -04:00
|
|
|
|
principalTable: "Users",
|
|
|
|
|
principalColumn: "Id");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
|
name: "Messages",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
2023-07-04 12:58:21 -04:00
|
|
|
|
Protocol = table.Column<string>(type: "text", nullable: true),
|
|
|
|
|
ExternalId = table.Column<string>(type: "text", nullable: true),
|
2023-06-01 00:03:23 -04:00
|
|
|
|
Content = table.Column<string>(type: "text", nullable: true),
|
|
|
|
|
MentionsMe = table.Column<bool>(type: "boolean", nullable: false),
|
|
|
|
|
Timestamp = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
|
|
|
|
ActedOn = table.Column<bool>(type: "boolean", nullable: false),
|
|
|
|
|
AuthorId = table.Column<Guid>(type: "uuid", nullable: true),
|
|
|
|
|
ChannelId = table.Column<Guid>(type: "uuid", nullable: true)
|
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_Messages", x => x.Id);
|
2023-07-04 12:58:21 -04:00
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_Messages_Accounts_AuthorId",
|
|
|
|
|
column: x => x.AuthorId,
|
|
|
|
|
principalTable: "Accounts",
|
|
|
|
|
principalColumn: "Id");
|
2023-06-01 00:03:23 -04:00
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_Messages_Channels_ChannelId",
|
|
|
|
|
column: x => x.ChannelId,
|
|
|
|
|
principalTable: "Channels",
|
|
|
|
|
principalColumn: "Id");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
|
name: "Attachments",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
|
|
|
ExternalId = table.Column<decimal>(type: "numeric(20,0)", nullable: true),
|
|
|
|
|
Source = table.Column<string>(type: "text", nullable: true),
|
|
|
|
|
Content = table.Column<byte[]>(type: "bytea", nullable: true),
|
|
|
|
|
Filename = table.Column<string>(type: "text", nullable: true),
|
2023-06-05 14:55:48 -04:00
|
|
|
|
MessageId = table.Column<Guid>(type: "uuid", nullable: true),
|
|
|
|
|
ContentType = table.Column<string>(type: "text", nullable: true),
|
|
|
|
|
Description = table.Column<string>(type: "text", nullable: true),
|
|
|
|
|
Size = table.Column<int>(type: "integer", nullable: false)
|
2023-06-01 00:03:23 -04:00
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_Attachments", x => x.Id);
|
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_Attachments_Messages_MessageId",
|
|
|
|
|
column: x => x.MessageId,
|
|
|
|
|
principalTable: "Messages",
|
|
|
|
|
principalColumn: "Id");
|
|
|
|
|
});
|
|
|
|
|
|
2023-07-04 12:58:21 -04:00
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_Accounts_IsUserId",
|
|
|
|
|
table: "Accounts",
|
|
|
|
|
column: "IsUserId");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_Accounts_SeenInChannelId",
|
|
|
|
|
table: "Accounts",
|
|
|
|
|
column: "SeenInChannelId");
|
|
|
|
|
|
2023-06-01 00:03:23 -04:00
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_Attachments_MessageId",
|
|
|
|
|
table: "Attachments",
|
|
|
|
|
column: "MessageId");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_Channels_ParentChannelId",
|
|
|
|
|
table: "Channels",
|
|
|
|
|
column: "ParentChannelId");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
2023-07-04 12:58:21 -04:00
|
|
|
|
name: "IX_Channels_PermissionsId",
|
2023-06-01 00:03:23 -04:00
|
|
|
|
table: "Channels",
|
2023-07-04 12:58:21 -04:00
|
|
|
|
column: "PermissionsId");
|
2023-06-01 00:03:23 -04:00
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_Messages_AuthorId",
|
|
|
|
|
table: "Messages",
|
|
|
|
|
column: "AuthorId");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_Messages_ChannelId",
|
|
|
|
|
table: "Messages",
|
|
|
|
|
column: "ChannelId");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
|
|
|
{
|
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "Attachments");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "Messages");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
2023-07-04 12:58:21 -04:00
|
|
|
|
name: "Accounts");
|
2023-06-01 00:03:23 -04:00
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "Channels");
|
|
|
|
|
|
2023-07-04 12:58:21 -04:00
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "Users");
|
|
|
|
|
|
2023-06-01 00:03:23 -04:00
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "PermissionSettings");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|