database changes

This commit is contained in:
2024-11-08 22:19:34 +01:00
Unverified
parent ba5d56e17c
commit 046dc26915
20 changed files with 3135 additions and 60 deletions

View File

@@ -0,0 +1,31 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using WatchIt.Database.Model.Account;
namespace WatchIt.Database.Model.Configuration.Account;
public class AccountFollowConfiguration : IEntityTypeConfiguration<AccountFollow>
{
public void Configure(EntityTypeBuilder<AccountFollow> builder)
{
builder.HasKey(x => x.Id);
builder.HasIndex(x => x.Id)
.IsUnique();
builder.Property(x => x.Id)
.IsRequired();
builder.HasOne(x => x.AccountFollower)
.WithMany(x => x.AccountFollows)
.HasForeignKey(x => x.AccountFollowerId)
.IsRequired();
builder.Property(x => x.AccountFollowerId)
.IsRequired();
builder.HasOne(x => x.AccountFollowed)
.WithMany(x => x.AccountFollowedBy)
.HasForeignKey(x => x.AccountFollowedId)
.IsRequired();
builder.Property(x => x.AccountFollowedId)
.IsRequired();
}
}

View File

@@ -20,9 +20,6 @@ public class GenreConfiguration : IEntityTypeConfiguration<Genre>
.HasMaxLength(100)
.IsRequired();
builder.Property(x => x.Description)
.HasMaxLength(1000);
// Navigation
builder.HasMany(x => x.Media)
.WithMany(x => x.Genres)

View File

@@ -39,6 +39,9 @@ public class Account
public virtual IEnumerable<RatingMediaSeriesEpisode> RatingMediaSeriesEpisode { get; set; } = new List<RatingMediaSeriesEpisode>();
public virtual IEnumerable<AccountRefreshToken> AccountRefreshTokens { get; set; } = new List<AccountRefreshToken>();
public virtual IEnumerable<AccountFollow> AccountFollows { get; set; } = new List<AccountFollow>();
public virtual IEnumerable<AccountFollow> AccountFollowedBy { get; set; } = new List<AccountFollow>();
#endregion
}

View File

@@ -0,0 +1,21 @@
namespace WatchIt.Database.Model.Account;
public class AccountFollow
{
#region PROPERTIES
public Guid Id { get; set; }
public long AccountFollowerId { get; set; }
public long AccountFollowedId { get; set; }
#endregion
#region NAVIGATION
public virtual Account AccountFollower { get; set; } = null!;
public virtual Account AccountFollowed { get; set; } = null!;
#endregion
}

View File

@@ -8,7 +8,6 @@ public class Genre
public short Id { get; set; }
public required string Name { get; set; }
public string? Description { get; set; }
#endregion

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,78 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace WatchIt.Database.Migrations
{
/// <inheritdoc />
public partial class GenreDescriptionRemoved : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Description",
table: "Genres");
migrationBuilder.UpdateData(
table: "Accounts",
keyColumn: "Id",
keyValue: 1L,
columns: new[] { "LeftSalt", "Password", "RightSalt" },
values: new object[] { "HIZYSU/94oe$[jAy\\{7V", new byte[] { 118, 180, 133, 0, 25, 6, 65, 230, 20, 221, 180, 8, 111, 189, 191, 158, 98, 160, 80, 196, 146, 99, 90, 55, 196, 219, 245, 244, 167, 89, 123, 74, 37, 92, 234, 81, 74, 199, 149, 128, 7, 213, 202, 191, 162, 62, 19, 144, 206, 83, 80, 237, 37, 179, 12, 215, 61, 179, 94, 189, 30, 98, 100, 164 }, "#(^8YBkY;<X=LKE_7$2p" });
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Description",
table: "Genres",
type: "character varying(1000)",
maxLength: 1000,
nullable: true);
migrationBuilder.UpdateData(
table: "Accounts",
keyColumn: "Id",
keyValue: 1L,
columns: new[] { "LeftSalt", "Password", "RightSalt" },
values: new object[] { "YuJiv1\"R'*0odl8${\\|S", new byte[] { 215, 154, 186, 191, 12, 223, 76, 105, 137, 67, 41, 138, 26, 3, 38, 36, 0, 71, 40, 84, 153, 152, 105, 239, 55, 60, 164, 15, 99, 175, 133, 175, 227, 245, 102, 9, 171, 119, 16, 234, 97, 179, 70, 29, 120, 112, 241, 91, 209, 91, 228, 164, 52, 244, 36, 207, 147, 60, 124, 66, 77, 252, 129, 151 }, "oT2N=y7^5,2o'+N>d}~!" });
migrationBuilder.UpdateData(
table: "Genres",
keyColumn: "Id",
keyValue: (short)1,
column: "Description",
value: null);
migrationBuilder.UpdateData(
table: "Genres",
keyColumn: "Id",
keyValue: (short)2,
column: "Description",
value: null);
migrationBuilder.UpdateData(
table: "Genres",
keyColumn: "Id",
keyValue: (short)3,
column: "Description",
value: null);
migrationBuilder.UpdateData(
table: "Genres",
keyColumn: "Id",
keyValue: (short)4,
column: "Description",
value: null);
migrationBuilder.UpdateData(
table: "Genres",
keyColumn: "Id",
keyValue: (short)5,
column: "Description",
value: null);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,77 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace WatchIt.Database.Migrations
{
/// <inheritdoc />
public partial class AccountFollowAdded : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "AccountFollow",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
AccountFollowerId = table.Column<long>(type: "bigint", nullable: false),
AccountFollowedId = table.Column<long>(type: "bigint", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AccountFollow", x => x.Id);
table.ForeignKey(
name: "FK_AccountFollow_Accounts_AccountFollowedId",
column: x => x.AccountFollowedId,
principalTable: "Accounts",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_AccountFollow_Accounts_AccountFollowerId",
column: x => x.AccountFollowerId,
principalTable: "Accounts",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.UpdateData(
table: "Accounts",
keyColumn: "Id",
keyValue: 1L,
columns: new[] { "LeftSalt", "Password", "RightSalt" },
values: new object[] { "sfA:fW!3D=GbwXn]X+rm", new byte[] { 95, 134, 48, 126, 85, 131, 129, 152, 252, 161, 69, 133, 62, 112, 45, 111, 3, 163, 80, 99, 167, 66, 169, 121, 140, 69, 242, 14, 89, 126, 184, 43, 62, 87, 22, 1, 88, 246, 34, 181, 231, 110, 14, 54, 120, 114, 37, 67, 240, 82, 112, 125, 84, 155, 194, 90, 14, 189, 90, 68, 30, 146, 204, 105 }, "@$rr>fSvr5Ls|D+Wp;?D" });
migrationBuilder.CreateIndex(
name: "IX_AccountFollow_AccountFollowedId",
table: "AccountFollow",
column: "AccountFollowedId");
migrationBuilder.CreateIndex(
name: "IX_AccountFollow_AccountFollowerId",
table: "AccountFollow",
column: "AccountFollowerId");
migrationBuilder.CreateIndex(
name: "IX_AccountFollow_Id",
table: "AccountFollow",
column: "Id",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AccountFollow");
migrationBuilder.UpdateData(
table: "Accounts",
keyColumn: "Id",
keyValue: 1L,
columns: new[] { "LeftSalt", "Password", "RightSalt" },
values: new object[] { "HIZYSU/94oe$[jAy\\{7V", new byte[] { 118, 180, 133, 0, 25, 6, 65, 230, 20, 221, 180, 8, 111, 189, 191, 158, 98, 160, 80, 196, 146, 99, 90, 55, 196, 219, 245, 244, 167, 89, 123, 74, 37, 92, 234, 81, 74, 199, 149, 128, 7, 213, 202, 191, 162, 62, 19, 144, 206, 83, 80, 237, 37, 179, 12, 215, 61, 179, 94, 189, 30, 98, 100, 164 }, "#(^8YBkY;<X=LKE_7$2p" });
}
}
}

View File

@@ -108,13 +108,37 @@ namespace WatchIt.Database.Migrations
Email = "root@watch.it",
IsAdmin = true,
LastActive = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
LeftSalt = "YuJiv1\"R'*0odl8${\\|S",
Password = new byte[] { 215, 154, 186, 191, 12, 223, 76, 105, 137, 67, 41, 138, 26, 3, 38, 36, 0, 71, 40, 84, 153, 152, 105, 239, 55, 60, 164, 15, 99, 175, 133, 175, 227, 245, 102, 9, 171, 119, 16, 234, 97, 179, 70, 29, 120, 112, 241, 91, 209, 91, 228, 164, 52, 244, 36, 207, 147, 60, 124, 66, 77, 252, 129, 151 },
RightSalt = "oT2N=y7^5,2o'+N>d}~!",
LeftSalt = "sfA:fW!3D=GbwXn]X+rm",
Password = new byte[] { 95, 134, 48, 126, 85, 131, 129, 152, 252, 161, 69, 133, 62, 112, 45, 111, 3, 163, 80, 99, 167, 66, 169, 121, 140, 69, 242, 14, 89, 126, 184, 43, 62, 87, 22, 1, 88, 246, 34, 181, 231, 110, 14, 54, 120, 114, 37, 67, 240, 82, 112, 125, 84, 155, 194, 90, 14, 189, 90, 68, 30, 146, 204, 105 },
RightSalt = "@$rr>fSvr5Ls|D+Wp;?D",
Username = "root"
});
});
modelBuilder.Entity("WatchIt.Database.Model.Account.AccountFollow", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<long>("AccountFollowedId")
.HasColumnType("bigint");
b.Property<long>("AccountFollowerId")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("AccountFollowedId");
b.HasIndex("AccountFollowerId");
b.HasIndex("Id")
.IsUnique();
b.ToTable("AccountFollow");
});
modelBuilder.Entity("WatchIt.Database.Model.Account.AccountProfilePicture", b =>
{
b.Property<Guid>("Id")
@@ -249,10 +273,6 @@ namespace WatchIt.Database.Migrations
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<short>("Id"));
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
@@ -997,6 +1017,25 @@ namespace WatchIt.Database.Migrations
b.Navigation("ProfilePicture");
});
modelBuilder.Entity("WatchIt.Database.Model.Account.AccountFollow", b =>
{
b.HasOne("WatchIt.Database.Model.Account.Account", "AccountFollowed")
.WithMany("AccountFollowedBy")
.HasForeignKey("AccountFollowedId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("WatchIt.Database.Model.Account.Account", "AccountFollower")
.WithMany("AccountFollows")
.HasForeignKey("AccountFollowerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("AccountFollowed");
b.Navigation("AccountFollower");
});
modelBuilder.Entity("WatchIt.Database.Model.Account.AccountRefreshToken", b =>
{
b.HasOne("WatchIt.Database.Model.Account.Account", "Account")
@@ -1309,6 +1348,10 @@ namespace WatchIt.Database.Migrations
modelBuilder.Entity("WatchIt.Database.Model.Account.Account", b =>
{
b.Navigation("AccountFollowedBy");
b.Navigation("AccountFollows");
b.Navigation("AccountRefreshTokens");
b.Navigation("RatingMedia");