BackEnd/YTManager/Migrations/20180224055707_fix_channel_...

83 lines
2.7 KiB
C#

using Microsoft.EntityFrameworkCore.Migrations;
using System;
using System.Collections.Generic;
namespace YTManager.Migrations
{
public partial class fix_channel_relationship : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Videos_Channels_ChannelPrimaryKey",
table: "Videos");
migrationBuilder.AlterColumn<long>(
name: "ChannelPrimaryKey",
table: "Videos",
nullable: false,
oldClrType: typeof(long),
oldNullable: true);
migrationBuilder.AddColumn<long>(
name: "VideoPrimaryKey",
table: "Tags",
nullable: true);
migrationBuilder.CreateIndex(
name: "IX_Tags_VideoPrimaryKey",
table: "Tags",
column: "VideoPrimaryKey");
migrationBuilder.AddForeignKey(
name: "FK_Tags_Videos_VideoPrimaryKey",
table: "Tags",
column: "VideoPrimaryKey",
principalTable: "Videos",
principalColumn: "PrimaryKey",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Videos_Channels_ChannelPrimaryKey",
table: "Videos",
column: "ChannelPrimaryKey",
principalTable: "Channels",
principalColumn: "PrimaryKey",
onDelete: ReferentialAction.Cascade);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Tags_Videos_VideoPrimaryKey",
table: "Tags");
migrationBuilder.DropForeignKey(
name: "FK_Videos_Channels_ChannelPrimaryKey",
table: "Videos");
migrationBuilder.DropIndex(
name: "IX_Tags_VideoPrimaryKey",
table: "Tags");
migrationBuilder.DropColumn(
name: "VideoPrimaryKey",
table: "Tags");
migrationBuilder.AlterColumn<long>(
name: "ChannelPrimaryKey",
table: "Videos",
nullable: true,
oldClrType: typeof(long));
migrationBuilder.AddForeignKey(
name: "FK_Videos_Channels_ChannelPrimaryKey",
table: "Videos",
column: "ChannelPrimaryKey",
principalTable: "Channels",
principalColumn: "PrimaryKey",
onDelete: ReferentialAction.Restrict);
}
}
}