using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace UnivateProperties_API.Migrations { public partial class MissingColumns : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_UnitConfigurationTypes_UnitConfigurations_UnitConfigurationId", table: "UnitConfigurationTypes"); //migrationBuilder.DropIndex( // name: "IX_Users_Username", // table: "Users"); //migrationBuilder.DropIndex( // name: "IX_UnitConfigurations_Code", // table: "UnitConfigurations"); //migrationBuilder.DropIndex( // name: "IX_Individuals_Telephone_CellNumber_Email", // table: "Individuals"); //migrationBuilder.AlterColumn( // name: "Id", // table: "Weeks", // nullable: false, // oldClrType: typeof(int)) // .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); //migrationBuilder.AlterColumn( // name: "Id", // table: "Users", // nullable: false, // oldClrType: typeof(int)) // .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); //migrationBuilder.AlterColumn( // name: "Id", // table: "UserDefinedGroups", // nullable: false, // oldClrType: typeof(int)) // .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); //migrationBuilder.AlterColumn( // name: "Id", // table: "UserDefinedFields", // nullable: false, // oldClrType: typeof(int)) // .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); //migrationBuilder.AlterColumn( // name: "Id", // table: "UnitConfigurationTypes", // nullable: false, // oldClrType: typeof(int)) // .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); //migrationBuilder.AlterColumn( // name: "Id", // table: "UnitConfigurations", // nullable: false, // oldClrType: typeof(int)) // .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); //migrationBuilder.AlterColumn( // name: "Id", // table: "Templates", // nullable: false, // oldClrType: typeof(int)) // .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); //migrationBuilder.AlterColumn( // name: "Id", // table: "Suburbs", // nullable: false, // oldClrType: typeof(int)) // .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); //migrationBuilder.AlterColumn( // name: "Id", // table: "Status", // nullable: false, // oldClrType: typeof(int)) // .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); //migrationBuilder.AlterColumn( // name: "Id", // table: "Seasons", // nullable: false, // oldClrType: typeof(int)) // .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); //migrationBuilder.AlterColumn( // name: "Id", // table: "SearchLogs", // nullable: false, // oldClrType: typeof(int)) // .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); //migrationBuilder.AlterColumn( // name: "Id", // table: "Provinces", // nullable: false, // oldClrType: typeof(int)) // .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); //migrationBuilder.AlterColumn( // name: "Id", // table: "PropertyUserFields", // nullable: false, // oldClrType: typeof(int)) // .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); //migrationBuilder.AlterColumn( // name: "Id", // table: "PropertyTypes", // nullable: false, // oldClrType: typeof(int)) // .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); //migrationBuilder.AlterColumn( // name: "Id", // table: "PropertyImages", // nullable: false, // oldClrType: typeof(int)) // .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); //migrationBuilder.AlterColumn( // name: "Id", // table: "Properties", // nullable: false, // oldClrType: typeof(int)) // .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); migrationBuilder.AddColumn( name: "DateAvailable", table: "Properties", nullable: false, defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); //migrationBuilder.AlterColumn( // name: "Id", // table: "ProcessFlows", // nullable: false, // oldClrType: typeof(int)) // .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); //migrationBuilder.AlterColumn( // name: "Id", // table: "PlaceHolders", // nullable: false, // oldClrType: typeof(int)) // .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); //migrationBuilder.AlterColumn( // name: "Id", // table: "Person", // nullable: false, // oldClrType: typeof(int)) // .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); //migrationBuilder.AlterColumn( // name: "Id", // table: "Location", // nullable: false, // oldClrType: typeof(int)) // .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); //migrationBuilder.AlterColumn( // name: "Id", // table: "Individuals", // nullable: false, // oldClrType: typeof(int)) // .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); //migrationBuilder.AlterColumn( // name: "Id", // table: "Hosts", // nullable: false, // oldClrType: typeof(int)) // .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); //migrationBuilder.AlterColumn( // name: "Id", // table: "Emails", // nullable: false, // oldClrType: typeof(int)) // .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); //migrationBuilder.AlterColumn( // name: "Id", // table: "Cities", // nullable: false, // oldClrType: typeof(int)) // .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); //migrationBuilder.AlterColumn( // name: "Id", // table: "Carousel", // nullable: false, // oldClrType: typeof(int)) // .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); //migrationBuilder.AlterColumn( // name: "Id", // table: "BidItems", // nullable: false, // oldClrType: typeof(int)) // .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); //migrationBuilder.AlterColumn( // name: "Id", // table: "Banks", // nullable: false, // oldClrType: typeof(int)) // .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); //migrationBuilder.AlterColumn( // name: "Id", // table: "BankAccounts", // nullable: false, // oldClrType: typeof(int)) // .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); //migrationBuilder.AlterColumn( // name: "Id", // table: "Agents", // nullable: false, // oldClrType: typeof(int)) // .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); //migrationBuilder.AlterColumn( // name: "Id", // table: "Agencies", // nullable: false, // oldClrType: typeof(int)) // .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); //migrationBuilder.AlterColumn( // name: "Id", // table: "Addresses", // nullable: false, // oldClrType: typeof(int)) // .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); migrationBuilder.AddColumn( name: "Province", table: "Addresses", nullable: true); //migrationBuilder.AlterColumn( // name: "Id", // table: "Accounts", // nullable: false, // oldClrType: typeof(int)) // .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); //migrationBuilder.CreateIndex( // name: "IX_Users_Username", // table: "Users", // column: "Username", // unique: true); migrationBuilder.CreateIndex( name: "IX_UnitConfigurations_Code", table: "UnitConfigurations", column: "Code", unique: true); //migrationBuilder.CreateIndex( // name: "IX_Individuals_Telephone_CellNumber_Email", // table: "Individuals", // columns: new[] { "Telephone", "CellNumber", "Email" }, // unique: true); migrationBuilder.AddForeignKey( name: "FK_UnitConfigurationTypes_UnitConfigurations_UnitConfiguration~", table: "UnitConfigurationTypes", column: "UnitConfigurationId", principalTable: "UnitConfigurations", principalColumn: "Id", onDelete: ReferentialAction.Cascade); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_UnitConfigurationTypes_UnitConfigurations_UnitConfiguration~", table: "UnitConfigurationTypes"); migrationBuilder.DropIndex( name: "IX_Users_Username", table: "Users"); migrationBuilder.DropIndex( name: "IX_UnitConfigurations_Code", table: "UnitConfigurations"); migrationBuilder.DropIndex( name: "IX_Individuals_Telephone_CellNumber_Email", table: "Individuals"); migrationBuilder.DropColumn( name: "DateAvailable", table: "Properties"); migrationBuilder.DropColumn( name: "Province", table: "Addresses"); migrationBuilder.AlterColumn( name: "Id", table: "Weeks", nullable: false, oldClrType: typeof(int)) .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); migrationBuilder.AlterColumn( name: "Id", table: "Users", nullable: false, oldClrType: typeof(int)) .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); migrationBuilder.AlterColumn( name: "Id", table: "UserDefinedGroups", nullable: false, oldClrType: typeof(int)) .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); migrationBuilder.AlterColumn( name: "Id", table: "UserDefinedFields", nullable: false, oldClrType: typeof(int)) .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); migrationBuilder.AlterColumn( name: "Id", table: "UnitConfigurationTypes", nullable: false, oldClrType: typeof(int)) .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); migrationBuilder.AlterColumn( name: "Id", table: "UnitConfigurations", nullable: false, oldClrType: typeof(int)) .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); migrationBuilder.AlterColumn( name: "Id", table: "Templates", nullable: false, oldClrType: typeof(int)) .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); migrationBuilder.AlterColumn( name: "Id", table: "Suburbs", nullable: false, oldClrType: typeof(int)) .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); migrationBuilder.AlterColumn( name: "Id", table: "Status", nullable: false, oldClrType: typeof(int)) .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); migrationBuilder.AlterColumn( name: "Id", table: "Seasons", nullable: false, oldClrType: typeof(int)) .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); migrationBuilder.AlterColumn( name: "Id", table: "SearchLogs", nullable: false, oldClrType: typeof(int)) .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); migrationBuilder.AlterColumn( name: "Id", table: "Provinces", nullable: false, oldClrType: typeof(int)) .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); migrationBuilder.AlterColumn( name: "Id", table: "PropertyUserFields", nullable: false, oldClrType: typeof(int)) .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); migrationBuilder.AlterColumn( name: "Id", table: "PropertyTypes", nullable: false, oldClrType: typeof(int)) .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); migrationBuilder.AlterColumn( name: "Id", table: "PropertyImages", nullable: false, oldClrType: typeof(int)) .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); migrationBuilder.AlterColumn( name: "Id", table: "Properties", nullable: false, oldClrType: typeof(int)) .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); migrationBuilder.AlterColumn( name: "Id", table: "ProcessFlows", nullable: false, oldClrType: typeof(int)) .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); migrationBuilder.AlterColumn( name: "Id", table: "PlaceHolders", nullable: false, oldClrType: typeof(int)) .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); migrationBuilder.AlterColumn( name: "Id", table: "Person", nullable: false, oldClrType: typeof(int)) .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); migrationBuilder.AlterColumn( name: "Id", table: "Location", nullable: false, oldClrType: typeof(int)) .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); migrationBuilder.AlterColumn( name: "Id", table: "Individuals", nullable: false, oldClrType: typeof(int)) .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); migrationBuilder.AlterColumn( name: "Id", table: "Hosts", nullable: false, oldClrType: typeof(int)) .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); migrationBuilder.AlterColumn( name: "Id", table: "Emails", nullable: false, oldClrType: typeof(int)) .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); migrationBuilder.AlterColumn( name: "Id", table: "Cities", nullable: false, oldClrType: typeof(int)) .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); migrationBuilder.AlterColumn( name: "Id", table: "Carousel", nullable: false, oldClrType: typeof(int)) .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); migrationBuilder.AlterColumn( name: "Id", table: "BidItems", nullable: false, oldClrType: typeof(int)) .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); migrationBuilder.AlterColumn( name: "Id", table: "Banks", nullable: false, oldClrType: typeof(int)) .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); migrationBuilder.AlterColumn( name: "Id", table: "BankAccounts", nullable: false, oldClrType: typeof(int)) .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); migrationBuilder.AlterColumn( name: "Id", table: "Agents", nullable: false, oldClrType: typeof(int)) .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); migrationBuilder.AlterColumn( name: "Id", table: "Agencies", nullable: false, oldClrType: typeof(int)) .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); migrationBuilder.AlterColumn( name: "Id", table: "Addresses", nullable: false, oldClrType: typeof(int)) .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); migrationBuilder.AlterColumn( name: "Id", table: "Accounts", nullable: false, oldClrType: typeof(int)) .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); migrationBuilder.CreateIndex( name: "IX_Users_Username", table: "Users", column: "Username", unique: true, filter: "[Username] IS NOT NULL"); migrationBuilder.CreateIndex( name: "IX_UnitConfigurations_Code", table: "UnitConfigurations", column: "Code", unique: true, filter: "[Code] IS NOT NULL"); migrationBuilder.CreateIndex( name: "IX_Individuals_Telephone_CellNumber_Email", table: "Individuals", columns: new[] { "Telephone", "CellNumber", "Email" }, unique: true, filter: "[Telephone] IS NOT NULL AND [CellNumber] IS NOT NULL AND [Email] IS NOT NULL"); migrationBuilder.AddForeignKey( name: "FK_UnitConfigurationTypes_UnitConfigurations_UnitConfigurationId", table: "UnitConfigurationTypes", column: "UnitConfigurationId", principalTable: "UnitConfigurations", principalColumn: "Id", onDelete: ReferentialAction.Cascade); } } }