123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416 |
- using System;
- using Microsoft.EntityFrameworkCore.Migrations;
- using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
-
- namespace UnivateProperties_API.Migrations
- {
- public partial class BanksAddresses : Migration
- {
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropForeignKey(
- name: "FK_Agents_Users_UserId",
- table: "Agents");
-
- migrationBuilder.DropForeignKey(
- name: "FK_Individuals_Users_UserId",
- table: "Individuals");
-
- migrationBuilder.AddColumn<int>(
- name: "AgencyId",
- table: "Properties",
- nullable: true);
-
- migrationBuilder.AddColumn<int>(
- name: "AgentId",
- table: "Properties",
- nullable: true);
-
- migrationBuilder.AddColumn<int>(
- name: "OwnerId",
- table: "Properties",
- nullable: true);
-
- migrationBuilder.AddColumn<int>(
- name: "StatusId",
- table: "Properties",
- nullable: true);
-
- migrationBuilder.AlterColumn<int>(
- name: "UserId",
- table: "Individuals",
- nullable: true,
- oldClrType: typeof(int));
-
- migrationBuilder.AddColumn<int>(
- name: "AddressId",
- table: "Individuals",
- nullable: true);
-
- migrationBuilder.AddColumn<string>(
- name: "CompanyRegNumber",
- table: "Individuals",
- nullable: true);
-
- migrationBuilder.AddColumn<string>(
- name: "IdNumber",
- table: "Individuals",
- nullable: true);
-
- migrationBuilder.AddColumn<string>(
- name: "IncomeTaxNumber",
- table: "Individuals",
- nullable: true);
-
- migrationBuilder.AddColumn<string>(
- name: "MaritalStatus",
- table: "Individuals",
- nullable: true);
-
- migrationBuilder.AlterColumn<int>(
- name: "UserId",
- table: "Agents",
- nullable: true,
- oldClrType: typeof(int));
-
- migrationBuilder.CreateTable(
- name: "Addresses",
- columns: table => new
- {
- Id = table.Column<int>(nullable: false)
- .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
- Created = table.Column<DateTime>(nullable: false),
- Modified = table.Column<DateTime>(nullable: false),
- ModifiedBy = table.Column<string>(nullable: true),
- StreetNumber = table.Column<string>(nullable: true),
- Street = table.Column<string>(nullable: true),
- Suburb = table.Column<string>(nullable: true),
- City = table.Column<string>(nullable: true),
- PostalCode = table.Column<string>(nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Addresses", x => x.Id);
- });
-
- migrationBuilder.CreateTable(
- name: "Banks",
- columns: table => new
- {
- Id = table.Column<int>(nullable: false)
- .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
- Created = table.Column<DateTime>(nullable: false),
- Modified = table.Column<DateTime>(nullable: false),
- ModifiedBy = table.Column<string>(nullable: true),
- Name = table.Column<string>(nullable: true),
- UniversalBranchCode = table.Column<string>(nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Banks", x => x.Id);
- });
-
- migrationBuilder.CreateTable(
- name: "ProcessFlows",
- columns: table => new
- {
- Id = table.Column<int>(nullable: false)
- .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
- Created = table.Column<DateTime>(nullable: false),
- Modified = table.Column<DateTime>(nullable: false),
- ModifiedBy = table.Column<string>(nullable: true),
- TimeshareID = table.Column<int>(nullable: true),
- PropertyID = table.Column<int>(nullable: true),
- StatusID = table.Column<int>(nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_ProcessFlows", x => x.Id);
- table.ForeignKey(
- name: "FK_ProcessFlows_Properties_PropertyID",
- column: x => x.PropertyID,
- principalTable: "Properties",
- principalColumn: "Id",
- onDelete: ReferentialAction.Restrict);
- table.ForeignKey(
- name: "FK_ProcessFlows_Status_StatusID",
- column: x => x.StatusID,
- principalTable: "Status",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- table.ForeignKey(
- name: "FK_ProcessFlows_Weeks_TimeshareID",
- column: x => x.TimeshareID,
- principalTable: "Weeks",
- principalColumn: "Id",
- onDelete: ReferentialAction.Restrict);
- });
-
- migrationBuilder.CreateTable(
- name: "BankAccounts",
- columns: table => new
- {
- Id = table.Column<int>(nullable: false)
- .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
- Created = table.Column<DateTime>(nullable: false),
- Modified = table.Column<DateTime>(nullable: false),
- ModifiedBy = table.Column<string>(nullable: true),
- AccountHolder = table.Column<string>(nullable: true),
- AccountNumber = table.Column<string>(nullable: true),
- BankId = table.Column<int>(nullable: false),
- OwnerId = table.Column<int>(nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_BankAccounts", x => x.Id);
- table.ForeignKey(
- name: "FK_BankAccounts_Banks_BankId",
- column: x => x.BankId,
- principalTable: "Banks",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- table.ForeignKey(
- name: "FK_BankAccounts_Individuals_OwnerId",
- column: x => x.OwnerId,
- principalTable: "Individuals",
- principalColumn: "Id",
- onDelete: ReferentialAction.Restrict);
- });
-
- migrationBuilder.CreateIndex(
- name: "IX_Properties_AgencyId",
- table: "Properties",
- column: "AgencyId");
-
- migrationBuilder.CreateIndex(
- name: "IX_Properties_AgentId",
- table: "Properties",
- column: "AgentId");
-
- migrationBuilder.CreateIndex(
- name: "IX_Properties_OwnerId",
- table: "Properties",
- column: "OwnerId");
-
- migrationBuilder.CreateIndex(
- name: "IX_Properties_StatusId",
- table: "Properties",
- column: "StatusId");
-
- migrationBuilder.CreateIndex(
- name: "IX_Individuals_AddressId",
- table: "Individuals",
- column: "AddressId");
-
- migrationBuilder.CreateIndex(
- name: "IX_BankAccounts_BankId",
- table: "BankAccounts",
- column: "BankId");
-
- migrationBuilder.CreateIndex(
- name: "IX_BankAccounts_OwnerId",
- table: "BankAccounts",
- column: "OwnerId");
-
- migrationBuilder.CreateIndex(
- name: "IX_ProcessFlows_PropertyID",
- table: "ProcessFlows",
- column: "PropertyID");
-
- migrationBuilder.CreateIndex(
- name: "IX_ProcessFlows_StatusID",
- table: "ProcessFlows",
- column: "StatusID");
-
- migrationBuilder.CreateIndex(
- name: "IX_ProcessFlows_TimeshareID",
- table: "ProcessFlows",
- column: "TimeshareID");
-
- migrationBuilder.AddForeignKey(
- name: "FK_Agents_Users_UserId",
- table: "Agents",
- column: "UserId",
- principalTable: "Users",
- principalColumn: "Id",
- onDelete: ReferentialAction.Restrict);
-
- migrationBuilder.AddForeignKey(
- name: "FK_Individuals_Addresses_AddressId",
- table: "Individuals",
- column: "AddressId",
- principalTable: "Addresses",
- principalColumn: "Id",
- onDelete: ReferentialAction.Restrict);
-
- migrationBuilder.AddForeignKey(
- name: "FK_Individuals_Users_UserId",
- table: "Individuals",
- column: "UserId",
- principalTable: "Users",
- principalColumn: "Id",
- onDelete: ReferentialAction.Restrict);
-
- migrationBuilder.AddForeignKey(
- name: "FK_Properties_Agencies_AgencyId",
- table: "Properties",
- column: "AgencyId",
- principalTable: "Agencies",
- principalColumn: "Id",
- onDelete: ReferentialAction.Restrict);
-
- migrationBuilder.AddForeignKey(
- name: "FK_Properties_Agents_AgentId",
- table: "Properties",
- column: "AgentId",
- principalTable: "Agents",
- principalColumn: "Id",
- onDelete: ReferentialAction.Restrict);
-
- migrationBuilder.AddForeignKey(
- name: "FK_Properties_Individuals_OwnerId",
- table: "Properties",
- column: "OwnerId",
- principalTable: "Individuals",
- principalColumn: "Id",
- onDelete: ReferentialAction.Restrict);
-
- migrationBuilder.AddForeignKey(
- name: "FK_Properties_Status_StatusId",
- table: "Properties",
- column: "StatusId",
- principalTable: "Status",
- principalColumn: "Id",
- onDelete: ReferentialAction.Restrict);
- }
-
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropForeignKey(
- name: "FK_Agents_Users_UserId",
- table: "Agents");
-
- migrationBuilder.DropForeignKey(
- name: "FK_Individuals_Addresses_AddressId",
- table: "Individuals");
-
- migrationBuilder.DropForeignKey(
- name: "FK_Individuals_Users_UserId",
- table: "Individuals");
-
- migrationBuilder.DropForeignKey(
- name: "FK_Properties_Agencies_AgencyId",
- table: "Properties");
-
- migrationBuilder.DropForeignKey(
- name: "FK_Properties_Agents_AgentId",
- table: "Properties");
-
- migrationBuilder.DropForeignKey(
- name: "FK_Properties_Individuals_OwnerId",
- table: "Properties");
-
- migrationBuilder.DropForeignKey(
- name: "FK_Properties_Status_StatusId",
- table: "Properties");
-
- migrationBuilder.DropTable(
- name: "Addresses");
-
- migrationBuilder.DropTable(
- name: "BankAccounts");
-
- migrationBuilder.DropTable(
- name: "ProcessFlows");
-
- migrationBuilder.DropTable(
- name: "Banks");
-
- migrationBuilder.DropIndex(
- name: "IX_Properties_AgencyId",
- table: "Properties");
-
- migrationBuilder.DropIndex(
- name: "IX_Properties_AgentId",
- table: "Properties");
-
- migrationBuilder.DropIndex(
- name: "IX_Properties_OwnerId",
- table: "Properties");
-
- migrationBuilder.DropIndex(
- name: "IX_Properties_StatusId",
- table: "Properties");
-
- migrationBuilder.DropIndex(
- name: "IX_Individuals_AddressId",
- table: "Individuals");
-
- migrationBuilder.DropColumn(
- name: "AgencyId",
- table: "Properties");
-
- migrationBuilder.DropColumn(
- name: "AgentId",
- table: "Properties");
-
- migrationBuilder.DropColumn(
- name: "OwnerId",
- table: "Properties");
-
- migrationBuilder.DropColumn(
- name: "StatusId",
- table: "Properties");
-
- migrationBuilder.DropColumn(
- name: "AddressId",
- table: "Individuals");
-
- migrationBuilder.DropColumn(
- name: "CompanyRegNumber",
- table: "Individuals");
-
- migrationBuilder.DropColumn(
- name: "IdNumber",
- table: "Individuals");
-
- migrationBuilder.DropColumn(
- name: "IncomeTaxNumber",
- table: "Individuals");
-
- migrationBuilder.DropColumn(
- name: "MaritalStatus",
- table: "Individuals");
-
- migrationBuilder.AlterColumn<int>(
- name: "UserId",
- table: "Individuals",
- nullable: false,
- oldClrType: typeof(int),
- oldNullable: true);
-
- migrationBuilder.AlterColumn<int>(
- name: "UserId",
- table: "Agents",
- nullable: false,
- oldClrType: typeof(int),
- oldNullable: true);
-
- migrationBuilder.AddForeignKey(
- name: "FK_Agents_Users_UserId",
- table: "Agents",
- column: "UserId",
- principalTable: "Users",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
-
- migrationBuilder.AddForeignKey(
- name: "FK_Individuals_Users_UserId",
- table: "Individuals",
- column: "UserId",
- principalTable: "Users",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- }
- }
- }
|