using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;

#nullable disable

namespace song_of_the_day.DataMigrations
{
    /// <inheritdoc />
    public partial class addingsonglikesandplaylists : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<int>(
                name: "SmartPlaylistDefinitionId",
                table: "SuggestionHelpers",
                type: "integer",
                nullable: true);

            migrationBuilder.AddColumn<int>(
                name: "SmartPlaylistDefinitionId",
                table: "Songs",
                type: "integer",
                nullable: true);

            migrationBuilder.AddColumn<int>(
                name: "SmartPlaylistDefinitionId1",
                table: "Songs",
                type: "integer",
                nullable: true);

            migrationBuilder.AddColumn<int>(
                name: "UserId",
                table: "Songs",
                type: "integer",
                nullable: true);

            migrationBuilder.CreateTable(
                name: "SmartPlaylistDefinitions",
                columns: table => new
                {
                    Id = table.Column<int>(type: "integer", nullable: false)
                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
                    Title = table.Column<string>(type: "text", nullable: true),
                    Description = table.Column<string>(type: "text", nullable: true),
                    CreatedByUserId = table.Column<int>(type: "integer", nullable: true),
                    IncludesUnCategorizedSongs = table.Column<bool>(type: "boolean", nullable: false),
                    IncludesLikedSongs = table.Column<bool>(type: "boolean", nullable: false),
                    SpotifyPlaylistId = table.Column<string>(type: "text", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SmartPlaylistDefinitions", x => x.Id);
                    table.ForeignKey(
                        name: "FK_SmartPlaylistDefinitions_Users_CreatedByUserId",
                        column: x => x.CreatedByUserId,
                        principalTable: "Users",
                        principalColumn: "UserId");
                });

            migrationBuilder.CreateIndex(
                name: "IX_SuggestionHelpers_SmartPlaylistDefinitionId",
                table: "SuggestionHelpers",
                column: "SmartPlaylistDefinitionId");

            migrationBuilder.CreateIndex(
                name: "IX_Songs_SmartPlaylistDefinitionId",
                table: "Songs",
                column: "SmartPlaylistDefinitionId");

            migrationBuilder.CreateIndex(
                name: "IX_Songs_SmartPlaylistDefinitionId1",
                table: "Songs",
                column: "SmartPlaylistDefinitionId1");

            migrationBuilder.CreateIndex(
                name: "IX_Songs_UserId",
                table: "Songs",
                column: "UserId");

            migrationBuilder.CreateIndex(
                name: "IX_SmartPlaylistDefinitions_CreatedByUserId",
                table: "SmartPlaylistDefinitions",
                column: "CreatedByUserId");

            migrationBuilder.AddForeignKey(
                name: "FK_Songs_SmartPlaylistDefinitions_SmartPlaylistDefinitionId",
                table: "Songs",
                column: "SmartPlaylistDefinitionId",
                principalTable: "SmartPlaylistDefinitions",
                principalColumn: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_Songs_SmartPlaylistDefinitions_SmartPlaylistDefinitionId1",
                table: "Songs",
                column: "SmartPlaylistDefinitionId1",
                principalTable: "SmartPlaylistDefinitions",
                principalColumn: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_Songs_Users_UserId",
                table: "Songs",
                column: "UserId",
                principalTable: "Users",
                principalColumn: "UserId");

            migrationBuilder.AddForeignKey(
                name: "FK_SuggestionHelpers_SmartPlaylistDefinitions_SmartPlaylistDef~",
                table: "SuggestionHelpers",
                column: "SmartPlaylistDefinitionId",
                principalTable: "SmartPlaylistDefinitions",
                principalColumn: "Id");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Songs_SmartPlaylistDefinitions_SmartPlaylistDefinitionId",
                table: "Songs");

            migrationBuilder.DropForeignKey(
                name: "FK_Songs_SmartPlaylistDefinitions_SmartPlaylistDefinitionId1",
                table: "Songs");

            migrationBuilder.DropForeignKey(
                name: "FK_Songs_Users_UserId",
                table: "Songs");

            migrationBuilder.DropForeignKey(
                name: "FK_SuggestionHelpers_SmartPlaylistDefinitions_SmartPlaylistDef~",
                table: "SuggestionHelpers");

            migrationBuilder.DropTable(
                name: "SmartPlaylistDefinitions");

            migrationBuilder.DropIndex(
                name: "IX_SuggestionHelpers_SmartPlaylistDefinitionId",
                table: "SuggestionHelpers");

            migrationBuilder.DropIndex(
                name: "IX_Songs_SmartPlaylistDefinitionId",
                table: "Songs");

            migrationBuilder.DropIndex(
                name: "IX_Songs_SmartPlaylistDefinitionId1",
                table: "Songs");

            migrationBuilder.DropIndex(
                name: "IX_Songs_UserId",
                table: "Songs");

            migrationBuilder.DropColumn(
                name: "SmartPlaylistDefinitionId",
                table: "SuggestionHelpers");

            migrationBuilder.DropColumn(
                name: "SmartPlaylistDefinitionId",
                table: "Songs");

            migrationBuilder.DropColumn(
                name: "SmartPlaylistDefinitionId1",
                table: "Songs");

            migrationBuilder.DropColumn(
                name: "UserId",
                table: "Songs");
        }
    }
}
