diff --git a/ProjectLighthouse/Migrations/20220923042831_AddPlaylists.cs b/ProjectLighthouse/Migrations/20220923042831_AddPlaylists.cs new file mode 100644 index 00000000..f7023a6d --- /dev/null +++ b/ProjectLighthouse/Migrations/20220923042831_AddPlaylists.cs @@ -0,0 +1,94 @@ +using LBPUnion.ProjectLighthouse; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace ProjectLighthouse.Migrations +{ + [DbContext(typeof(Database))] + [Migration("20220923042831_AddPlaylists")] + public partial class AddPlaylists : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Playlists", + columns: table => new + { + PlaylistId = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Name = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Description = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + CreatorId = table.Column(type: "int", nullable: false), + SlotCollection = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_Playlists", x => x.PlaylistId); + table.ForeignKey( + name: "FK_Playlists_Users_CreatorId", + column: x => x.CreatorId, + principalTable: "Users", + principalColumn: "UserId", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "HeartedPlaylists", + columns: table => new + { + HeartedPlaylistId = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + UserId = table.Column(type: "int", nullable: false), + PlaylistId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_HeartedPlaylists", x => x.HeartedPlaylistId); + table.ForeignKey( + name: "FK_HeartedPlaylists_Playlists_PlaylistId", + column: x => x.PlaylistId, + principalTable: "Playlists", + principalColumn: "PlaylistId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_HeartedPlaylists_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "UserId", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateIndex( + name: "IX_HeartedPlaylists_PlaylistId", + table: "HeartedPlaylists", + column: "PlaylistId"); + + migrationBuilder.CreateIndex( + name: "IX_HeartedPlaylists_UserId", + table: "HeartedPlaylists", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_Playlists_CreatorId", + table: "Playlists", + column: "CreatorId"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "HeartedPlaylists"); + + migrationBuilder.DropTable( + name: "Playlists"); + } + } +}