Skip to content

Commit

Permalink
update notification tble
Browse files Browse the repository at this point in the history
  • Loading branch information
The-DevBlog committed Mar 2, 2024
1 parent b730b43 commit 0bc61e3
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 48 deletions.
2 changes: 0 additions & 2 deletions devblog/devblog/Data/AppDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);

modelBuilder.Entity<Notification>().HasKey(e => new { e.PostId, e.UserName });

modelBuilder.Entity<UpVote>().HasKey(e => new { e.PostId, e.UserName });

modelBuilder.Entity<DownVote>().HasKey(e => new { e.PostId, e.UserName });
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,30 @@ public partial class initial : Migration
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
//migrationBuilder.AlterDatabase()
// .Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterDatabase()
.Annotation("MySql:CharSet", "utf8mb4");

//migrationBuilder.CreateTable(
// name: "Notification",
// columns: table => new
// {
// PostId = table.Column<int>(type: "int", nullable: false),
// UserName = table.Column<string>(type: "varchar(255)", nullable: false)
// .Annotation("MySql:CharSet", "utf8mb4"),
// Author = table.Column<string>(type: "longtext", nullable: false)
// .Annotation("MySql:CharSet", "utf8mb4"),
// ImgUrl = table.Column<string>(type: "longtext", nullable: false)
// .Annotation("MySql:CharSet", "utf8mb4"),
// NotificationType = table.Column<string>(type: "longtext", nullable: false)
// .Annotation("MySql:CharSet", "utf8mb4")
// },
// constraints: table =>
// {
// table.PrimaryKey("PK_Notification", x => new { x.PostId, x.UserName });
// })
// .Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "Notification",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
PostId = table.Column<int>(type: "int", nullable: false),
UserName = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Author = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
ImgUrl = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
NotificationType = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_Notification", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");

//migrationBuilder.CreateTable(
// name: "Post",
Expand Down Expand Up @@ -173,20 +175,6 @@ protected override void Up(MigrationBuilder migrationBuilder)
// table: "YtVideo",
// column: "Url",
// unique: true);

migrationBuilder.AddColumn<string>(
name: "Author",
table: "Notification",
type: "varchar(255)",
nullable: false)
.Annotation("MySql:CharSet", "utf8mb4");

migrationBuilder.AddColumn<string>(
name: "ImgUrl",
table: "Notification",
type: "longtext",
nullable: false)
.Annotation("MySql:CharSet", "utf8mb4");
}

/// <inheritdoc />
Expand Down
15 changes: 10 additions & 5 deletions devblog/devblog/Data/AppDbMigrations/AppDbContextModelSnapshot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,10 @@ protected override void BuildModel(ModelBuilder modelBuilder)

modelBuilder.Entity("devblog.Models.Notification", b =>
{
b.Property<int>("PostId")
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("UserName")
.HasColumnType("varchar(255)");
b.Property<string>("Author")
.IsRequired()
.HasColumnType("longtext");
Expand All @@ -99,7 +97,14 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.IsRequired()
.HasColumnType("longtext");
b.HasKey("PostId", "UserName");
b.Property<int>("PostId")
.HasColumnType("int");
b.Property<string>("UserName")
.IsRequired()
.HasColumnType("longtext");
b.HasKey("Id");
b.ToTable("Notification");
});
Expand Down
1 change: 1 addition & 0 deletions devblog/devblog/Models/Notification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
public class Notification
{
public int Id { get; set; }
public int PostId { get; set; }
public required string UserName { get; set; }
public required string Author { get; set; }
Expand Down

0 comments on commit 0bc61e3

Please sign in to comment.