Torma Kristóf
634488c2d8
All checks were successful
continuous-integration/drone/push Build is passing
126 lines
4.7 KiB
C#
126 lines
4.7 KiB
C#
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
namespace HanyadikHetVan.Data.Migrations
|
|
{
|
|
public partial class FunFactAndUser : Migration
|
|
{
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_WeeklyTimeSpans_AspNetUsers_OwnerId",
|
|
table: "WeeklyTimeSpans");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Purses");
|
|
|
|
migrationBuilder.RenameColumn(
|
|
name: "OwnerId",
|
|
table: "WeeklyTimeSpans",
|
|
newName: "UserId");
|
|
|
|
migrationBuilder.RenameIndex(
|
|
name: "IX_WeeklyTimeSpans_OwnerId",
|
|
table: "WeeklyTimeSpans",
|
|
newName: "IX_WeeklyTimeSpans_UserId");
|
|
|
|
migrationBuilder.AddColumn<string>(
|
|
name: "Discriminator",
|
|
table: "AspNetUsers",
|
|
type: "nvarchar(max)",
|
|
nullable: false,
|
|
defaultValue: "");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "FunFacts",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
Fact = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
FunFactor = table.Column<double>(type: "float", nullable: false),
|
|
WeeklyTimeSpanId = table.Column<int>(type: "int", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_FunFacts", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_FunFacts_WeeklyTimeSpans_WeeklyTimeSpanId",
|
|
column: x => x.WeeklyTimeSpanId,
|
|
principalTable: "WeeklyTimeSpans",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_FunFacts_WeeklyTimeSpanId",
|
|
table: "FunFacts",
|
|
column: "WeeklyTimeSpanId");
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_WeeklyTimeSpans_AspNetUsers_UserId",
|
|
table: "WeeklyTimeSpans",
|
|
column: "UserId",
|
|
principalTable: "AspNetUsers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
}
|
|
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_WeeklyTimeSpans_AspNetUsers_UserId",
|
|
table: "WeeklyTimeSpans");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "FunFacts");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "Discriminator",
|
|
table: "AspNetUsers");
|
|
|
|
migrationBuilder.RenameColumn(
|
|
name: "UserId",
|
|
table: "WeeklyTimeSpans",
|
|
newName: "OwnerId");
|
|
|
|
migrationBuilder.RenameIndex(
|
|
name: "IX_WeeklyTimeSpans_UserId",
|
|
table: "WeeklyTimeSpans",
|
|
newName: "IX_WeeklyTimeSpans_OwnerId");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Purses",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
Balance = table.Column<int>(type: "int", nullable: false),
|
|
UserId = table.Column<string>(type: "nvarchar(450)", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Purses", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Purses_AspNetUsers_UserId",
|
|
column: x => x.UserId,
|
|
principalTable: "AspNetUsers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Purses_UserId",
|
|
table: "Purses",
|
|
column: "UserId");
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_WeeklyTimeSpans_AspNetUsers_OwnerId",
|
|
table: "WeeklyTimeSpans",
|
|
column: "OwnerId",
|
|
principalTable: "AspNetUsers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
}
|
|
}
|
|
}
|