Fix nix, update admin api db models
This commit is contained in:
parent
3843a6e7b1
commit
7777595125
@ -5,9 +5,11 @@ using Spacebar.Db.Models;
|
||||
|
||||
namespace Spacebar.Db.Contexts;
|
||||
|
||||
public partial class SpacebarDbContext(DbContextOptions<SpacebarDbContext> options) : DbContext(options) {
|
||||
public SpacebarDbContext Clone() {
|
||||
return new SpacebarDbContext(options);
|
||||
public partial class SpacebarDbContext : DbContext
|
||||
{
|
||||
public SpacebarDbContext(DbContextOptions<SpacebarDbContext> options)
|
||||
: base(options)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual DbSet<Application> Applications { get; set; }
|
||||
@ -16,6 +18,8 @@ public partial class SpacebarDbContext(DbContextOptions<SpacebarDbContext> optio
|
||||
|
||||
public virtual DbSet<AuditLog> AuditLogs { get; set; }
|
||||
|
||||
public virtual DbSet<AutomodRule> AutomodRules { get; set; }
|
||||
|
||||
public virtual DbSet<BackupCode> BackupCodes { get; set; }
|
||||
|
||||
public virtual DbSet<Badge> Badges { get; set; }
|
||||
@ -28,6 +32,8 @@ public partial class SpacebarDbContext(DbContextOptions<SpacebarDbContext> optio
|
||||
|
||||
public virtual DbSet<ClientRelease> ClientReleases { get; set; }
|
||||
|
||||
public virtual DbSet<CloudAttachment> CloudAttachments { get; set; }
|
||||
|
||||
public virtual DbSet<Config> Configs { get; set; }
|
||||
|
||||
public virtual DbSet<ConnectedAccount> ConnectedAccounts { get; set; }
|
||||
@ -70,6 +76,10 @@ public partial class SpacebarDbContext(DbContextOptions<SpacebarDbContext> optio
|
||||
|
||||
public virtual DbSet<StickerPack> StickerPacks { get; set; }
|
||||
|
||||
public virtual DbSet<Stream> Streams { get; set; }
|
||||
|
||||
public virtual DbSet<StreamSession> StreamSessions { get; set; }
|
||||
|
||||
public virtual DbSet<Team> Teams { get; set; }
|
||||
|
||||
public virtual DbSet<TeamMember> TeamMembers { get; set; }
|
||||
@ -80,6 +90,8 @@ public partial class SpacebarDbContext(DbContextOptions<SpacebarDbContext> optio
|
||||
|
||||
public virtual DbSet<UserSetting> UserSettings { get; set; }
|
||||
|
||||
public virtual DbSet<UserSettingsProto> UserSettingsProtos { get; set; }
|
||||
|
||||
public virtual DbSet<ValidRegistrationToken> ValidRegistrationTokens { get; set; }
|
||||
|
||||
public virtual DbSet<VoiceState> VoiceStates { get; set; }
|
||||
@ -125,6 +137,15 @@ public partial class SpacebarDbContext(DbContextOptions<SpacebarDbContext> optio
|
||||
entity.HasOne(d => d.User).WithMany(p => p.AuditLogUsers).HasConstraintName("FK_bd2726fd31b35443f2245b93ba0");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<AutomodRule>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK_99789ae863507f5aed9e58d7866");
|
||||
|
||||
entity.HasOne(d => d.Creator).WithMany(p => p.AutomodRules)
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("FK_12d3d60b961393d310429c062b7");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<BackupCode>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK_34ab957382dbc57e8fb53f1638f");
|
||||
@ -179,6 +200,19 @@ public partial class SpacebarDbContext(DbContextOptions<SpacebarDbContext> optio
|
||||
entity.HasKey(e => e.Id).HasName("PK_4c4ea258342d2d6ba1be0a71a43");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<CloudAttachment>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK_5794827a3ee7c9318612dcb70c8");
|
||||
|
||||
entity.HasOne(d => d.Channel).WithMany(p => p.CloudAttachments)
|
||||
.OnDelete(DeleteBehavior.SetNull)
|
||||
.HasConstraintName("FK_998d5fe91008ba5b09e1322104c");
|
||||
|
||||
entity.HasOne(d => d.User).WithMany(p => p.CloudAttachments)
|
||||
.OnDelete(DeleteBehavior.SetNull)
|
||||
.HasConstraintName("FK_8bf8cc8767e48cb482ff644fce6");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Config>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Key).HasName("PK_26489c99ddbb4c91631ef5cc791");
|
||||
@ -512,6 +546,26 @@ public partial class SpacebarDbContext(DbContextOptions<SpacebarDbContext> optio
|
||||
entity.HasOne(d => d.CoverStickerId1Navigation).WithMany(p => p.StickerPacks).HasConstraintName("FK_448fafba4355ee1c837bbc865f1");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Stream>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK_40440b6f569ebc02bc71c25c499");
|
||||
|
||||
entity.HasOne(d => d.Channel).WithMany(p => p.Streams).HasConstraintName("FK_5101f0cded27ff0aae78fc4eed7");
|
||||
|
||||
entity.HasOne(d => d.Owner).WithMany(p => p.Streams).HasConstraintName("FK_1b566f9b54d1cda271da53ac82f");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<StreamSession>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK_49bdc3f66394c12478f8371c546");
|
||||
|
||||
entity.Property(e => e.Used).HasDefaultValue(false);
|
||||
|
||||
entity.HasOne(d => d.Stream).WithMany(p => p.StreamSessions).HasConstraintName("FK_8b5a028a34dae9ee54af37c9c32");
|
||||
|
||||
entity.HasOne(d => d.User).WithMany(p => p.StreamSessions).HasConstraintName("FK_13ae5c29aff4d0890c54179511a");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Team>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK_7e5523774a38b08a6236d322403");
|
||||
@ -557,6 +611,15 @@ public partial class SpacebarDbContext(DbContextOptions<SpacebarDbContext> optio
|
||||
entity.HasKey(e => e.Index).HasName("PK_e81f8bb92802737337d35c00981");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<UserSettingsProto>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.UserId).HasName("PK_8ff3d1961a48b693810c9f99853");
|
||||
|
||||
entity.HasOne(d => d.User).WithOne(p => p.UserSettingsProto)
|
||||
.OnDelete(DeleteBehavior.ClientSetNull)
|
||||
.HasConstraintName("FK_8ff3d1961a48b693810c9f99853");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<ValidRegistrationToken>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Token).HasName("PK_e0f5c8e3fcefe3134a092c50485");
|
||||
|
||||
52
extra/admin-api/Spacebar.Db/Models/AutomodRule.cs
Normal file
52
extra/admin-api/Spacebar.Db/Models/AutomodRule.cs
Normal file
@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Spacebar.Db.Models;
|
||||
|
||||
[Table("automod_rules")]
|
||||
public partial class AutomodRule
|
||||
{
|
||||
[Key]
|
||||
[Column("id", TypeName = "character varying")]
|
||||
public string Id { get; set; } = null!;
|
||||
|
||||
[Column("enabled")]
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
[Column("event_type")]
|
||||
public int EventType { get; set; }
|
||||
|
||||
[Column("exempt_channels")]
|
||||
public string ExemptChannels { get; set; } = null!;
|
||||
|
||||
[Column("exempt_roles")]
|
||||
public string ExemptRoles { get; set; } = null!;
|
||||
|
||||
[Column("guild_id", TypeName = "character varying")]
|
||||
public string GuildId { get; set; } = null!;
|
||||
|
||||
[Column("name", TypeName = "character varying")]
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
[Column("position")]
|
||||
public int Position { get; set; }
|
||||
|
||||
[Column("trigger_type")]
|
||||
public int TriggerType { get; set; }
|
||||
|
||||
[Column("trigger_metadata")]
|
||||
public string? TriggerMetadata { get; set; }
|
||||
|
||||
[Column("actions")]
|
||||
public string Actions { get; set; } = null!;
|
||||
|
||||
[Column("creator_id", TypeName = "character varying")]
|
||||
public string? CreatorId { get; set; }
|
||||
|
||||
[ForeignKey("CreatorId")]
|
||||
[InverseProperty("AutomodRules")]
|
||||
public virtual User? Creator { get; set; }
|
||||
}
|
||||
@ -71,7 +71,10 @@ public partial class Channel
|
||||
public int Flags { get; set; }
|
||||
|
||||
[Column("default_thread_rate_limit_per_user")]
|
||||
public int DefaultThreadRateLimitPerUser { get; set; }
|
||||
public int? DefaultThreadRateLimitPerUser { get; set; }
|
||||
|
||||
[InverseProperty("Channel")]
|
||||
public virtual ICollection<CloudAttachment> CloudAttachments { get; set; } = new List<CloudAttachment>();
|
||||
|
||||
[ForeignKey("GuildId")]
|
||||
[InverseProperty("Channels")]
|
||||
@ -115,6 +118,9 @@ public partial class Channel
|
||||
[InverseProperty("Channel")]
|
||||
public virtual ICollection<Recipient> Recipients { get; set; } = new List<Recipient>();
|
||||
|
||||
[InverseProperty("Channel")]
|
||||
public virtual ICollection<Stream> Streams { get; set; } = new List<Stream>();
|
||||
|
||||
[InverseProperty("Channel")]
|
||||
public virtual ICollection<VoiceState> VoiceStates { get; set; } = new List<VoiceState>();
|
||||
|
||||
|
||||
59
extra/admin-api/Spacebar.Db/Models/CloudAttachment.cs
Normal file
59
extra/admin-api/Spacebar.Db/Models/CloudAttachment.cs
Normal file
@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Spacebar.Db.Models;
|
||||
|
||||
[Table("cloud_attachments")]
|
||||
public partial class CloudAttachment
|
||||
{
|
||||
[Key]
|
||||
[Column("id", TypeName = "character varying")]
|
||||
public string Id { get; set; } = null!;
|
||||
|
||||
[Column("user_id", TypeName = "character varying")]
|
||||
public string? UserId { get; set; }
|
||||
|
||||
[Column("channel_id", TypeName = "character varying")]
|
||||
public string? ChannelId { get; set; }
|
||||
|
||||
[Column("upload_filename", TypeName = "character varying")]
|
||||
public string UploadFilename { get; set; } = null!;
|
||||
|
||||
[Column("user_attachment_id", TypeName = "character varying")]
|
||||
public string? UserAttachmentId { get; set; }
|
||||
|
||||
[Column("user_filename", TypeName = "character varying")]
|
||||
public string UserFilename { get; set; } = null!;
|
||||
|
||||
[Column("user_file_size")]
|
||||
public int? UserFileSize { get; set; }
|
||||
|
||||
[Column("user_original_content_type", TypeName = "character varying")]
|
||||
public string? UserOriginalContentType { get; set; }
|
||||
|
||||
[Column("user_is_clip")]
|
||||
public bool? UserIsClip { get; set; }
|
||||
|
||||
[Column("size")]
|
||||
public int? Size { get; set; }
|
||||
|
||||
[Column("height")]
|
||||
public int? Height { get; set; }
|
||||
|
||||
[Column("width")]
|
||||
public int? Width { get; set; }
|
||||
|
||||
[Column("content_type", TypeName = "character varying")]
|
||||
public string? ContentType { get; set; }
|
||||
|
||||
[ForeignKey("ChannelId")]
|
||||
[InverseProperty("CloudAttachments")]
|
||||
public virtual Channel? Channel { get; set; }
|
||||
|
||||
[ForeignKey("UserId")]
|
||||
[InverseProperty("CloudAttachments")]
|
||||
public virtual User? User { get; set; }
|
||||
}
|
||||
@ -58,8 +58,8 @@ public partial class Message
|
||||
[Column("nonce")]
|
||||
public string? Nonce { get; set; }
|
||||
|
||||
[Column("pinned")]
|
||||
public bool? Pinned { get; set; }
|
||||
[Column("pinned_at", TypeName = "timestamp without time zone")]
|
||||
public DateTime? PinnedAt { get; set; }
|
||||
|
||||
[Column("type")]
|
||||
public int Type { get; set; }
|
||||
|
||||
@ -49,6 +49,9 @@ public partial class Role
|
||||
[Column("flags")]
|
||||
public int Flags { get; set; }
|
||||
|
||||
[Column("colors")]
|
||||
public string Colors { get; set; } = null!;
|
||||
|
||||
[ForeignKey("GuildId")]
|
||||
[InverseProperty("Roles")]
|
||||
public virtual Guild Guild { get; set; } = null!;
|
||||
|
||||
35
extra/admin-api/Spacebar.Db/Models/Stream.cs
Normal file
35
extra/admin-api/Spacebar.Db/Models/Stream.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Spacebar.Db.Models;
|
||||
|
||||
[Table("streams")]
|
||||
public partial class Stream
|
||||
{
|
||||
[Key]
|
||||
[Column("id", TypeName = "character varying")]
|
||||
public string Id { get; set; } = null!;
|
||||
|
||||
[Column("owner_id", TypeName = "character varying")]
|
||||
public string OwnerId { get; set; } = null!;
|
||||
|
||||
[Column("channel_id", TypeName = "character varying")]
|
||||
public string ChannelId { get; set; } = null!;
|
||||
|
||||
[Column("endpoint", TypeName = "character varying")]
|
||||
public string Endpoint { get; set; } = null!;
|
||||
|
||||
[ForeignKey("ChannelId")]
|
||||
[InverseProperty("Streams")]
|
||||
public virtual Channel Channel { get; set; } = null!;
|
||||
|
||||
[ForeignKey("OwnerId")]
|
||||
[InverseProperty("Streams")]
|
||||
public virtual User Owner { get; set; } = null!;
|
||||
|
||||
[InverseProperty("Stream")]
|
||||
public virtual ICollection<StreamSession> StreamSessions { get; set; } = new List<StreamSession>();
|
||||
}
|
||||
38
extra/admin-api/Spacebar.Db/Models/StreamSession.cs
Normal file
38
extra/admin-api/Spacebar.Db/Models/StreamSession.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Spacebar.Db.Models;
|
||||
|
||||
[Table("stream_sessions")]
|
||||
public partial class StreamSession
|
||||
{
|
||||
[Key]
|
||||
[Column("id", TypeName = "character varying")]
|
||||
public string Id { get; set; } = null!;
|
||||
|
||||
[Column("stream_id", TypeName = "character varying")]
|
||||
public string StreamId { get; set; } = null!;
|
||||
|
||||
[Column("user_id", TypeName = "character varying")]
|
||||
public string UserId { get; set; } = null!;
|
||||
|
||||
[Column("token", TypeName = "character varying")]
|
||||
public string? Token { get; set; }
|
||||
|
||||
[Column("session_id", TypeName = "character varying")]
|
||||
public string SessionId { get; set; } = null!;
|
||||
|
||||
[Column("used")]
|
||||
public bool Used { get; set; }
|
||||
|
||||
[ForeignKey("StreamId")]
|
||||
[InverseProperty("StreamSessions")]
|
||||
public virtual Stream Stream { get; set; } = null!;
|
||||
|
||||
[ForeignKey("UserId")]
|
||||
[InverseProperty("StreamSessions")]
|
||||
public virtual User User { get; set; } = null!;
|
||||
}
|
||||
@ -92,11 +92,11 @@ public partial class User
|
||||
[Column("email", TypeName = "character varying")]
|
||||
public string? Email { get; set; }
|
||||
|
||||
[Column("flags", TypeName = "text")]
|
||||
public ulong Flags { get; set; }
|
||||
[Column("flags", TypeName = "character varying")]
|
||||
public string Flags { get; set; }
|
||||
|
||||
[Column("public_flags")]
|
||||
public ulong PublicFlags { get; set; }
|
||||
public int PublicFlags { get; set; }
|
||||
|
||||
[Column("purchased_flags")]
|
||||
public int PurchasedFlags { get; set; }
|
||||
@ -105,7 +105,7 @@ public partial class User
|
||||
public int PremiumUsageFlags { get; set; }
|
||||
|
||||
[Column("rights")]
|
||||
public ulong Rights { get; set; }
|
||||
public long Rights { get; set; }
|
||||
|
||||
[Column("data")]
|
||||
public string Data { get; set; } = null!;
|
||||
@ -134,6 +134,9 @@ public partial class User
|
||||
[InverseProperty("User")]
|
||||
public virtual ICollection<AuditLog> AuditLogUsers { get; set; } = new List<AuditLog>();
|
||||
|
||||
[InverseProperty("Creator")]
|
||||
public virtual ICollection<AutomodRule> AutomodRules { get; set; } = new List<AutomodRule>();
|
||||
|
||||
[InverseProperty("User")]
|
||||
public virtual ICollection<BackupCode> BackupCodes { get; set; } = new List<BackupCode>();
|
||||
|
||||
@ -146,6 +149,9 @@ public partial class User
|
||||
[InverseProperty("Owner")]
|
||||
public virtual ICollection<Channel> Channels { get; set; } = new List<Channel>();
|
||||
|
||||
[InverseProperty("User")]
|
||||
public virtual ICollection<CloudAttachment> CloudAttachments { get; set; } = new List<CloudAttachment>();
|
||||
|
||||
[InverseProperty("User")]
|
||||
public virtual ICollection<ConnectedAccount> ConnectedAccounts { get; set; } = new List<ConnectedAccount>();
|
||||
|
||||
@ -201,6 +207,12 @@ public partial class User
|
||||
[InverseProperty("User")]
|
||||
public virtual ICollection<Sticker> Stickers { get; set; } = new List<Sticker>();
|
||||
|
||||
[InverseProperty("User")]
|
||||
public virtual ICollection<StreamSession> StreamSessions { get; set; } = new List<StreamSession>();
|
||||
|
||||
[InverseProperty("Owner")]
|
||||
public virtual ICollection<Stream> Streams { get; set; } = new List<Stream>();
|
||||
|
||||
[InverseProperty("User")]
|
||||
public virtual ICollection<TeamMember> TeamMembers { get; set; } = new List<TeamMember>();
|
||||
|
||||
@ -210,6 +222,9 @@ public partial class User
|
||||
[InverseProperty("Creator")]
|
||||
public virtual ICollection<Template> Templates { get; set; } = new List<Template>();
|
||||
|
||||
[InverseProperty("User")]
|
||||
public virtual UserSettingsProto? UserSettingsProto { get; set; }
|
||||
|
||||
[InverseProperty("User")]
|
||||
public virtual ICollection<VoiceState> VoiceStates { get; set; } = new List<VoiceState>();
|
||||
|
||||
|
||||
25
extra/admin-api/Spacebar.Db/Models/UserSettingsProto.cs
Normal file
25
extra/admin-api/Spacebar.Db/Models/UserSettingsProto.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Spacebar.Db.Models;
|
||||
|
||||
[Table("user_settings_protos")]
|
||||
public partial class UserSettingsProto
|
||||
{
|
||||
[Key]
|
||||
[Column("user_id", TypeName = "character varying")]
|
||||
public string UserId { get; set; } = null!;
|
||||
|
||||
[Column("userSettings", TypeName = "character varying")]
|
||||
public string? UserSettings { get; set; }
|
||||
|
||||
[Column("frecencySettings", TypeName = "character varying")]
|
||||
public string? FrecencySettings { get; set; }
|
||||
|
||||
[ForeignKey("UserId")]
|
||||
[InverseProperty("UserSettingsProto")]
|
||||
public virtual User User { get; set; } = null!;
|
||||
}
|
||||
@ -1,8 +1,6 @@
|
||||
diff --git a/extra/admin-api/Spacebar.Db/Models/User.cs b/extra/admin-api/Spacebar.Db/Models/User.cs
|
||||
index 7825bd17..ca140dbc 100644
|
||||
--- a/extra/admin-api/Spacebar.Db/Models/User.cs
|
||||
+++ b/extra/admin-api/Spacebar.Db/Models/User.cs
|
||||
@@ -92,8 +92,8 @@ public partial class User
|
||||
--- Spacebar.Db/Models/User.cs.orig 2025-10-05 22:04:37.168566856 +0200
|
||||
+++ Spacebar.Db/Models/User.cs 2025-10-05 22:07:11.519980808 +0200
|
||||
@@ -92,8 +92,8 @@
|
||||
[Column("email", TypeName = "character varying")]
|
||||
public string? Email { get; set; }
|
||||
|
||||
|
||||
BIN
extra/admin-api/flake.lock
generated
Normal file
BIN
extra/admin-api/flake.lock
generated
Normal file
Binary file not shown.
@ -1,3 +1,3 @@
|
||||
{
|
||||
"npmDepsHash": "sha256-EQqDGr8mi7X1hr2iUvkNNJjhYW55ZUKI13sSRMzTjyg="
|
||||
"npmDepsHash": "sha256-0fIc3mzMVm0yu5SLeinjEBC5ADURYU+FCvcfoOJ0O/I="
|
||||
}
|
||||
|
||||
@ -183,8 +183,8 @@ export class Channel extends BaseClass {
|
||||
@Column()
|
||||
flags: number = 0;
|
||||
|
||||
@Column()
|
||||
default_thread_rate_limit_per_user: number = 0;
|
||||
@Column({ nullable: true })
|
||||
default_thread_rate_limit_per_user?: number = 0;
|
||||
|
||||
/** Must be calculated Channel.calculatePosition */
|
||||
position: number;
|
||||
|
||||
Reference in New Issue
Block a user