This commit is contained in:
sam 2024-08-13 13:08:50 +02:00
commit ded4f4db26
Signed by: sam
GPG key ID: 5F3C3C1B3166639D
43 changed files with 2052 additions and 0 deletions

View file

@ -0,0 +1,180 @@
// <auto-generated />
using System.Collections.Generic;
using Catalogger.Backend.Database;
using Catalogger.Backend.Database.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using NodaTime;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Catalogger.Backend.Database.Migrations
{
[DbContext(typeof(DatabaseContext))]
[Migration("20240803132306_Init")]
partial class Init
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.7")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Catalogger.Backend.Database.Models.Guild", b =>
{
b.Property<long>("Id")
.HasColumnType("bigint")
.HasColumnName("id");
b.Property<List<string>>("BannedSystems")
.IsRequired()
.HasColumnType("text[]")
.HasColumnName("banned_systems");
b.Property<Guild.ChannelConfig>("Channels")
.IsRequired()
.HasColumnType("jsonb")
.HasColumnName("channels");
b.Property<List<long>>("KeyRoles")
.IsRequired()
.HasColumnType("bigint[]")
.HasColumnName("key_roles");
b.HasKey("Id")
.HasName("pk_guilds");
b.ToTable("guilds", (string)null);
});
modelBuilder.Entity("Catalogger.Backend.Database.Models.IgnoredMessage", b =>
{
b.Property<long>("Id")
.HasColumnType("bigint")
.HasColumnName("id");
b.HasKey("Id")
.HasName("pk_ignored_messages");
b.ToTable("ignored_messages", (string)null);
});
modelBuilder.Entity("Catalogger.Backend.Database.Models.Invite", b =>
{
b.Property<string>("Code")
.HasColumnType("text")
.HasColumnName("code");
b.Property<long>("GuildId")
.HasColumnType("bigint")
.HasColumnName("guild_id");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text")
.HasColumnName("name");
b.HasKey("Code")
.HasName("pk_invites");
b.HasIndex("GuildId")
.HasDatabaseName("ix_invites_guild_id");
b.ToTable("invites", (string)null);
});
modelBuilder.Entity("Catalogger.Backend.Database.Models.Message", b =>
{
b.Property<long>("Id")
.HasColumnType("bigint")
.HasColumnName("id");
b.Property<int>("AttachmentSize")
.HasColumnType("integer")
.HasColumnName("attachment_size");
b.Property<long>("ChannelId")
.HasColumnType("bigint")
.HasColumnName("channel_id");
b.Property<byte[]>("EncryptedContent")
.IsRequired()
.HasColumnType("bytea")
.HasColumnName("content");
b.Property<byte[]>("EncryptedMetadata")
.HasColumnType("bytea")
.HasColumnName("metadata");
b.Property<byte[]>("EncryptedUsername")
.IsRequired()
.HasColumnType("bytea")
.HasColumnName("username");
b.Property<long>("GuildId")
.HasColumnType("bigint")
.HasColumnName("guild_id");
b.Property<string>("Member")
.HasColumnType("text")
.HasColumnName("member");
b.Property<long?>("OriginalId")
.HasColumnType("bigint")
.HasColumnName("original_id");
b.Property<string>("System")
.HasColumnType("text")
.HasColumnName("system");
b.Property<long>("UserId")
.HasColumnType("bigint")
.HasColumnName("user_id");
b.HasKey("Id")
.HasName("pk_messages");
b.ToTable("messages", (string)null);
});
modelBuilder.Entity("Catalogger.Backend.Database.Models.Watchlist", b =>
{
b.Property<long>("GuildId")
.HasColumnType("bigint")
.HasColumnName("guild_id");
b.Property<long>("UserId")
.HasColumnType("bigint")
.HasColumnName("user_id");
b.Property<Instant>("AddedAt")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasColumnName("added_at")
.HasDefaultValueSql("now()");
b.Property<long>("ModeratorId")
.HasColumnType("bigint")
.HasColumnName("moderator_id");
b.Property<string>("Reason")
.IsRequired()
.HasColumnType("text")
.HasColumnName("reason");
b.HasKey("GuildId", "UserId")
.HasName("pk_watchlists");
b.ToTable("watchlists", (string)null);
});
#pragma warning restore 612, 618
}
}
}

View file

@ -0,0 +1,115 @@
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),
key_roles = table.Column<List<long>>(type: "bigint[]", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_guilds", x => x.id);
});
migrationBuilder.CreateTable(
name: "ignored_messages",
columns: table => new
{
id = table.Column<long>(type: "bigint", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_ignored_messages", x => x.id);
});
migrationBuilder.CreateTable(
name: "invites",
columns: table => new
{
code = table.Column<string>(type: "text", nullable: false),
guild_id = table.Column<long>(type: "bigint", nullable: false),
name = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_invites", x => x.code);
});
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),
attachment_size = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_messages", x => x.id);
});
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),
added_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
moderator_id = table.Column<long>(type: "bigint", nullable: false),
reason = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_watchlists", x => new { x.guild_id, x.user_id });
});
migrationBuilder.CreateIndex(
name: "ix_invites_guild_id",
table: "invites",
column: "guild_id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "guilds");
migrationBuilder.DropTable(
name: "ignored_messages");
migrationBuilder.DropTable(
name: "invites");
migrationBuilder.DropTable(
name: "messages");
migrationBuilder.DropTable(
name: "watchlists");
}
}
}

View file

@ -0,0 +1,177 @@
// <auto-generated />
using System.Collections.Generic;
using Catalogger.Backend.Database;
using Catalogger.Backend.Database.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using NodaTime;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Catalogger.Backend.Database.Migrations
{
[DbContext(typeof(DatabaseContext))]
partial class DatabaseContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.7")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Catalogger.Backend.Database.Models.Guild", b =>
{
b.Property<long>("Id")
.HasColumnType("bigint")
.HasColumnName("id");
b.Property<List<string>>("BannedSystems")
.IsRequired()
.HasColumnType("text[]")
.HasColumnName("banned_systems");
b.Property<Guild.ChannelConfig>("Channels")
.IsRequired()
.HasColumnType("jsonb")
.HasColumnName("channels");
b.Property<List<long>>("KeyRoles")
.IsRequired()
.HasColumnType("bigint[]")
.HasColumnName("key_roles");
b.HasKey("Id")
.HasName("pk_guilds");
b.ToTable("guilds", (string)null);
});
modelBuilder.Entity("Catalogger.Backend.Database.Models.IgnoredMessage", b =>
{
b.Property<long>("Id")
.HasColumnType("bigint")
.HasColumnName("id");
b.HasKey("Id")
.HasName("pk_ignored_messages");
b.ToTable("ignored_messages", (string)null);
});
modelBuilder.Entity("Catalogger.Backend.Database.Models.Invite", b =>
{
b.Property<string>("Code")
.HasColumnType("text")
.HasColumnName("code");
b.Property<long>("GuildId")
.HasColumnType("bigint")
.HasColumnName("guild_id");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text")
.HasColumnName("name");
b.HasKey("Code")
.HasName("pk_invites");
b.HasIndex("GuildId")
.HasDatabaseName("ix_invites_guild_id");
b.ToTable("invites", (string)null);
});
modelBuilder.Entity("Catalogger.Backend.Database.Models.Message", b =>
{
b.Property<long>("Id")
.HasColumnType("bigint")
.HasColumnName("id");
b.Property<int>("AttachmentSize")
.HasColumnType("integer")
.HasColumnName("attachment_size");
b.Property<long>("ChannelId")
.HasColumnType("bigint")
.HasColumnName("channel_id");
b.Property<byte[]>("EncryptedContent")
.IsRequired()
.HasColumnType("bytea")
.HasColumnName("content");
b.Property<byte[]>("EncryptedMetadata")
.HasColumnType("bytea")
.HasColumnName("metadata");
b.Property<byte[]>("EncryptedUsername")
.IsRequired()
.HasColumnType("bytea")
.HasColumnName("username");
b.Property<long>("GuildId")
.HasColumnType("bigint")
.HasColumnName("guild_id");
b.Property<string>("Member")
.HasColumnType("text")
.HasColumnName("member");
b.Property<long?>("OriginalId")
.HasColumnType("bigint")
.HasColumnName("original_id");
b.Property<string>("System")
.HasColumnType("text")
.HasColumnName("system");
b.Property<long>("UserId")
.HasColumnType("bigint")
.HasColumnName("user_id");
b.HasKey("Id")
.HasName("pk_messages");
b.ToTable("messages", (string)null);
});
modelBuilder.Entity("Catalogger.Backend.Database.Models.Watchlist", b =>
{
b.Property<long>("GuildId")
.HasColumnType("bigint")
.HasColumnName("guild_id");
b.Property<long>("UserId")
.HasColumnType("bigint")
.HasColumnName("user_id");
b.Property<Instant>("AddedAt")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasColumnName("added_at")
.HasDefaultValueSql("now()");
b.Property<long>("ModeratorId")
.HasColumnType("bigint")
.HasColumnName("moderator_id");
b.Property<string>("Reason")
.IsRequired()
.HasColumnType("text")
.HasColumnName("reason");
b.HasKey("GuildId", "UserId")
.HasName("pk_watchlists");
b.ToTable("watchlists", (string)null);
});
#pragma warning restore 612, 618
}
}
}