添加项目文件。

This commit is contained in:
heiye111
2026-05-19 21:55:48 +08:00
parent 4dfb6cd5ae
commit b3e57cd13c
24 changed files with 3074 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using WebAppServer1.ApplicationDbContext;
#nullable disable
namespace WebAppServer1.Migrations
{
[DbContext(typeof(AppDbContext))]
[Migration("20260516024729_InitialCreate")]
partial class InitialCreate
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "10.0.8")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("WebAppServer1.Models.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("CreatedDate")
.HasColumnType("timestamp with time zone");
b.Property<DateTime>("LastModifiedDate")
.HasColumnType("timestamp with time zone");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<string>("Password")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Users");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,39 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace WebAppServer1.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Users",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: true),
CreatedDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
LastModifiedDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
Password = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Users", x => x.Id);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Users");
}
}
}

View File

@@ -0,0 +1,90 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using WebAppServer1.ApplicationDbContext;
#nullable disable
namespace WebAppServer1.Migrations
{
[DbContext(typeof(AppDbContext))]
[Migration("20260517061910_tokens")]
partial class tokens
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "10.0.8")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("WebAppServer1.Models.Tokens", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("ExpiresAt")
.HasColumnType("timestamp with time zone");
b.Property<bool>("IsRevoked")
.HasColumnType("boolean");
b.Property<DateTime>("IssuedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("RefreshToken")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.Property<string>("UserName")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Tokens");
});
modelBuilder.Entity("WebAppServer1.Models.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("CreatedDate")
.HasColumnType("timestamp with time zone");
b.Property<DateTime>("LastModifiedDate")
.HasColumnType("timestamp with time zone");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Users");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,41 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace WebAppServer1.Migrations
{
/// <inheritdoc />
public partial class tokens : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Tokens",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
RefreshToken = table.Column<string>(type: "text", nullable: false),
UserId = table.Column<int>(type: "integer", nullable: false),
UserName = table.Column<string>(type: "text", nullable: false),
IssuedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
ExpiresAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
IsRevoked = table.Column<bool>(type: "boolean", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Tokens", x => x.Id);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Tokens");
}
}
}

View File

@@ -0,0 +1,509 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using WebAppServer1.ApplicationDbContext;
#nullable disable
namespace WebAppServer1.Migrations
{
[DbContext(typeof(AppDbContext))]
[Migration("20260519032425_InitialFriends")]
partial class InitialFriends
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "10.0.8")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("WebAppServer1.Models.FileEntity", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("FileType")
.HasColumnType("integer");
b.Property<string>("FileUrl")
.IsRequired()
.HasColumnType("text");
b.Property<int>("MessageId")
.HasColumnType("integer");
b.Property<int>("Size")
.HasColumnType("integer");
b.Property<DateTime>("UploadedAt")
.HasColumnType("timestamp with time zone");
b.Property<int>("UploaderId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("MessageId");
b.HasIndex("UploaderId");
b.ToTable("Files");
});
modelBuilder.Entity("WebAppServer1.Models.Friend", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<int>("FriendId")
.HasColumnType("integer");
b.Property<int>("Status")
.HasColumnType("integer");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("FriendId");
b.HasIndex("UserId");
b.ToTable("Friends");
});
modelBuilder.Entity("WebAppServer1.Models.Group", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("AvatarUrl")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("OwnerId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("OwnerId");
b.ToTable("Groups");
});
modelBuilder.Entity("WebAppServer1.Models.GroupMember", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("GroupId")
.HasColumnType("integer");
b.Property<DateTime>("JoinedAt")
.HasColumnType("timestamp with time zone");
b.Property<int>("Role")
.HasColumnType("integer");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("GroupId");
b.HasIndex("UserId");
b.ToTable("GroupMembers");
});
modelBuilder.Entity("WebAppServer1.Models.LoginRecord", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("DeviceInfo")
.IsRequired()
.HasColumnType("text");
b.Property<string>("IpAddress")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsSuccess")
.HasColumnType("boolean");
b.Property<DateTime>("LoginTime")
.HasColumnType("timestamp with time zone");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("LoginRecords");
});
modelBuilder.Entity("WebAppServer1.Models.Message", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Content")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<int?>("GroupId")
.HasColumnType("integer");
b.Property<bool>("IsDeleted")
.HasColumnType("boolean");
b.Property<bool>("IsRead")
.HasColumnType("boolean");
b.Property<int>("MessageType")
.HasColumnType("integer");
b.Property<int?>("ReceiverId")
.HasColumnType("integer");
b.Property<int>("SenderId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("GroupId");
b.HasIndex("ReceiverId");
b.HasIndex("SenderId");
b.ToTable("Messages");
});
modelBuilder.Entity("WebAppServer1.Models.Notification", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Content")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<bool>("IsRead")
.HasColumnType("boolean");
b.Property<int>("Type")
.HasColumnType("integer");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Notifications");
});
modelBuilder.Entity("WebAppServer1.Models.Tokens", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("ExpiresAt")
.HasColumnType("timestamp with time zone");
b.Property<bool>("IsRevoked")
.HasColumnType("boolean");
b.Property<DateTime>("IssuedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("RefreshToken")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.Property<string>("UserName")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Tokens");
});
modelBuilder.Entity("WebAppServer1.Models.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("AvatarUrl")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsOnline")
.HasColumnType("boolean");
b.Property<DateTime>("LastActive")
.HasColumnType("timestamp with time zone");
b.Property<string>("PasswordHash")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Signature")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Username")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Users");
});
modelBuilder.Entity("WebAppServer1.Models.UserProfileHistory", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("ChangedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("ChangedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("FieldName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("NewValue")
.IsRequired()
.HasColumnType("text");
b.Property<string>("OldValue")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("userProfileHistories");
});
modelBuilder.Entity("WebAppServer1.Models.FileEntity", b =>
{
b.HasOne("WebAppServer1.Models.Message", "Message")
.WithMany()
.HasForeignKey("MessageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("WebAppServer1.Models.User", "Uploader")
.WithMany()
.HasForeignKey("UploaderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Message");
b.Navigation("Uploader");
});
modelBuilder.Entity("WebAppServer1.Models.Friend", b =>
{
b.HasOne("WebAppServer1.Models.User", "FriendUser")
.WithMany()
.HasForeignKey("FriendId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("WebAppServer1.Models.User", "User")
.WithMany("Friends")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("FriendUser");
b.Navigation("User");
});
modelBuilder.Entity("WebAppServer1.Models.Group", b =>
{
b.HasOne("WebAppServer1.Models.User", "Owner")
.WithMany()
.HasForeignKey("OwnerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Owner");
});
modelBuilder.Entity("WebAppServer1.Models.GroupMember", b =>
{
b.HasOne("WebAppServer1.Models.Group", "Group")
.WithMany("Members")
.HasForeignKey("GroupId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("WebAppServer1.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Group");
b.Navigation("User");
});
modelBuilder.Entity("WebAppServer1.Models.LoginRecord", b =>
{
b.HasOne("WebAppServer1.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("WebAppServer1.Models.Message", b =>
{
b.HasOne("WebAppServer1.Models.Group", "Group")
.WithMany()
.HasForeignKey("GroupId");
b.HasOne("WebAppServer1.Models.User", "Receiver")
.WithMany()
.HasForeignKey("ReceiverId")
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("WebAppServer1.Models.User", "Sender")
.WithMany("Messages")
.HasForeignKey("SenderId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Group");
b.Navigation("Receiver");
b.Navigation("Sender");
});
modelBuilder.Entity("WebAppServer1.Models.Notification", b =>
{
b.HasOne("WebAppServer1.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("WebAppServer1.Models.UserProfileHistory", b =>
{
b.HasOne("WebAppServer1.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("WebAppServer1.Models.Group", b =>
{
b.Navigation("Members");
});
modelBuilder.Entity("WebAppServer1.Models.User", b =>
{
b.Navigation("Friends");
b.Navigation("Messages");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,408 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace WebAppServer1.Migrations
{
/// <inheritdoc />
public partial class InitialFriends : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "Password",
table: "Users",
newName: "Username");
migrationBuilder.RenameColumn(
name: "Name",
table: "Users",
newName: "Signature");
migrationBuilder.RenameColumn(
name: "LastModifiedDate",
table: "Users",
newName: "LastActive");
migrationBuilder.RenameColumn(
name: "CreatedDate",
table: "Users",
newName: "CreatedAt");
migrationBuilder.AddColumn<string>(
name: "AvatarUrl",
table: "Users",
type: "text",
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<string>(
name: "Email",
table: "Users",
type: "text",
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<bool>(
name: "IsOnline",
table: "Users",
type: "boolean",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<string>(
name: "PasswordHash",
table: "Users",
type: "text",
nullable: false,
defaultValue: "");
migrationBuilder.CreateTable(
name: "Friends",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
UserId = table.Column<int>(type: "integer", nullable: false),
FriendId = table.Column<int>(type: "integer", nullable: false),
Status = table.Column<int>(type: "integer", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Friends", x => x.Id);
table.ForeignKey(
name: "FK_Friends_Users_FriendId",
column: x => x.FriendId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_Friends_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "Groups",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: false),
OwnerId = table.Column<int>(type: "integer", nullable: false),
AvatarUrl = table.Column<string>(type: "text", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Groups", x => x.Id);
table.ForeignKey(
name: "FK_Groups_Users_OwnerId",
column: x => x.OwnerId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "LoginRecords",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
UserId = table.Column<int>(type: "integer", nullable: false),
LoginTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
IpAddress = table.Column<string>(type: "text", nullable: false),
DeviceInfo = table.Column<string>(type: "text", nullable: false),
IsSuccess = table.Column<bool>(type: "boolean", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_LoginRecords", x => x.Id);
table.ForeignKey(
name: "FK_LoginRecords_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Notifications",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
UserId = table.Column<int>(type: "integer", nullable: false),
Type = table.Column<int>(type: "integer", nullable: false),
Content = table.Column<string>(type: "text", nullable: false),
IsRead = table.Column<bool>(type: "boolean", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Notifications", x => x.Id);
table.ForeignKey(
name: "FK_Notifications_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "userProfileHistories",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
UserId = table.Column<int>(type: "integer", nullable: false),
FieldName = table.Column<string>(type: "text", nullable: false),
OldValue = table.Column<string>(type: "text", nullable: false),
NewValue = table.Column<string>(type: "text", nullable: false),
ChangedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
ChangedBy = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_userProfileHistories", x => x.Id);
table.ForeignKey(
name: "FK_userProfileHistories_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "GroupMembers",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
GroupId = table.Column<int>(type: "integer", nullable: false),
UserId = table.Column<int>(type: "integer", nullable: false),
Role = table.Column<int>(type: "integer", nullable: false),
JoinedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_GroupMembers", x => x.Id);
table.ForeignKey(
name: "FK_GroupMembers_Groups_GroupId",
column: x => x.GroupId,
principalTable: "Groups",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_GroupMembers_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Messages",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
SenderId = table.Column<int>(type: "integer", nullable: false),
ReceiverId = table.Column<int>(type: "integer", nullable: true),
GroupId = table.Column<int>(type: "integer", nullable: true),
Content = table.Column<string>(type: "text", nullable: false),
MessageType = table.Column<int>(type: "integer", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
IsRead = table.Column<bool>(type: "boolean", nullable: false),
IsDeleted = table.Column<bool>(type: "boolean", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Messages", x => x.Id);
table.ForeignKey(
name: "FK_Messages_Groups_GroupId",
column: x => x.GroupId,
principalTable: "Groups",
principalColumn: "Id");
table.ForeignKey(
name: "FK_Messages_Users_ReceiverId",
column: x => x.ReceiverId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_Messages_Users_SenderId",
column: x => x.SenderId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "Files",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
UploaderId = table.Column<int>(type: "integer", nullable: false),
MessageId = table.Column<int>(type: "integer", nullable: false),
FileUrl = table.Column<string>(type: "text", nullable: false),
FileType = table.Column<int>(type: "integer", nullable: false),
Size = table.Column<int>(type: "integer", nullable: false),
UploadedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Files", x => x.Id);
table.ForeignKey(
name: "FK_Files_Messages_MessageId",
column: x => x.MessageId,
principalTable: "Messages",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Files_Users_UploaderId",
column: x => x.UploaderId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Files_MessageId",
table: "Files",
column: "MessageId");
migrationBuilder.CreateIndex(
name: "IX_Files_UploaderId",
table: "Files",
column: "UploaderId");
migrationBuilder.CreateIndex(
name: "IX_Friends_FriendId",
table: "Friends",
column: "FriendId");
migrationBuilder.CreateIndex(
name: "IX_Friends_UserId",
table: "Friends",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_GroupMembers_GroupId",
table: "GroupMembers",
column: "GroupId");
migrationBuilder.CreateIndex(
name: "IX_GroupMembers_UserId",
table: "GroupMembers",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_Groups_OwnerId",
table: "Groups",
column: "OwnerId");
migrationBuilder.CreateIndex(
name: "IX_LoginRecords_UserId",
table: "LoginRecords",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_Messages_GroupId",
table: "Messages",
column: "GroupId");
migrationBuilder.CreateIndex(
name: "IX_Messages_ReceiverId",
table: "Messages",
column: "ReceiverId");
migrationBuilder.CreateIndex(
name: "IX_Messages_SenderId",
table: "Messages",
column: "SenderId");
migrationBuilder.CreateIndex(
name: "IX_Notifications_UserId",
table: "Notifications",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_userProfileHistories_UserId",
table: "userProfileHistories",
column: "UserId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Files");
migrationBuilder.DropTable(
name: "Friends");
migrationBuilder.DropTable(
name: "GroupMembers");
migrationBuilder.DropTable(
name: "LoginRecords");
migrationBuilder.DropTable(
name: "Notifications");
migrationBuilder.DropTable(
name: "userProfileHistories");
migrationBuilder.DropTable(
name: "Messages");
migrationBuilder.DropTable(
name: "Groups");
migrationBuilder.DropColumn(
name: "AvatarUrl",
table: "Users");
migrationBuilder.DropColumn(
name: "Email",
table: "Users");
migrationBuilder.DropColumn(
name: "IsOnline",
table: "Users");
migrationBuilder.DropColumn(
name: "PasswordHash",
table: "Users");
migrationBuilder.RenameColumn(
name: "Username",
table: "Users",
newName: "Password");
migrationBuilder.RenameColumn(
name: "Signature",
table: "Users",
newName: "Name");
migrationBuilder.RenameColumn(
name: "LastActive",
table: "Users",
newName: "LastModifiedDate");
migrationBuilder.RenameColumn(
name: "CreatedAt",
table: "Users",
newName: "CreatedDate");
}
}
}

View File

@@ -0,0 +1,513 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using WebAppServer1.ApplicationDbContext;
#nullable disable
namespace WebAppServer1.Migrations
{
[DbContext(typeof(AppDbContext))]
[Migration("20260519043509_addNickName")]
partial class addNickName
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "10.0.8")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("WebAppServer1.Models.FileEntity", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("FileType")
.HasColumnType("integer");
b.Property<string>("FileUrl")
.IsRequired()
.HasColumnType("text");
b.Property<int>("MessageId")
.HasColumnType("integer");
b.Property<int>("Size")
.HasColumnType("integer");
b.Property<DateTime>("UploadedAt")
.HasColumnType("timestamp with time zone");
b.Property<int>("UploaderId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("MessageId");
b.HasIndex("UploaderId");
b.ToTable("Files");
});
modelBuilder.Entity("WebAppServer1.Models.Friend", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<int>("FriendId")
.HasColumnType("integer");
b.Property<int>("Status")
.HasColumnType("integer");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("FriendId");
b.HasIndex("UserId");
b.ToTable("Friends");
});
modelBuilder.Entity("WebAppServer1.Models.Group", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("AvatarUrl")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("OwnerId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("OwnerId");
b.ToTable("Groups");
});
modelBuilder.Entity("WebAppServer1.Models.GroupMember", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("GroupId")
.HasColumnType("integer");
b.Property<DateTime>("JoinedAt")
.HasColumnType("timestamp with time zone");
b.Property<int>("Role")
.HasColumnType("integer");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("GroupId");
b.HasIndex("UserId");
b.ToTable("GroupMembers");
});
modelBuilder.Entity("WebAppServer1.Models.LoginRecord", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("DeviceInfo")
.IsRequired()
.HasColumnType("text");
b.Property<string>("IpAddress")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsSuccess")
.HasColumnType("boolean");
b.Property<DateTime>("LoginTime")
.HasColumnType("timestamp with time zone");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("LoginRecords");
});
modelBuilder.Entity("WebAppServer1.Models.Message", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Content")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<int?>("GroupId")
.HasColumnType("integer");
b.Property<bool>("IsDeleted")
.HasColumnType("boolean");
b.Property<bool>("IsRead")
.HasColumnType("boolean");
b.Property<int>("MessageType")
.HasColumnType("integer");
b.Property<int?>("ReceiverId")
.HasColumnType("integer");
b.Property<int>("SenderId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("GroupId");
b.HasIndex("ReceiverId");
b.HasIndex("SenderId");
b.ToTable("Messages");
});
modelBuilder.Entity("WebAppServer1.Models.Notification", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Content")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<bool>("IsRead")
.HasColumnType("boolean");
b.Property<int>("Type")
.HasColumnType("integer");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Notifications");
});
modelBuilder.Entity("WebAppServer1.Models.Tokens", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("ExpiresAt")
.HasColumnType("timestamp with time zone");
b.Property<bool>("IsRevoked")
.HasColumnType("boolean");
b.Property<DateTime>("IssuedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("RefreshToken")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.Property<string>("UserName")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Tokens");
});
modelBuilder.Entity("WebAppServer1.Models.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("AvatarUrl")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsOnline")
.HasColumnType("boolean");
b.Property<DateTime>("LastActive")
.HasColumnType("timestamp with time zone");
b.Property<string>("Nickname")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PasswordHash")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Signature")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Username")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Users");
});
modelBuilder.Entity("WebAppServer1.Models.UserProfileHistory", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("ChangedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("ChangedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("FieldName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("NewValue")
.IsRequired()
.HasColumnType("text");
b.Property<string>("OldValue")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("userProfileHistories");
});
modelBuilder.Entity("WebAppServer1.Models.FileEntity", b =>
{
b.HasOne("WebAppServer1.Models.Message", "Message")
.WithMany()
.HasForeignKey("MessageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("WebAppServer1.Models.User", "Uploader")
.WithMany()
.HasForeignKey("UploaderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Message");
b.Navigation("Uploader");
});
modelBuilder.Entity("WebAppServer1.Models.Friend", b =>
{
b.HasOne("WebAppServer1.Models.User", "FriendUser")
.WithMany()
.HasForeignKey("FriendId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("WebAppServer1.Models.User", "User")
.WithMany("Friends")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("FriendUser");
b.Navigation("User");
});
modelBuilder.Entity("WebAppServer1.Models.Group", b =>
{
b.HasOne("WebAppServer1.Models.User", "Owner")
.WithMany()
.HasForeignKey("OwnerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Owner");
});
modelBuilder.Entity("WebAppServer1.Models.GroupMember", b =>
{
b.HasOne("WebAppServer1.Models.Group", "Group")
.WithMany("Members")
.HasForeignKey("GroupId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("WebAppServer1.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Group");
b.Navigation("User");
});
modelBuilder.Entity("WebAppServer1.Models.LoginRecord", b =>
{
b.HasOne("WebAppServer1.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("WebAppServer1.Models.Message", b =>
{
b.HasOne("WebAppServer1.Models.Group", "Group")
.WithMany()
.HasForeignKey("GroupId");
b.HasOne("WebAppServer1.Models.User", "Receiver")
.WithMany()
.HasForeignKey("ReceiverId")
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("WebAppServer1.Models.User", "Sender")
.WithMany("Messages")
.HasForeignKey("SenderId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Group");
b.Navigation("Receiver");
b.Navigation("Sender");
});
modelBuilder.Entity("WebAppServer1.Models.Notification", b =>
{
b.HasOne("WebAppServer1.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("WebAppServer1.Models.UserProfileHistory", b =>
{
b.HasOne("WebAppServer1.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("WebAppServer1.Models.Group", b =>
{
b.Navigation("Members");
});
modelBuilder.Entity("WebAppServer1.Models.User", b =>
{
b.Navigation("Friends");
b.Navigation("Messages");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,29 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace WebAppServer1.Migrations
{
/// <inheritdoc />
public partial class addNickName : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Nickname",
table: "Users",
type: "text",
nullable: false,
defaultValue: "");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Nickname",
table: "Users");
}
}
}

View File

@@ -0,0 +1,510 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using WebAppServer1.ApplicationDbContext;
#nullable disable
namespace WebAppServer1.Migrations
{
[DbContext(typeof(AppDbContext))]
partial class AppDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "10.0.8")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("WebAppServer1.Models.FileEntity", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("FileType")
.HasColumnType("integer");
b.Property<string>("FileUrl")
.IsRequired()
.HasColumnType("text");
b.Property<int>("MessageId")
.HasColumnType("integer");
b.Property<int>("Size")
.HasColumnType("integer");
b.Property<DateTime>("UploadedAt")
.HasColumnType("timestamp with time zone");
b.Property<int>("UploaderId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("MessageId");
b.HasIndex("UploaderId");
b.ToTable("Files");
});
modelBuilder.Entity("WebAppServer1.Models.Friend", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<int>("FriendId")
.HasColumnType("integer");
b.Property<int>("Status")
.HasColumnType("integer");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("FriendId");
b.HasIndex("UserId");
b.ToTable("Friends");
});
modelBuilder.Entity("WebAppServer1.Models.Group", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("AvatarUrl")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("OwnerId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("OwnerId");
b.ToTable("Groups");
});
modelBuilder.Entity("WebAppServer1.Models.GroupMember", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("GroupId")
.HasColumnType("integer");
b.Property<DateTime>("JoinedAt")
.HasColumnType("timestamp with time zone");
b.Property<int>("Role")
.HasColumnType("integer");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("GroupId");
b.HasIndex("UserId");
b.ToTable("GroupMembers");
});
modelBuilder.Entity("WebAppServer1.Models.LoginRecord", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("DeviceInfo")
.IsRequired()
.HasColumnType("text");
b.Property<string>("IpAddress")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsSuccess")
.HasColumnType("boolean");
b.Property<DateTime>("LoginTime")
.HasColumnType("timestamp with time zone");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("LoginRecords");
});
modelBuilder.Entity("WebAppServer1.Models.Message", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Content")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<int?>("GroupId")
.HasColumnType("integer");
b.Property<bool>("IsDeleted")
.HasColumnType("boolean");
b.Property<bool>("IsRead")
.HasColumnType("boolean");
b.Property<int>("MessageType")
.HasColumnType("integer");
b.Property<int?>("ReceiverId")
.HasColumnType("integer");
b.Property<int>("SenderId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("GroupId");
b.HasIndex("ReceiverId");
b.HasIndex("SenderId");
b.ToTable("Messages");
});
modelBuilder.Entity("WebAppServer1.Models.Notification", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Content")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<bool>("IsRead")
.HasColumnType("boolean");
b.Property<int>("Type")
.HasColumnType("integer");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Notifications");
});
modelBuilder.Entity("WebAppServer1.Models.Tokens", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("ExpiresAt")
.HasColumnType("timestamp with time zone");
b.Property<bool>("IsRevoked")
.HasColumnType("boolean");
b.Property<DateTime>("IssuedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("RefreshToken")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.Property<string>("UserName")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Tokens");
});
modelBuilder.Entity("WebAppServer1.Models.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("AvatarUrl")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsOnline")
.HasColumnType("boolean");
b.Property<DateTime>("LastActive")
.HasColumnType("timestamp with time zone");
b.Property<string>("Nickname")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PasswordHash")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Signature")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Username")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Users");
});
modelBuilder.Entity("WebAppServer1.Models.UserProfileHistory", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("ChangedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("ChangedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("FieldName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("NewValue")
.IsRequired()
.HasColumnType("text");
b.Property<string>("OldValue")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("userProfileHistories");
});
modelBuilder.Entity("WebAppServer1.Models.FileEntity", b =>
{
b.HasOne("WebAppServer1.Models.Message", "Message")
.WithMany()
.HasForeignKey("MessageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("WebAppServer1.Models.User", "Uploader")
.WithMany()
.HasForeignKey("UploaderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Message");
b.Navigation("Uploader");
});
modelBuilder.Entity("WebAppServer1.Models.Friend", b =>
{
b.HasOne("WebAppServer1.Models.User", "FriendUser")
.WithMany()
.HasForeignKey("FriendId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("WebAppServer1.Models.User", "User")
.WithMany("Friends")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("FriendUser");
b.Navigation("User");
});
modelBuilder.Entity("WebAppServer1.Models.Group", b =>
{
b.HasOne("WebAppServer1.Models.User", "Owner")
.WithMany()
.HasForeignKey("OwnerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Owner");
});
modelBuilder.Entity("WebAppServer1.Models.GroupMember", b =>
{
b.HasOne("WebAppServer1.Models.Group", "Group")
.WithMany("Members")
.HasForeignKey("GroupId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("WebAppServer1.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Group");
b.Navigation("User");
});
modelBuilder.Entity("WebAppServer1.Models.LoginRecord", b =>
{
b.HasOne("WebAppServer1.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("WebAppServer1.Models.Message", b =>
{
b.HasOne("WebAppServer1.Models.Group", "Group")
.WithMany()
.HasForeignKey("GroupId");
b.HasOne("WebAppServer1.Models.User", "Receiver")
.WithMany()
.HasForeignKey("ReceiverId")
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("WebAppServer1.Models.User", "Sender")
.WithMany("Messages")
.HasForeignKey("SenderId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Group");
b.Navigation("Receiver");
b.Navigation("Sender");
});
modelBuilder.Entity("WebAppServer1.Models.Notification", b =>
{
b.HasOne("WebAppServer1.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("WebAppServer1.Models.UserProfileHistory", b =>
{
b.HasOne("WebAppServer1.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("WebAppServer1.Models.Group", b =>
{
b.Navigation("Members");
});
modelBuilder.Entity("WebAppServer1.Models.User", b =>
{
b.Navigation("Friends");
b.Navigation("Messages");
});
#pragma warning restore 612, 618
}
}
}