Database changes for syncshell changes

This commit is contained in:
defnotken
2025-09-16 09:52:15 -05:00
parent d7e8be97ff
commit 81261fae49
7 changed files with 1307 additions and 0 deletions

View File

@@ -53,6 +53,7 @@ public class LightlessDbContext : DbContext
public DbSet<CharaDataOriginalFile> CharaDataOriginalFiles { get; set; }
public DbSet<CharaDataPose> CharaDataPoses { get; set; }
public DbSet<CharaDataAllowance> CharaDataAllowances { get; set; }
public DbSet<GroupProfile> GroupProfiles { get; set; }
protected override void OnModelCreating(ModelBuilder mb)
{
@@ -78,6 +79,14 @@ public class LightlessDbContext : DbContext
mb.Entity<GroupBan>().HasKey(u => new { u.GroupGID, u.BannedUserUID });
mb.Entity<GroupBan>().HasIndex(c => c.BannedUserUID);
mb.Entity<GroupBan>().HasIndex(c => c.GroupGID);
mb.Entity<GroupProfile>().ToTable("group_profiles");
mb.Entity<GroupProfile>().HasKey(u => u.GroupGID);
mb.Entity<GroupProfile>().HasIndex(c => c.GroupGID);
mb.Entity<GroupProfile>()
.HasOne(gp => gp.Group)
.WithMany()
.HasForeignKey(gp => gp.GroupGID)
.OnDelete(DeleteBehavior.Cascade);
mb.Entity<GroupTempInvite>().ToTable("group_temp_invites");
mb.Entity<GroupTempInvite>().HasKey(u => new { u.GroupGID, u.Invite });
mb.Entity<GroupTempInvite>().HasIndex(c => c.GroupGID);

View File

@@ -0,0 +1,80 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace LightlessSyncServer.Migrations
{
/// <inheritdoc />
public partial class AddGroupProfilesAndDates : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<DateTime>(
name: "created_date",
table: "groups",
type: "timestamp with time zone",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
migrationBuilder.AddColumn<bool>(
name: "from_finder",
table: "group_pairs",
type: "boolean",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<DateTime>(
name: "joined_group_on",
table: "group_pairs",
type: "timestamp with time zone",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
migrationBuilder.CreateTable(
name: "group_profiles",
columns: table => new
{
group_gid = table.Column<string>(type: "character varying(20)", nullable: false),
description = table.Column<string>(type: "text", nullable: true),
tags = table.Column<string>(type: "text", nullable: true),
base64group_profile_image = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_group_profiles", x => x.group_gid);
table.ForeignKey(
name: "fk_group_profiles_groups_group_gid",
column: x => x.group_gid,
principalTable: "groups",
principalColumn: "gid",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "ix_group_profiles_group_gid",
table: "group_profiles",
column: "group_gid");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "group_profiles");
migrationBuilder.DropColumn(
name: "created_date",
table: "groups");
migrationBuilder.DropColumn(
name: "from_finder",
table: "group_pairs");
migrationBuilder.DropColumn(
name: "joined_group_on",
table: "group_pairs");
}
}
}

View File

@@ -430,6 +430,10 @@ namespace LightlessSyncServer.Migrations
.HasColumnType("character varying(50)")
.HasColumnName("alias");
b.Property<DateTime>("CreatedDate")
.HasColumnType("timestamp with time zone")
.HasColumnName("created_date");
b.Property<string>("HashedPassword")
.HasColumnType("text")
.HasColumnName("hashed_password");
@@ -510,6 +514,10 @@ namespace LightlessSyncServer.Migrations
.HasColumnType("character varying(10)")
.HasColumnName("group_user_uid");
b.Property<bool>("FromFinder")
.HasColumnType("boolean")
.HasColumnName("from_finder");
b.Property<bool>("IsModerator")
.HasColumnType("boolean")
.HasColumnName("is_moderator");
@@ -518,6 +526,10 @@ namespace LightlessSyncServer.Migrations
.HasColumnType("boolean")
.HasColumnName("is_pinned");
b.Property<DateTime>("JoinedGroupOn")
.HasColumnType("timestamp with time zone")
.HasColumnName("joined_group_on");
b.HasKey("GroupGID", "GroupUserUID")
.HasName("pk_group_pairs");
@@ -568,6 +580,33 @@ namespace LightlessSyncServer.Migrations
b.ToTable("group_pair_preferred_permissions", (string)null);
});
modelBuilder.Entity("LightlessSyncShared.Models.GroupProfile", b =>
{
b.Property<string>("GroupGID")
.HasColumnType("character varying(20)")
.HasColumnName("group_gid");
b.Property<string>("Base64GroupProfileImage")
.HasColumnType("text")
.HasColumnName("base64group_profile_image");
b.Property<string>("Description")
.HasColumnType("text")
.HasColumnName("description");
b.Property<string>("Tags")
.HasColumnType("text")
.HasColumnName("tags");
b.HasKey("GroupGID")
.HasName("pk_group_profiles");
b.HasIndex("GroupGID")
.HasDatabaseName("ix_group_profiles_group_gid");
b.ToTable("group_profiles", (string)null);
});
modelBuilder.Entity("LightlessSyncShared.Models.GroupTempInvite", b =>
{
b.Property<string>("GroupGID")
@@ -1010,6 +1049,18 @@ namespace LightlessSyncServer.Migrations
b.Navigation("User");
});
modelBuilder.Entity("LightlessSyncShared.Models.GroupProfile", b =>
{
b.HasOne("LightlessSyncShared.Models.Group", "Group")
.WithMany()
.HasForeignKey("GroupGID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("fk_group_profiles_groups_group_gid");
b.Navigation("Group");
});
modelBuilder.Entity("LightlessSyncShared.Models.GroupTempInvite", b =>
{
b.HasOne("LightlessSyncShared.Models.Group", "Group")

View File

@@ -16,4 +16,5 @@ public class Group
public bool PreferDisableSounds { get; set; }
public bool PreferDisableAnimations { get; set; }
public bool PreferDisableVFX { get; set; }
public DateTime CreatedDate { get; set; } = DateTime.UtcNow;
}

View File

@@ -8,4 +8,6 @@ public class GroupPair
public User GroupUser { get; set; }
public bool IsPinned { get; set; }
public bool IsModerator { get; set; }
public bool FromFinder { get; set; } = false;
public DateTime JoinedGroupOn { get; set; }
}

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LightlessSyncShared.Models;
public class GroupProfile
{
public string GroupGID { get; set; }
public Group Group { get; set; }
public string Description { get; set; }
public string Tags { get; set; }
public string Base64GroupProfileImage { get; set; }
}