flower-story/Server/Migrations/20230809083422_Add-Comments.cs
2023-08-09 17:34:18 +08:00

95 lines
3.4 KiB
C#

using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Blahblah.FlowerStory.Server.Migrations
{
/// <inheritdoc />
public partial class AddComments : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "comments",
table: "records",
type: "INTEGER",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "favs",
table: "records",
type: "INTEGER",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "likes",
table: "records",
type: "INTEGER",
nullable: true);
migrationBuilder.CreateTable(
name: "comments",
columns: table => new
{
cid = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
uid = table.Column<int>(type: "INTEGER", nullable: false),
date = table.Column<long>(type: "INTEGER", nullable: false),
rid = table.Column<int>(type: "INTEGER", nullable: false),
category = table.Column<int>(type: "INTEGER", nullable: true),
byuid = table.Column<int>(type: "INTEGER", nullable: true),
byname = table.Column<string>(type: "TEXT", nullable: true),
text = table.Column<string>(type: "TEXT", nullable: true),
latitude = table.Column<double>(type: "REAL", nullable: true),
longitude = table.Column<double>(type: "REAL", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_comments", x => x.cid);
table.ForeignKey(
name: "FK_comments_records_rid",
column: x => x.rid,
principalTable: "records",
principalColumn: "rid",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_comments_users_uid",
column: x => x.uid,
principalTable: "users",
principalColumn: "uid",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_comments_rid",
table: "comments",
column: "rid");
migrationBuilder.CreateIndex(
name: "IX_comments_uid",
table: "comments",
column: "uid");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "comments");
migrationBuilder.DropColumn(
name: "comments",
table: "records");
migrationBuilder.DropColumn(
name: "favs",
table: "records");
migrationBuilder.DropColumn(
name: "likes",
table: "records");
}
}
}