Catalogger.NET/Catalogger.Backend/Database/Migrations/20240803132306_Init.cs

118 lines
4.6 KiB
C#
Raw Normal View History

2024-08-13 13:08:50 +02:00
using System.Collections.Generic;
using Catalogger.Backend.Database.Models;
using Microsoft.EntityFrameworkCore.Migrations;
using NodaTime;
#nullable disable
namespace Catalogger.Backend.Database.Migrations
{
/// <inheritdoc />
public partial class Init : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "guilds",
columns: table => new
{
id = table.Column<long>(type: "bigint", nullable: false),
channels = table.Column<Guild.ChannelConfig>(type: "jsonb", nullable: false),
banned_systems = table.Column<List<string>>(type: "text[]", nullable: false),
2024-10-09 17:35:11 +02:00
key_roles = table.Column<List<long>>(type: "bigint[]", nullable: false),
2024-08-13 13:08:50 +02:00
},
constraints: table =>
{
table.PrimaryKey("pk_guilds", x => x.id);
2024-10-09 17:35:11 +02:00
}
);
2024-08-13 13:08:50 +02:00
migrationBuilder.CreateTable(
name: "ignored_messages",
2024-10-09 17:35:11 +02:00
columns: table => new { id = table.Column<long>(type: "bigint", nullable: false) },
2024-08-13 13:08:50 +02:00
constraints: table =>
{
table.PrimaryKey("pk_ignored_messages", x => x.id);
2024-10-09 17:35:11 +02:00
}
);
2024-08-13 13:08:50 +02:00
migrationBuilder.CreateTable(
name: "invites",
columns: table => new
{
code = table.Column<string>(type: "text", nullable: false),
guild_id = table.Column<long>(type: "bigint", nullable: false),
2024-10-09 17:35:11 +02:00
name = table.Column<string>(type: "text", nullable: false),
2024-08-13 13:08:50 +02:00
},
constraints: table =>
{
table.PrimaryKey("pk_invites", x => x.code);
2024-10-09 17:35:11 +02:00
}
);
2024-08-13 13:08:50 +02:00
migrationBuilder.CreateTable(
name: "messages",
columns: table => new
{
id = table.Column<long>(type: "bigint", nullable: false),
original_id = table.Column<long>(type: "bigint", nullable: true),
user_id = table.Column<long>(type: "bigint", nullable: false),
channel_id = table.Column<long>(type: "bigint", nullable: false),
guild_id = table.Column<long>(type: "bigint", nullable: false),
member = table.Column<string>(type: "text", nullable: true),
system = table.Column<string>(type: "text", nullable: true),
username = table.Column<byte[]>(type: "bytea", nullable: false),
content = table.Column<byte[]>(type: "bytea", nullable: false),
metadata = table.Column<byte[]>(type: "bytea", nullable: true),
2024-10-09 17:35:11 +02:00
attachment_size = table.Column<int>(type: "integer", nullable: false),
2024-08-13 13:08:50 +02:00
},
constraints: table =>
{
table.PrimaryKey("pk_messages", x => x.id);
2024-10-09 17:35:11 +02:00
}
);
2024-08-13 13:08:50 +02:00
migrationBuilder.CreateTable(
name: "watchlists",
columns: table => new
{
guild_id = table.Column<long>(type: "bigint", nullable: false),
user_id = table.Column<long>(type: "bigint", nullable: false),
2024-10-09 17:35:11 +02:00
added_at = table.Column<Instant>(
type: "timestamp with time zone",
nullable: false,
defaultValueSql: "now()"
),
2024-08-13 13:08:50 +02:00
moderator_id = table.Column<long>(type: "bigint", nullable: false),
2024-10-09 17:35:11 +02:00
reason = table.Column<string>(type: "text", nullable: false),
2024-08-13 13:08:50 +02:00
},
constraints: table =>
{
table.PrimaryKey("pk_watchlists", x => new { x.guild_id, x.user_id });
2024-10-09 17:35:11 +02:00
}
);
2024-08-13 13:08:50 +02:00
migrationBuilder.CreateIndex(
name: "ix_invites_guild_id",
table: "invites",
2024-10-09 17:35:11 +02:00
column: "guild_id"
);
2024-08-13 13:08:50 +02:00
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
2024-10-09 17:35:11 +02:00
migrationBuilder.DropTable(name: "guilds");
2024-08-13 13:08:50 +02:00
2024-10-09 17:35:11 +02:00
migrationBuilder.DropTable(name: "ignored_messages");
2024-08-13 13:08:50 +02:00
2024-10-09 17:35:11 +02:00
migrationBuilder.DropTable(name: "invites");
2024-08-13 13:08:50 +02:00
2024-10-09 17:35:11 +02:00
migrationBuilder.DropTable(name: "messages");
2024-08-13 13:08:50 +02:00
2024-10-09 17:35:11 +02:00
migrationBuilder.DropTable(name: "watchlists");
2024-08-13 13:08:50 +02:00
}
}
}