was added firebase nitifying

This commit is contained in:
Artemy
2026-03-01 16:48:06 +07:00
parent 76d7280c71
commit eab0d746b8
60 changed files with 2335 additions and 1149 deletions
@@ -1,763 +0,0 @@
// <auto-generated />
using System;
using Govor.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Govor.Data.Migrations
{
[DbContext(typeof(GovorDbContext))]
[Migration("20251019125424_InitialCreate")]
partial class InitialCreate
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.6")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Govor.Core.Models.ChatGroup", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("character varying(500)");
b.Property<Guid>("ImageId")
.HasColumnType("uuid");
b.Property<bool>("IsChannel")
.HasColumnType("boolean");
b.Property<bool>("IsPrivate")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.HasKey("Id");
b.ToTable("ChatGroups");
});
modelBuilder.Entity("Govor.Core.Models.Friendship", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("AddresseeId")
.HasColumnType("uuid");
b.Property<Guid>("RequesterId")
.HasColumnType("uuid");
b.Property<int>("Status")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("AddresseeId");
b.HasIndex("RequesterId");
b.ToTable("Friendships");
});
modelBuilder.Entity("Govor.Core.Models.GroupAdmins", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("GroupId")
.HasColumnType("uuid");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("GroupId");
b.ToTable("GroupAdmins");
});
modelBuilder.Entity("Govor.Core.Models.GroupInvitation", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("character varying(500)");
b.Property<DateTime>("EndDate")
.HasColumnType("timestamp with time zone");
b.Property<Guid>("GroupId")
.HasColumnType("uuid");
b.Property<string>("InvitationCode")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<int>("MaxParticipants")
.HasColumnType("integer");
b.Property<Guid>("UserMakerId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("GroupId");
b.HasIndex("UserMakerId");
b.ToTable("GroupInvitations");
});
modelBuilder.Entity("Govor.Core.Models.GroupMembership", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("GroupId")
.HasColumnType("uuid");
b.Property<Guid?>("InvitationId")
.HasColumnType("uuid");
b.Property<bool>("IsBanned")
.HasColumnType("boolean");
b.Property<DateTime>("MemberSince")
.HasColumnType("timestamp with time zone");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("GroupId");
b.HasIndex("InvitationId");
b.ToTable("GroupMemberships");
});
modelBuilder.Entity("Govor.Core.Models.Invitation", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Code")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("EndDate")
.HasColumnType("timestamp with time zone");
b.Property<bool>("IsActive")
.HasColumnType("boolean");
b.Property<bool>("IsAdmin")
.HasColumnType("boolean");
b.Property<int>("MaxParticipants")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("Invitations");
});
modelBuilder.Entity("Govor.Core.Models.MediaFile", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone");
b.Property<string>("MediaType")
.IsRequired()
.HasColumnType("text");
b.Property<string>("MineType")
.IsRequired()
.HasMaxLength(128)
.HasColumnType("character varying(128)");
b.Property<Guid>("UploaderId")
.HasColumnType("uuid");
b.Property<string>("Url")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("MediaFiles");
});
modelBuilder.Entity("Govor.Core.Models.Messages.MediaAttachments", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("MediaFileId")
.HasColumnType("uuid");
b.Property<Guid>("MessageId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("MediaFileId");
b.HasIndex("MessageId");
b.ToTable("MediaAttachments");
});
modelBuilder.Entity("Govor.Core.Models.Messages.Message", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid?>("ChatGroupId")
.HasColumnType("uuid");
b.Property<DateTime?>("EditedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("EncryptedContent")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsEdited")
.HasColumnType("boolean");
b.Property<Guid?>("PrivateChatId")
.HasColumnType("uuid");
b.Property<Guid>("RecipientId")
.HasColumnType("uuid");
b.Property<int>("RecipientType")
.HasColumnType("integer");
b.Property<Guid?>("ReplyToMessageId")
.HasColumnType("uuid");
b.Property<Guid>("SenderId")
.HasColumnType("uuid");
b.Property<DateTime>("SentAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("ChatGroupId");
b.HasIndex("PrivateChatId");
b.ToTable("Messages");
});
modelBuilder.Entity("Govor.Core.Models.Messages.MessageReaction", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("MessageId")
.HasColumnType("uuid");
b.Property<DateTime>("ReactedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("ReactionCode")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("character varying(64)");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("UserId");
b.HasIndex("MessageId", "UserId")
.IsUnique();
b.ToTable("MessageReactions");
});
modelBuilder.Entity("Govor.Core.Models.Messages.MessageView", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("MessageId")
.HasColumnType("uuid");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.Property<DateTime>("ViewedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("MessageId", "UserId")
.IsUnique();
b.ToTable("MessageViews");
});
modelBuilder.Entity("Govor.Core.Models.PrivateChat", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("UserAId")
.HasColumnType("uuid");
b.Property<Guid>("UserBId")
.HasColumnType("uuid");
b.HasKey("Id");
b.ToTable("PrivateChats");
});
modelBuilder.Entity("Govor.Core.Models.Users.Admin", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("UserId");
b.ToTable("Admins");
});
modelBuilder.Entity("Govor.Core.Models.Users.Crypto.OneTimePreKey", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<bool>("IsUsed")
.ValueGeneratedOnAdd()
.HasColumnType("boolean")
.HasDefaultValue(false);
b.Property<byte[]>("PublicKey")
.IsRequired()
.HasColumnType("bytea");
b.Property<DateTime>("UploadedAt")
.HasColumnType("timestamp with time zone");
b.Property<Guid>("UserCryptoSessionId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("UploadedAt");
b.HasIndex("UserCryptoSessionId", "IsUsed");
b.ToTable("OneTimePreKeys");
});
modelBuilder.Entity("Govor.Core.Models.Users.Crypto.SignedPreKey", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<byte[]>("PublicSignedPreKey")
.IsRequired()
.HasColumnType("bytea");
b.Property<byte[]>("SignedPreKeySignature")
.IsRequired()
.HasColumnType("bytea");
b.Property<Guid>("UserCryptoSessionId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("UserCryptoSessionId")
.IsUnique();
b.ToTable("SignedPreKeys");
});
modelBuilder.Entity("Govor.Core.Models.Users.Crypto.UserCryptoSession", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<byte[]>("PublicIdentityKey")
.IsRequired()
.HasColumnType("bytea");
b.Property<Guid>("UserSessionId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("UserSessionId")
.IsUnique();
b.ToTable("UserCryptoSessions");
});
modelBuilder.Entity("Govor.Core.Models.Users.User", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateOnly>("CreatedOn")
.HasColumnType("date");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("IconId")
.HasColumnType("uuid");
b.Property<Guid>("InviteId")
.HasColumnType("uuid");
b.Property<string>("PasswordHash")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Username")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("WasOnline")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("InviteId");
b.ToTable("Users");
});
modelBuilder.Entity("Govor.Core.Models.Users.UserSession", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("DeviceInfo")
.IsRequired()
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<DateTime>("ExpiresAt")
.HasColumnType("timestamp with time zone");
b.Property<bool>("IsRevoked")
.HasColumnType("boolean");
b.Property<string>("RefreshToken")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("UserSessions");
});
modelBuilder.Entity("Govor.Core.Models.Friendship", b =>
{
b.HasOne("Govor.Core.Models.Users.User", "Addressee")
.WithMany("ReceivedFriendRequests")
.HasForeignKey("AddresseeId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("Govor.Core.Models.Users.User", "Requester")
.WithMany("SentFriendRequests")
.HasForeignKey("RequesterId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Addressee");
b.Navigation("Requester");
});
modelBuilder.Entity("Govor.Core.Models.GroupAdmins", b =>
{
b.HasOne("Govor.Core.Models.ChatGroup", null)
.WithMany("Admins")
.HasForeignKey("GroupId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Govor.Core.Models.GroupInvitation", b =>
{
b.HasOne("Govor.Core.Models.ChatGroup", null)
.WithMany("InviteCodes")
.HasForeignKey("GroupId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Govor.Core.Models.Users.User", "UserMaker")
.WithMany()
.HasForeignKey("UserMakerId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("UserMaker");
});
modelBuilder.Entity("Govor.Core.Models.GroupMembership", b =>
{
b.HasOne("Govor.Core.Models.ChatGroup", null)
.WithMany("Members")
.HasForeignKey("GroupId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Govor.Core.Models.GroupInvitation", null)
.WithMany()
.HasForeignKey("InvitationId")
.OnDelete(DeleteBehavior.SetNull);
});
modelBuilder.Entity("Govor.Core.Models.Messages.MediaAttachments", b =>
{
b.HasOne("Govor.Core.Models.MediaFile", "MediaFile")
.WithMany()
.HasForeignKey("MediaFileId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("Govor.Core.Models.Messages.Message", "Message")
.WithMany("MediaAttachments")
.HasForeignKey("MessageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("MediaFile");
b.Navigation("Message");
});
modelBuilder.Entity("Govor.Core.Models.Messages.Message", b =>
{
b.HasOne("Govor.Core.Models.ChatGroup", null)
.WithMany("Messages")
.HasForeignKey("ChatGroupId");
b.HasOne("Govor.Core.Models.PrivateChat", null)
.WithMany("Messages")
.HasForeignKey("PrivateChatId");
});
modelBuilder.Entity("Govor.Core.Models.Messages.MessageReaction", b =>
{
b.HasOne("Govor.Core.Models.Messages.Message", "Message")
.WithMany("Reactions")
.HasForeignKey("MessageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Govor.Core.Models.Users.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Message");
b.Navigation("User");
});
modelBuilder.Entity("Govor.Core.Models.Messages.MessageView", b =>
{
b.HasOne("Govor.Core.Models.Messages.Message", null)
.WithMany("MessageViews")
.HasForeignKey("MessageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Govor.Core.Models.Users.Admin", b =>
{
b.HasOne("Govor.Core.Models.Users.User", "User")
.WithOne()
.HasForeignKey("Govor.Core.Models.Users.Admin", "UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("Govor.Core.Models.Users.Crypto.OneTimePreKey", b =>
{
b.HasOne("Govor.Core.Models.Users.Crypto.UserCryptoSession", "UserCryptoSession")
.WithMany("OneTimePreKeys")
.HasForeignKey("UserCryptoSessionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("UserCryptoSession");
});
modelBuilder.Entity("Govor.Core.Models.Users.Crypto.SignedPreKey", b =>
{
b.HasOne("Govor.Core.Models.Users.Crypto.UserCryptoSession", "UserCryptoSession")
.WithOne("SignedPreKey")
.HasForeignKey("Govor.Core.Models.Users.Crypto.SignedPreKey", "UserCryptoSessionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("UserCryptoSession");
});
modelBuilder.Entity("Govor.Core.Models.Users.Crypto.UserCryptoSession", b =>
{
b.HasOne("Govor.Core.Models.Users.UserSession", "UserSession")
.WithOne("CryptoSession")
.HasForeignKey("Govor.Core.Models.Users.Crypto.UserCryptoSession", "UserSessionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("UserSession");
});
modelBuilder.Entity("Govor.Core.Models.Users.User", b =>
{
b.HasOne("Govor.Core.Models.Invitation", "Invite")
.WithMany("Users")
.HasForeignKey("InviteId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Invite");
});
modelBuilder.Entity("Govor.Core.Models.Users.UserSession", b =>
{
b.HasOne("Govor.Core.Models.Users.User", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Govor.Core.Models.ChatGroup", b =>
{
b.Navigation("Admins");
b.Navigation("InviteCodes");
b.Navigation("Members");
b.Navigation("Messages");
});
modelBuilder.Entity("Govor.Core.Models.Invitation", b =>
{
b.Navigation("Users");
});
modelBuilder.Entity("Govor.Core.Models.Messages.Message", b =>
{
b.Navigation("MediaAttachments");
b.Navigation("MessageViews");
b.Navigation("Reactions");
});
modelBuilder.Entity("Govor.Core.Models.PrivateChat", b =>
{
b.Navigation("Messages");
});
modelBuilder.Entity("Govor.Core.Models.Users.Crypto.UserCryptoSession", b =>
{
b.Navigation("OneTimePreKeys");
b.Navigation("SignedPreKey")
.IsRequired();
});
modelBuilder.Entity("Govor.Core.Models.Users.User", b =>
{
b.Navigation("ReceivedFriendRequests");
b.Navigation("SentFriendRequests");
});
modelBuilder.Entity("Govor.Core.Models.Users.UserSession", b =>
{
b.Navigation("CryptoSession")
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}
@@ -1,40 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Govor.Data.Migrations
{
/// <inheritdoc />
public partial class MediaOwnerTypeAdded : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<Guid>(
name: "OwnerId",
table: "MediaFiles",
type: "uuid",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "OwnerType",
table: "MediaFiles",
type: "integer",
nullable: false,
defaultValue: 0);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "OwnerId",
table: "MediaFiles");
migrationBuilder.DropColumn(
name: "OwnerType",
table: "MediaFiles");
}
}
}
@@ -1,94 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Govor.Data.Migrations
{
/// <inheritdoc />
public partial class update_sessions_model : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "RefreshToken",
table: "UserSessions",
newName: "RefreshTokenHash");
migrationBuilder.AlterColumn<string>(
name: "Username",
table: "Users",
type: "character varying(50)",
maxLength: 50,
nullable: false,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "PasswordHash",
table: "Users",
type: "character varying(128)",
maxLength: 128,
nullable: false,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "Description",
table: "Users",
type: "character varying(500)",
maxLength: 500,
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.CreateIndex(
name: "IX_Users_Username",
table: "Users",
column: "Username",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_Users_Username",
table: "Users");
migrationBuilder.RenameColumn(
name: "RefreshTokenHash",
table: "UserSessions",
newName: "RefreshToken");
migrationBuilder.AlterColumn<string>(
name: "Username",
table: "Users",
type: "text",
nullable: false,
oldClrType: typeof(string),
oldType: "character varying(50)",
oldMaxLength: 50);
migrationBuilder.AlterColumn<string>(
name: "PasswordHash",
table: "Users",
type: "text",
nullable: false,
oldClrType: typeof(string),
oldType: "character varying(128)",
oldMaxLength: 128);
migrationBuilder.AlterColumn<string>(
name: "Description",
table: "Users",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "character varying(500)",
oldMaxLength: 500,
oldNullable: true);
}
}
}
@@ -12,8 +12,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace Govor.Data.Migrations
{
[DbContext(typeof(GovorDbContext))]
[Migration("20251103060801_MediaOwnerTypeAdded")]
partial class MediaOwnerTypeAdded
[Migration("20260301080331_Init")]
partial class Init
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@@ -74,6 +74,9 @@ namespace Govor.Data.Migrations
b.HasIndex("AddresseeId");
b.HasIndex("Id")
.IsUnique();
b.HasIndex("RequesterId");
b.ToTable("Friendships");
@@ -300,8 +303,14 @@ namespace Govor.Data.Migrations
b.HasIndex("ChatGroupId");
b.HasIndex("Id")
.IsUnique();
b.HasIndex("PrivateChatId");
b.HasIndex("RecipientId")
.IsUnique();
b.ToTable("Messages");
});
@@ -372,6 +381,9 @@ namespace Govor.Data.Migrations
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.ToTable("PrivateChats");
});
@@ -471,8 +483,8 @@ namespace Govor.Data.Migrations
.HasColumnType("date");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
.HasMaxLength(500)
.HasColumnType("character varying(500)");
b.Property<Guid>("IconId")
.HasColumnType("uuid");
@@ -482,22 +494,83 @@ namespace Govor.Data.Migrations
b.Property<string>("PasswordHash")
.IsRequired()
.HasColumnType("text");
.HasMaxLength(128)
.HasColumnType("character varying(128)");
b.Property<string>("Username")
.IsRequired()
.HasColumnType("text");
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime>("WasOnline")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("CreatedOn");
b.HasIndex("InviteId");
b.HasIndex("Username")
.IsUnique();
b.HasIndex("WasOnline");
b.ToTable("Users");
});
modelBuilder.Entity("Govor.Core.Models.Users.UserPushToken", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<bool>("IsActive")
.HasColumnType("boolean");
b.Property<DateTime?>("LastUsedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Platform")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Provider")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Token")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.Property<Guid?>("UserSessionId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("Token")
.IsUnique();
b.HasIndex("UserId")
.IsUnique();
b.HasIndex("UserSessionId")
.IsUnique();
b.HasIndex("UserId", "IsActive");
b.ToTable("UserPushTokens");
});
modelBuilder.Entity("Govor.Core.Models.Users.UserSession", b =>
{
b.Property<Guid>("Id")
@@ -518,7 +591,7 @@ namespace Govor.Data.Migrations
b.Property<bool>("IsRevoked")
.HasColumnType("boolean");
b.Property<string>("RefreshToken")
b.Property<string>("RefreshTokenHash")
.IsRequired()
.HasColumnType("text");
@@ -527,6 +600,12 @@ namespace Govor.Data.Migrations
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.HasIndex("RefreshTokenHash")
.IsUnique();
b.HasIndex("UserId");
b.ToTable("UserSessions");
@@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
namespace Govor.Data.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
public partial class Init : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
@@ -54,7 +54,9 @@ namespace Govor.Data.Migrations
Url = table.Column<string>(type: "text", nullable: false),
MediaType = table.Column<string>(type: "text", nullable: false),
MineType = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false),
DateCreated = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
DateCreated = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
OwnerType = table.Column<int>(type: "integer", nullable: false),
OwnerId = table.Column<Guid>(type: "uuid", nullable: true)
},
constraints: table =>
{
@@ -74,6 +76,26 @@ namespace Govor.Data.Migrations
table.PrimaryKey("PK_PrivateChats", x => x.Id);
});
migrationBuilder.CreateTable(
name: "UserPushTokens",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
UserId = table.Column<Guid>(type: "uuid", nullable: false),
UserSessionId = table.Column<Guid>(type: "uuid", nullable: true),
Token = table.Column<string>(type: "text", nullable: false),
Provider = table.Column<string>(type: "text", nullable: false),
Platform = table.Column<string>(type: "text", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
LastUsedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
IsActive = table.Column<bool>(type: "boolean", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_UserPushTokens", x => x.Id);
});
migrationBuilder.CreateTable(
name: "GroupAdmins",
columns: table => new
@@ -98,9 +120,9 @@ namespace Govor.Data.Migrations
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Username = table.Column<string>(type: "text", nullable: false),
Description = table.Column<string>(type: "text", nullable: false),
PasswordHash = table.Column<string>(type: "text", nullable: false),
Username = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
Description = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: true),
PasswordHash = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false),
IconId = table.Column<Guid>(type: "uuid", nullable: false),
CreatedOn = table.Column<DateOnly>(type: "date", nullable: false),
WasOnline = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
@@ -227,7 +249,7 @@ namespace Govor.Data.Migrations
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
UserId = table.Column<Guid>(type: "uuid", nullable: false),
RefreshToken = table.Column<string>(type: "text", nullable: false),
RefreshTokenHash = table.Column<string>(type: "text", nullable: false),
DeviceInfo = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
ExpiresAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
@@ -409,6 +431,12 @@ namespace Govor.Data.Migrations
table: "Friendships",
column: "AddresseeId");
migrationBuilder.CreateIndex(
name: "IX_Friendships_Id",
table: "Friendships",
column: "Id",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Friendships_RequesterId",
table: "Friendships",
@@ -465,11 +493,23 @@ namespace Govor.Data.Migrations
table: "Messages",
column: "ChatGroupId");
migrationBuilder.CreateIndex(
name: "IX_Messages_Id",
table: "Messages",
column: "Id",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Messages_PrivateChatId",
table: "Messages",
column: "PrivateChatId");
migrationBuilder.CreateIndex(
name: "IX_Messages_RecipientId",
table: "Messages",
column: "RecipientId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_MessageViews_MessageId_UserId",
table: "MessageViews",
@@ -486,6 +526,12 @@ namespace Govor.Data.Migrations
table: "OneTimePreKeys",
columns: new[] { "UserCryptoSessionId", "IsUsed" });
migrationBuilder.CreateIndex(
name: "IX_PrivateChats_Id",
table: "PrivateChats",
column: "Id",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_SignedPreKeys_UserCryptoSessionId",
table: "SignedPreKeys",
@@ -498,11 +544,62 @@ namespace Govor.Data.Migrations
column: "UserSessionId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_UserPushTokens_Token",
table: "UserPushTokens",
column: "Token",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_UserPushTokens_UserId",
table: "UserPushTokens",
column: "UserId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_UserPushTokens_UserId_IsActive",
table: "UserPushTokens",
columns: new[] { "UserId", "IsActive" });
migrationBuilder.CreateIndex(
name: "IX_UserPushTokens_UserSessionId",
table: "UserPushTokens",
column: "UserSessionId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Users_CreatedOn",
table: "Users",
column: "CreatedOn");
migrationBuilder.CreateIndex(
name: "IX_Users_InviteId",
table: "Users",
column: "InviteId");
migrationBuilder.CreateIndex(
name: "IX_Users_Username",
table: "Users",
column: "Username",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Users_WasOnline",
table: "Users",
column: "WasOnline");
migrationBuilder.CreateIndex(
name: "IX_UserSessions_Id",
table: "UserSessions",
column: "Id",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_UserSessions_RefreshTokenHash",
table: "UserSessions",
column: "RefreshTokenHash",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_UserSessions_UserId",
table: "UserSessions",
@@ -539,6 +636,9 @@ namespace Govor.Data.Migrations
migrationBuilder.DropTable(
name: "SignedPreKeys");
migrationBuilder.DropTable(
name: "UserPushTokens");
migrationBuilder.DropTable(
name: "GroupInvitations");
@@ -12,8 +12,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace Govor.Data.Migrations
{
[DbContext(typeof(GovorDbContext))]
[Migration("20251214065852_update_sessions_model")]
partial class update_sessions_model
[Migration("20260301091506_FixRecipientIndex")]
partial class FixRecipientIndex
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@@ -302,6 +302,8 @@ namespace Govor.Data.Migrations
b.HasIndex("PrivateChatId");
b.HasIndex("RecipientId");
b.ToTable("Messages");
});
@@ -495,14 +497,70 @@ namespace Govor.Data.Migrations
b.HasKey("Id");
b.HasIndex("CreatedOn");
b.HasIndex("InviteId");
b.HasIndex("Username")
.IsUnique();
b.HasIndex("WasOnline");
b.ToTable("Users");
});
modelBuilder.Entity("Govor.Core.Models.Users.UserPushToken", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<bool>("IsActive")
.HasColumnType("boolean");
b.Property<DateTime?>("LastUsedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Platform")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Provider")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Token")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.Property<Guid?>("UserSessionId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("Token")
.IsUnique();
b.HasIndex("UserId")
.IsUnique();
b.HasIndex("UserSessionId")
.IsUnique();
b.HasIndex("UserId", "IsActive");
b.ToTable("UserPushTokens");
});
modelBuilder.Entity("Govor.Core.Models.Users.UserSession", b =>
{
b.Property<Guid>("Id")
@@ -532,6 +590,12 @@ namespace Govor.Data.Migrations
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.HasIndex("RefreshTokenHash")
.IsUnique();
b.HasIndex("UserId");
b.ToTable("UserSessions");
@@ -0,0 +1,67 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Govor.Data.Migrations
{
/// <inheritdoc />
public partial class FixRecipientIndex : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_PrivateChats_Id",
table: "PrivateChats");
migrationBuilder.DropIndex(
name: "IX_Messages_Id",
table: "Messages");
migrationBuilder.DropIndex(
name: "IX_Messages_RecipientId",
table: "Messages");
migrationBuilder.DropIndex(
name: "IX_Friendships_Id",
table: "Friendships");
migrationBuilder.CreateIndex(
name: "IX_Messages_RecipientId",
table: "Messages",
column: "RecipientId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_Messages_RecipientId",
table: "Messages");
migrationBuilder.CreateIndex(
name: "IX_PrivateChats_Id",
table: "PrivateChats",
column: "Id",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Messages_Id",
table: "Messages",
column: "Id",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Messages_RecipientId",
table: "Messages",
column: "RecipientId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Friendships_Id",
table: "Friendships",
column: "Id",
unique: true);
}
}
}
@@ -299,6 +299,8 @@ namespace Govor.Data.Migrations
b.HasIndex("PrivateChatId");
b.HasIndex("RecipientId");
b.ToTable("Messages");
});
@@ -492,14 +494,70 @@ namespace Govor.Data.Migrations
b.HasKey("Id");
b.HasIndex("CreatedOn");
b.HasIndex("InviteId");
b.HasIndex("Username")
.IsUnique();
b.HasIndex("WasOnline");
b.ToTable("Users");
});
modelBuilder.Entity("Govor.Core.Models.Users.UserPushToken", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<bool>("IsActive")
.HasColumnType("boolean");
b.Property<DateTime?>("LastUsedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Platform")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Provider")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Token")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.Property<Guid?>("UserSessionId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("Token")
.IsUnique();
b.HasIndex("UserId")
.IsUnique();
b.HasIndex("UserSessionId")
.IsUnique();
b.HasIndex("UserId", "IsActive");
b.ToTable("UserPushTokens");
});
modelBuilder.Entity("Govor.Core.Models.Users.UserSession", b =>
{
b.Property<Guid>("Id")
@@ -529,6 +587,12 @@ namespace Govor.Data.Migrations
b.HasKey("Id");
b.HasIndex("Id")
.IsUnique();
b.HasIndex("RefreshTokenHash")
.IsUnique();
b.HasIndex("UserId");
b.ToTable("UserSessions");