using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Infrastructure.Migrations.AppDb
{
///
public partial class AddPostViewLog : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "PostViewLog",
columns: table => new
{
ID = table.Column(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
PostID = table.Column(type: "int", nullable: false),
MemberID = table.Column(type: "int", nullable: true),
IpAddress = table.Column(type: "nvarchar(max)", nullable: true),
UserAgent = table.Column(type: "nvarchar(max)", nullable: true),
CreatedAt = table.Column(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_PostViewLog", x => x.ID);
table.ForeignKey(
name: "FK_PostViewLog_Member_MemberID",
column: x => x.MemberID,
principalTable: "Member",
principalColumn: "ID");
table.ForeignKey(
name: "FK_PostViewLog_Post_PostID",
column: x => x.PostID,
principalTable: "Post",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_PostViewLog_MemberID",
table: "PostViewLog",
column: "MemberID");
migrationBuilder.CreateIndex(
name: "IX_PostViewLog_PostID",
table: "PostViewLog",
column: "PostID");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "PostViewLog");
}
}
}