[backend/database] Remove extraneous user table columns

This commit is contained in:
Laura Hausmann 2024-07-11 23:37:55 +02:00
parent 3ac63e1510
commit 0cd754f4c2
No known key found for this signature in database
GPG key ID: D044E84C5BE01605
3 changed files with 56 additions and 31 deletions

View file

@ -3951,12 +3951,6 @@ namespace Iceshrimp.Backend.Core.Database.Migrations
.HasColumnName("followingCount")
.HasComment("The count of following.");
b.Property<bool>("HideOnlineStatus")
.ValueGeneratedOnAdd()
.HasColumnType("boolean")
.HasDefaultValue(false)
.HasColumnName("hideOnlineStatus");
b.Property<string>("Host")
.HasMaxLength(512)
.HasColumnType("character varying(512)")
@ -4079,13 +4073,6 @@ namespace Iceshrimp.Backend.Core.Database.Migrations
.HasColumnName("tags")
.HasDefaultValueSql("'{}'::character varying[]");
b.Property<string>("Token")
.HasMaxLength(16)
.HasColumnType("character(16)")
.HasColumnName("token")
.IsFixedLength()
.HasComment("The native access token of the User. It will be null if the origin of the user is local.");
b.Property<DateTime?>("UpdatedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("updatedAt")
@ -4133,9 +4120,6 @@ namespace Iceshrimp.Backend.Core.Database.Migrations
b.HasIndex("Tags");
b.HasIndex("Token")
.IsUnique();
b.HasIndex("UpdatedAt");
b.HasIndex("Uri");
@ -4611,7 +4595,7 @@ namespace Iceshrimp.Backend.Core.Database.Migrations
.HasColumnType("character varying(32)")
.HasColumnName("userId");
b.Property<bool>("AlwaysMarkNsfw")
b.Property<bool>("AlwaysMarkSensitive")
.ValueGeneratedOnAdd()
.HasColumnType("boolean")
.HasDefaultValue(false)

View file

@ -0,0 +1,55 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Infrastructure;
#nullable disable
namespace Iceshrimp.Backend.Core.Database.Migrations
{
/// <inheritdoc />
[DbContext(typeof(DatabaseContext))]
[Migration("20240711213718_RemoveExtraneousUserColumns")]
public partial class RemoveExtraneousUserColumns : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_user_token",
table: "user");
migrationBuilder.DropColumn(
name: "hideOnlineStatus",
table: "user");
migrationBuilder.DropColumn(
name: "token",
table: "user");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "hideOnlineStatus",
table: "user",
type: "boolean",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<string>(
name: "token",
table: "user",
type: "character(16)",
fixedLength: true,
maxLength: 16,
nullable: true,
comment: "The native access token of the User. It will be null if the origin of the user is local.");
migrationBuilder.CreateIndex(
name: "IX_user_token",
table: "user",
column: "token",
unique: true);
}
}
}

View file

@ -22,7 +22,6 @@ namespace Iceshrimp.Backend.Core.Database.Tables;
[Index(nameof(Tags))]
[Index(nameof(AvatarId), IsUnique = true)]
[Index(nameof(BannerId), IsUnique = true)]
[Index(nameof(Token), IsUnique = true)]
public class User : IEntity
{
/// <summary>
@ -183,13 +182,6 @@ public class User : IEntity
[StringLength(512)]
public string? Uri { get; set; }
/// <summary>
/// The native access token of the User. It will be null if the origin of the user is local.
/// </summary>
[Column("token")]
[StringLength(16)]
public string? Token { get; set; }
/// <summary>
/// Whether the User is explorable.
/// </summary>
@ -205,8 +197,6 @@ public class User : IEntity
[Column("lastActiveDate")] public DateTime? LastActiveDate { get; set; }
[Column("hideOnlineStatus")] public bool HideOnlineStatus { get; set; }
/// <summary>
/// Whether the User is deleted.
/// </summary>
@ -658,7 +648,6 @@ public class UserEntityTypeConfiguration : IEntityTypeConfiguration<User>
entity.Property(e => e.FollowingCount)
.HasDefaultValue(0)
.HasComment("The count of following.");
entity.Property(e => e.HideOnlineStatus).HasDefaultValue(false);
entity.Property(e => e.Host)
.HasComment("The host of the User. It will be null if the origin of the user is local.");
entity.Property(e => e.Inbox)
@ -701,9 +690,6 @@ public class UserEntityTypeConfiguration : IEntityTypeConfiguration<User>
.HasDefaultValue(true)
.HasComment("Whether to speak as a cat if isCat.");
entity.Property(e => e.Tags).HasDefaultValueSql("'{}'::character varying[]");
entity.Property(e => e.Token)
.IsFixedLength()
.HasComment("The native access token of the User. It will be null if the origin of the user is local.");
entity.Property(e => e.UpdatedAt).HasComment("The updated date of the User.");
entity.Property(e => e.Uri)
.HasComment("The URI of the User. It will be null if the origin of the user is local.");