using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace GerbilManagerWebAPI.Migrations
{
    /// <inheritdoc />
    public partial class AddGermanCollation : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<string>(
                name: "ExternalRef",
                table: "Litters",
                type: "text",
                nullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "OriginBreeder",
                table: "Gerbils",
                type: "text",
                nullable: true,
                collation: "de-x-icu",
                oldClrType: typeof(string),
                oldType: "text",
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "NameSearch",
                table: "Gerbils",
                type: "text",
                nullable: true,
                collation: "de-x-icu",
                oldClrType: typeof(string),
                oldType: "text",
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "Name",
                table: "Gerbils",
                type: "text",
                nullable: false,
                collation: "de-x-icu",
                oldClrType: typeof(string),
                oldType: "text");

            migrationBuilder.AlterColumn<string>(
                name: "Name",
                table: "Contacts",
                type: "text",
                nullable: false,
                collation: "de-x-icu",
                oldClrType: typeof(string),
                oldType: "text");

            migrationBuilder.AlterColumn<string>(
                name: "Name",
                table: "ColorVarieties",
                type: "text",
                nullable: false,
                collation: "de-x-icu",
                oldClrType: typeof(string),
                oldType: "text");

            migrationBuilder.CreateIndex(
                name: "IX_Litters_ExternalRef",
                table: "Litters",
                column: "ExternalRef",
                unique: true,
                filter: "\"ExternalRef\" IS NOT NULL");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropIndex(
                name: "IX_Litters_ExternalRef",
                table: "Litters");

            migrationBuilder.DropColumn(
                name: "ExternalRef",
                table: "Litters");

            migrationBuilder.AlterColumn<string>(
                name: "OriginBreeder",
                table: "Gerbils",
                type: "text",
                nullable: true,
                oldClrType: typeof(string),
                oldType: "text",
                oldNullable: true,
                oldCollation: "de-x-icu");

            migrationBuilder.AlterColumn<string>(
                name: "NameSearch",
                table: "Gerbils",
                type: "text",
                nullable: true,
                oldClrType: typeof(string),
                oldType: "text",
                oldNullable: true,
                oldCollation: "de-x-icu");

            migrationBuilder.AlterColumn<string>(
                name: "Name",
                table: "Gerbils",
                type: "text",
                nullable: false,
                oldClrType: typeof(string),
                oldType: "text",
                oldCollation: "de-x-icu");

            migrationBuilder.AlterColumn<string>(
                name: "Name",
                table: "Contacts",
                type: "text",
                nullable: false,
                oldClrType: typeof(string),
                oldType: "text",
                oldCollation: "de-x-icu");

            migrationBuilder.AlterColumn<string>(
                name: "Name",
                table: "ColorVarieties",
                type: "text",
                nullable: false,
                oldClrType: typeof(string),
                oldType: "text",
                oldCollation: "de-x-icu");
        }
    }
}
