using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace song_of_the_day.DataMigrations { /// public partial class explicitlymodellikedsongsrelationship : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_Songs_Users_UserId", table: "Songs"); migrationBuilder.DropIndex( name: "IX_Songs_UserId", table: "Songs"); migrationBuilder.DropColumn( name: "UserId", table: "Songs"); migrationBuilder.CreateTable( name: "LikedSongs", columns: table => new { SongId = table.Column(type: "integer", nullable: false), UserId = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_LikedSongs", x => new { x.SongId, x.UserId }); table.ForeignKey( name: "FK_LikedSongs_Songs_SongId", column: x => x.SongId, principalTable: "Songs", principalColumn: "SongId", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_LikedSongs_Users_UserId", column: x => x.UserId, principalTable: "Users", principalColumn: "UserId", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_LikedSongs_UserId", table: "LikedSongs", column: "UserId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "LikedSongs"); migrationBuilder.AddColumn( name: "UserId", table: "Songs", type: "integer", nullable: true); migrationBuilder.CreateIndex( name: "IX_Songs_UserId", table: "Songs", column: "UserId"); migrationBuilder.AddForeignKey( name: "FK_Songs_Users_UserId", table: "Songs", column: "UserId", principalTable: "Users", principalColumn: "UserId"); } } }