[iceshrimp/database] Add plugin store table (ISH-424)
This commit is contained in:
parent
635b5793bf
commit
478efdc4c7
4 changed files with 94 additions and 0 deletions
|
@ -90,6 +90,7 @@ public class DatabaseContext(DbContextOptions<DatabaseContext> options)
|
||||||
public virtual DbSet<Worker> Workers { get; init; } = null!;
|
public virtual DbSet<Worker> Workers { get; init; } = null!;
|
||||||
public virtual DbSet<Filter> Filters { get; init; } = null!;
|
public virtual DbSet<Filter> Filters { get; init; } = null!;
|
||||||
public virtual DbSet<DataProtectionKey> DataProtectionKeys { get; init; } = null!;
|
public virtual DbSet<DataProtectionKey> DataProtectionKeys { get; init; } = null!;
|
||||||
|
public virtual DbSet<PluginStoreEntry> PluginStore { get; init; } = null!;
|
||||||
|
|
||||||
public static NpgsqlDataSource GetDataSource(Config.DatabaseSection config)
|
public static NpgsqlDataSource GetDataSource(Config.DatabaseSection config)
|
||||||
{
|
{
|
||||||
|
|
|
@ -3371,6 +3371,33 @@ namespace Iceshrimp.Backend.Core.Database.Migrations
|
||||||
b.ToTable("password_reset_request");
|
b.ToTable("password_reset_request");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Iceshrimp.Backend.Core.Database.Tables.PluginStoreEntry", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid")
|
||||||
|
.HasColumnName("id");
|
||||||
|
|
||||||
|
b.Property<string>("Data")
|
||||||
|
.IsRequired()
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("jsonb")
|
||||||
|
.HasColumnName("data")
|
||||||
|
.HasDefaultValueSql("'{}'::jsonb")
|
||||||
|
.HasComment("The plugin-specific data object");
|
||||||
|
|
||||||
|
b.Property<string>("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 =>
|
modelBuilder.Entity("Iceshrimp.Backend.Core.Database.Tables.Poll", b =>
|
||||||
{
|
{
|
||||||
b.Property<string>("NoteId")
|
b.Property<string>("NoteId")
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Iceshrimp.Backend.Core.Database.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
[DbContext(typeof(DatabaseContext))]
|
||||||
|
[Migration("20240713201555_AddPluginStore")]
|
||||||
|
public partial class AddPluginStore : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "plugin_store",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
name = table.Column<string>(type: "text", nullable: false),
|
||||||
|
data = table.Column<string>(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");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "plugin_store");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
23
Iceshrimp.Backend/Core/Database/Tables/PluginStoreEntry.cs
Normal file
23
Iceshrimp.Backend/Core/Database/Tables/PluginStoreEntry.cs
Normal file
|
@ -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<PluginStoreEntry>
|
||||||
|
{
|
||||||
|
public void Configure(EntityTypeBuilder<PluginStoreEntry> entity)
|
||||||
|
{
|
||||||
|
entity.Property(e => e.Data).HasDefaultValueSql("'{}'::jsonb").HasComment("The plugin-specific data object");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue