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( name: "ChannelPrimaryKey", table: "Videos", nullable: false, oldClrType: typeof(long), oldNullable: true); migrationBuilder.AddColumn( 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( 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); } } }