mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-19 03:31:29 +00:00
Refactor Database into DatabaseContext Moved into separate folder so it actually has a namespace instead sitting in the root
112 lines
4.9 KiB
C#
112 lines
4.9 KiB
C#
using LBPUnion.ProjectLighthouse;
|
|
using LBPUnion.ProjectLighthouse.Database;
|
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
using Microsoft.EntityFrameworkCore.Metadata;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace ProjectLighthouse.Migrations
|
|
{
|
|
[DbContext(typeof(DatabaseContext))]
|
|
[Migration("20211211045823_AddLevelReviews")]
|
|
public partial class AddLevelReviews : Migration
|
|
{
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "Reviews",
|
|
columns: table => new
|
|
{
|
|
ReviewId = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
ReviewerId = table.Column<int>(type: "int", nullable: false),
|
|
SlotId = table.Column<int>(type: "int", nullable: false),
|
|
Timestamp = table.Column<long>(type: "bigint", nullable: false),
|
|
LabelCollection = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
Deleted = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
|
DeletedBy = table.Column<int>(type: "int", nullable: false),
|
|
Text = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
Thumb = table.Column<int>(type: "int", nullable: false),
|
|
ThumbsUp = table.Column<int>(type: "int", nullable: false),
|
|
ThumbsDown = table.Column<int>(type: "int", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Reviews", x => x.ReviewId);
|
|
table.ForeignKey(
|
|
name: "FK_Reviews_Slots_SlotId",
|
|
column: x => x.SlotId,
|
|
principalTable: "Slots",
|
|
principalColumn: "SlotId",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_Reviews_Users_ReviewerId",
|
|
column: x => x.ReviewerId,
|
|
principalTable: "Users",
|
|
principalColumn: "UserId",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "RatedReviews",
|
|
columns: table => new
|
|
{
|
|
RatedReviewId = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
UserId = table.Column<int>(type: "int", nullable: false),
|
|
ReviewId = table.Column<int>(type: "int", nullable: false),
|
|
Thumb = table.Column<int>(type: "int", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_RatedReviews", x => x.RatedReviewId);
|
|
table.ForeignKey(
|
|
name: "FK_RatedReviews_Reviews_ReviewId",
|
|
column: x => x.ReviewId,
|
|
principalTable: "Reviews",
|
|
principalColumn: "ReviewId",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_RatedReviews_Users_UserId",
|
|
column: x => x.UserId,
|
|
principalTable: "Users",
|
|
principalColumn: "UserId",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_RatedReviews_ReviewId",
|
|
table: "RatedReviews",
|
|
column: "ReviewId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_RatedReviews_UserId",
|
|
table: "RatedReviews",
|
|
column: "UserId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Reviews_ReviewerId",
|
|
table: "Reviews",
|
|
column: "ReviewerId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Reviews_SlotId",
|
|
table: "Reviews",
|
|
column: "SlotId");
|
|
}
|
|
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "RatedReviews");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Reviews");
|
|
}
|
|
}
|
|
}
|