divan/RMuseum/Migrations/20211218155310_RecitationUserUpVotes.cs
2021-12-18 19:51:59 +03:30

57 lines
2.2 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace RMuseum.Migrations
{
public partial class RecitationUserUpVotes : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "RecitationUserUpVotes",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
RecitationId = table.Column<int>(type: "int", nullable: false),
UserId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
DateTime = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_RecitationUserUpVotes", x => x.Id);
table.ForeignKey(
name: "FK_RecitationUserUpVotes_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id");
table.ForeignKey(
name: "FK_RecitationUserUpVotes_Recitations_RecitationId",
column: x => x.RecitationId,
principalTable: "Recitations",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_RecitationUserUpVotes_RecitationId_UserId",
table: "RecitationUserUpVotes",
columns: new[] { "RecitationId", "UserId" },
unique: true,
filter: "[UserId] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_RecitationUserUpVotes_UserId",
table: "RecitationUserUpVotes",
column: "UserId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "RecitationUserUpVotes");
}
}
}