84 lines
3.1 KiB
C#
84 lines
3.1 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace DramaLing.Api.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class RemoveCardSetFeature : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_flashcards_card_sets_card_set_id",
|
|
table: "flashcards");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "card_sets");
|
|
|
|
migrationBuilder.DropIndex(
|
|
name: "IX_flashcards_card_set_id",
|
|
table: "flashcards");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "card_set_id",
|
|
table: "flashcards");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.AddColumn<Guid>(
|
|
name: "card_set_id",
|
|
table: "flashcards",
|
|
type: "TEXT",
|
|
nullable: true);
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "card_sets",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "TEXT", nullable: false),
|
|
UserId = table.Column<Guid>(type: "TEXT", nullable: false),
|
|
CardCount = table.Column<int>(type: "INTEGER", nullable: false),
|
|
Color = table.Column<string>(type: "TEXT", maxLength: 50, nullable: false),
|
|
CreatedAt = table.Column<DateTime>(type: "TEXT", nullable: false),
|
|
Description = table.Column<string>(type: "TEXT", nullable: true),
|
|
IsDefault = table.Column<bool>(type: "INTEGER", nullable: false),
|
|
Name = table.Column<string>(type: "TEXT", maxLength: 255, nullable: false),
|
|
UpdatedAt = table.Column<DateTime>(type: "TEXT", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_card_sets", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_card_sets_user_profiles_UserId",
|
|
column: x => x.UserId,
|
|
principalTable: "user_profiles",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_flashcards_card_set_id",
|
|
table: "flashcards",
|
|
column: "card_set_id");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_card_sets_UserId",
|
|
table: "card_sets",
|
|
column: "UserId");
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_flashcards_card_sets_card_set_id",
|
|
table: "flashcards",
|
|
column: "card_set_id",
|
|
principalTable: "card_sets",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.SetNull);
|
|
}
|
|
}
|
|
}
|