db changes

This commit is contained in:
defnotken
2025-09-16 15:03:15 -05:00
parent 81261fae49
commit 0df7ee424d
5 changed files with 15 additions and 9 deletions

View File

@@ -71,6 +71,9 @@ public class LightlessDbContext : DbContext
mb.Entity<BannedRegistrations>().ToTable("banned_registrations");
mb.Entity<Group>().ToTable("groups");
mb.Entity<Group>().HasIndex(c => c.OwnerUID);
mb.Entity<Group>()
.Property(g => g.CreatedDate)
.HasDefaultValueSql("CURRENT_TIMESTAMP");
mb.Entity<GroupPair>().ToTable("group_pairs");
mb.Entity<GroupPair>().HasKey(u => new { u.GroupGID, u.GroupUserUID });
mb.Entity<GroupPair>().HasIndex(c => c.GroupUserUID);

View File

@@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace LightlessSyncServer.Migrations
{
[DbContext(typeof(LightlessDbContext))]
[Migration("20250916145052_AddGroupProfilesAndDates")]
[Migration("20250916200240_AddGroupProfilesAndDates")]
partial class AddGroupProfilesAndDates
{
/// <inheritdoc />
@@ -434,8 +434,10 @@ namespace LightlessSyncServer.Migrations
.HasColumnName("alias");
b.Property<DateTime>("CreatedDate")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasColumnName("created_date");
.HasColumnName("created_date")
.HasDefaultValueSql("CURRENT_TIMESTAMP");
b.Property<string>("HashedPassword")
.HasColumnType("text")
@@ -529,7 +531,7 @@ namespace LightlessSyncServer.Migrations
.HasColumnType("boolean")
.HasColumnName("is_pinned");
b.Property<DateTime>("JoinedGroupOn")
b.Property<DateTime?>("JoinedGroupOn")
.HasColumnType("timestamp with time zone")
.HasColumnName("joined_group_on");

View File

@@ -16,7 +16,7 @@ namespace LightlessSyncServer.Migrations
table: "groups",
type: "timestamp with time zone",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
defaultValueSql: "CURRENT_TIMESTAMP");
migrationBuilder.AddColumn<bool>(
name: "from_finder",
@@ -29,8 +29,7 @@ namespace LightlessSyncServer.Migrations
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));
nullable: true);
migrationBuilder.CreateTable(
name: "group_profiles",

View File

@@ -431,8 +431,10 @@ namespace LightlessSyncServer.Migrations
.HasColumnName("alias");
b.Property<DateTime>("CreatedDate")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasColumnName("created_date");
.HasColumnName("created_date")
.HasDefaultValueSql("CURRENT_TIMESTAMP");
b.Property<string>("HashedPassword")
.HasColumnType("text")
@@ -526,7 +528,7 @@ namespace LightlessSyncServer.Migrations
.HasColumnType("boolean")
.HasColumnName("is_pinned");
b.Property<DateTime>("JoinedGroupOn")
b.Property<DateTime?>("JoinedGroupOn")
.HasColumnType("timestamp with time zone")
.HasColumnName("joined_group_on");

View File

@@ -9,5 +9,5 @@ public class GroupPair
public bool IsPinned { get; set; }
public bool IsModerator { get; set; }
public bool FromFinder { get; set; } = false;
public DateTime JoinedGroupOn { get; set; }
public DateTime? JoinedGroupOn { get; set; }
}