diff --git a/Iceshrimp.Backend/Core/Database/DatabaseContext.cs b/Iceshrimp.Backend/Core/Database/DatabaseContext.cs index 8baf17ec..35128c0a 100644 --- a/Iceshrimp.Backend/Core/Database/DatabaseContext.cs +++ b/Iceshrimp.Backend/Core/Database/DatabaseContext.cs @@ -90,6 +90,7 @@ public class DatabaseContext(DbContextOptions options) public virtual DbSet Workers { get; init; } = null!; public virtual DbSet Filters { get; init; } = null!; public virtual DbSet DataProtectionKeys { get; init; } = null!; + public virtual DbSet PluginStore { get; init; } = null!; public static NpgsqlDataSource GetDataSource(Config.DatabaseSection config) { diff --git a/Iceshrimp.Backend/Core/Database/Migrations/DatabaseContextModelSnapshot.cs b/Iceshrimp.Backend/Core/Database/Migrations/DatabaseContextModelSnapshot.cs index 6de79184..53715ab9 100644 --- a/Iceshrimp.Backend/Core/Database/Migrations/DatabaseContextModelSnapshot.cs +++ b/Iceshrimp.Backend/Core/Database/Migrations/DatabaseContextModelSnapshot.cs @@ -3371,6 +3371,33 @@ namespace Iceshrimp.Backend.Core.Database.Migrations b.ToTable("password_reset_request"); }); + modelBuilder.Entity("Iceshrimp.Backend.Core.Database.Tables.PluginStoreEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("Data") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("jsonb") + .HasColumnName("data") + .HasDefaultValueSql("'{}'::jsonb") + .HasComment("The plugin-specific data object"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text") + .HasColumnName("name"); + + b.HasKey("Id"); + + b.HasIndex("Id"); + + b.ToTable("plugin_store"); + }); + modelBuilder.Entity("Iceshrimp.Backend.Core.Database.Tables.Poll", b => { b.Property("NoteId") diff --git a/Iceshrimp.Backend/Core/Database/Migrations/v2024.1-beta3/20240713201555_AddPluginStore.cs b/Iceshrimp.Backend/Core/Database/Migrations/v2024.1-beta3/20240713201555_AddPluginStore.cs new file mode 100644 index 00000000..6d6c90c5 --- /dev/null +++ b/Iceshrimp.Backend/Core/Database/Migrations/v2024.1-beta3/20240713201555_AddPluginStore.cs @@ -0,0 +1,43 @@ +using System; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Iceshrimp.Backend.Core.Database.Migrations +{ + /// + [DbContext(typeof(DatabaseContext))] + [Migration("20240713201555_AddPluginStore")] + public partial class AddPluginStore : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "plugin_store", + columns: table => new + { + id = table.Column(type: "uuid", nullable: false), + name = table.Column(type: "text", nullable: false), + data = table.Column(type: "jsonb", nullable: false, defaultValueSql: "'{}'::jsonb", comment: "The plugin-specific data object") + }, + constraints: table => + { + table.PrimaryKey("PK_plugin_store", x => x.id); + }); + + migrationBuilder.CreateIndex( + name: "IX_plugin_store_id", + table: "plugin_store", + column: "id"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "plugin_store"); + } + } +} diff --git a/Iceshrimp.Backend/Core/Database/Tables/PluginStoreEntry.cs b/Iceshrimp.Backend/Core/Database/Tables/PluginStoreEntry.cs new file mode 100644 index 00000000..6b56289d --- /dev/null +++ b/Iceshrimp.Backend/Core/Database/Tables/PluginStoreEntry.cs @@ -0,0 +1,23 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace Iceshrimp.Backend.Core.Database.Tables; + +[Table("plugin_store")] +[Index(nameof(Id))] +public class PluginStoreEntry +{ + [Key] [Column("id")] public Guid Id { get; set; } + [Column("name")] public string Name { get; set; } = null!; + [Column("data", TypeName = "jsonb")] public string Data { get; set; } = null!; +} + +public class PluginStoreEntityTypeConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder entity) + { + entity.Property(e => e.Data).HasDefaultValueSql("'{}'::jsonb").HasComment("The plugin-specific data object"); + } +} \ No newline at end of file