Add migration to sync Contacts table with model

- Generate SyncContactsAndModels migration for missing columns
- Adds AccountId, Address fields, social URLs, LocationId to Contacts table
This commit is contained in:
Adam Moussa 2026-04-16 16:54:36 -04:00
parent dbb31ca7d7
commit 51b52a7fb5
3 changed files with 4002 additions and 17 deletions

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,852 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Data.SeaHavenIndustries.Migrations
{
/// <inheritdoc />
public partial class SyncContactsAndModels : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "Name",
table: "Contacts",
newName: "Zip");
migrationBuilder.AddColumn<int>(
name: "AccountId",
table: "Contacts",
type: "int",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Address1",
table: "Contacts",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Address2",
table: "Contacts",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "City",
table: "Contacts",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "ContactType",
table: "Contacts",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "FacebookUrl",
table: "Contacts",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "FirstName",
table: "Contacts",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "LastName",
table: "Contacts",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "LinkedInUrl",
table: "Contacts",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "LocationId",
table: "Contacts",
type: "int",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "MiddleName",
table: "Contacts",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Owner",
table: "Contacts",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "State",
table: "Contacts",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Title",
table: "Contacts",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "TwitterUrl",
table: "Contacts",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AlterColumn<string>(
name: "Name",
table: "AspNetUserTokens",
type: "nvarchar(450)",
nullable: false,
oldClrType: typeof(string),
oldType: "nvarchar(128)",
oldMaxLength: 128);
migrationBuilder.AlterColumn<string>(
name: "LoginProvider",
table: "AspNetUserTokens",
type: "nvarchar(450)",
nullable: false,
oldClrType: typeof(string),
oldType: "nvarchar(128)",
oldMaxLength: 128);
migrationBuilder.AlterColumn<string>(
name: "ProviderKey",
table: "AspNetUserLogins",
type: "nvarchar(450)",
nullable: false,
oldClrType: typeof(string),
oldType: "nvarchar(128)",
oldMaxLength: 128);
migrationBuilder.AlterColumn<string>(
name: "LoginProvider",
table: "AspNetUserLogins",
type: "nvarchar(450)",
nullable: false,
oldClrType: typeof(string),
oldType: "nvarchar(128)",
oldMaxLength: 128);
migrationBuilder.CreateTable(
name: "Accounts",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(max)", nullable: true),
Type = table.Column<string>(type: "nvarchar(max)", nullable: true),
Importance = table.Column<int>(type: "int", nullable: true),
TerritoryId = table.Column<int>(type: "int", nullable: true),
OwnerEmployeeId = table.Column<int>(type: "int", nullable: true),
PrivacySetting = table.Column<string>(type: "nvarchar(max)", nullable: true),
About = table.Column<string>(type: "nvarchar(max)", nullable: true),
Tags = table.Column<string>(type: "nvarchar(max)", nullable: true),
Phone = table.Column<string>(type: "nvarchar(max)", nullable: true),
Email = table.Column<string>(type: "nvarchar(max)", nullable: true),
IndustryId = table.Column<int>(type: "int", nullable: true),
TimeZone = table.Column<string>(type: "nvarchar(max)", nullable: true),
Website = table.Column<string>(type: "nvarchar(max)", nullable: true),
CurrencyCode = table.Column<string>(type: "nvarchar(max)", nullable: true),
ServiceInstructions = table.Column<string>(type: "nvarchar(max)", nullable: true),
FacebookUrl = table.Column<string>(type: "nvarchar(max)", nullable: true),
LinkedInUrl = table.Column<string>(type: "nvarchar(max)", nullable: true),
TwitterUrl = table.Column<string>(type: "nvarchar(max)", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: true),
createdby = table.Column<string>(type: "nvarchar(max)", nullable: true),
DeleterUserId = table.Column<string>(type: "nvarchar(max)", nullable: true),
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true),
CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifierUserId = table.Column<int>(type: "int", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Accounts", x => x.Id);
});
migrationBuilder.CreateTable(
name: "ContactDetails",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ContactId = table.Column<int>(type: "int", nullable: false),
Gender = table.Column<string>(type: "nvarchar(max)", nullable: true),
DateOfBirth = table.Column<DateTime>(type: "datetime2", nullable: true),
Territory = table.Column<string>(type: "nvarchar(max)", nullable: true),
PrivacySetting = table.Column<string>(type: "nvarchar(max)", nullable: true),
About = table.Column<string>(type: "nvarchar(max)", nullable: true),
Tags = table.Column<string>(type: "nvarchar(max)", nullable: true),
FacebookUrl = table.Column<string>(type: "nvarchar(max)", nullable: true),
LinkedInUrl = table.Column<string>(type: "nvarchar(max)", nullable: true),
TwitterUrl = table.Column<string>(type: "nvarchar(max)", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: true),
createdby = table.Column<string>(type: "nvarchar(max)", nullable: true),
DeleterUserId = table.Column<string>(type: "nvarchar(max)", nullable: true),
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true),
CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifierUserId = table.Column<int>(type: "int", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_ContactDetails", x => x.Id);
table.ForeignKey(
name: "FK_ContactDetails_Contacts_ContactId",
column: x => x.ContactId,
principalTable: "Contacts",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "Departments",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
IsDeleted = table.Column<bool>(type: "bit", nullable: true),
createdby = table.Column<string>(type: "nvarchar(max)", nullable: true),
DeleterUserId = table.Column<string>(type: "nvarchar(max)", nullable: true),
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true),
CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifierUserId = table.Column<int>(type: "int", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Departments", x => x.Id);
});
migrationBuilder.CreateTable(
name: "JobTitles",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
IsDeleted = table.Column<bool>(type: "bit", nullable: true),
createdby = table.Column<string>(type: "nvarchar(max)", nullable: true),
DeleterUserId = table.Column<string>(type: "nvarchar(max)", nullable: true),
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true),
CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifierUserId = table.Column<int>(type: "int", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_JobTitles", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Regions",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
IsDeleted = table.Column<bool>(type: "bit", nullable: true),
createdby = table.Column<string>(type: "nvarchar(max)", nullable: true),
DeleterUserId = table.Column<string>(type: "nvarchar(max)", nullable: true),
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true),
CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifierUserId = table.Column<int>(type: "int", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Regions", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Addresses",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
AddressType = table.Column<string>(type: "nvarchar(max)", nullable: true),
Address1 = table.Column<string>(type: "nvarchar(max)", nullable: true),
Address2 = table.Column<string>(type: "nvarchar(max)", nullable: true),
City = table.Column<string>(type: "nvarchar(max)", nullable: true),
State = table.Column<string>(type: "nvarchar(max)", nullable: true),
Zip = table.Column<string>(type: "nvarchar(max)", nullable: true),
Country = table.Column<string>(type: "nvarchar(max)", nullable: true),
County = table.Column<string>(type: "nvarchar(max)", nullable: true),
AccountId = table.Column<int>(type: "int", nullable: true),
ContactId = table.Column<int>(type: "int", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: true),
createdby = table.Column<string>(type: "nvarchar(max)", nullable: true),
DeleterUserId = table.Column<string>(type: "nvarchar(max)", nullable: true),
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true),
CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifierUserId = table.Column<int>(type: "int", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Addresses", x => x.Id);
table.ForeignKey(
name: "FK_Addresses_Accounts_AccountId",
column: x => x.AccountId,
principalTable: "Accounts",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_Addresses_Contacts_ContactId",
column: x => x.ContactId,
principalTable: "Contacts",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "Assets",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
AssetCode = table.Column<string>(type: "nvarchar(max)", nullable: false),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
Description = table.Column<string>(type: "nvarchar(max)", nullable: true),
AccountId = table.Column<int>(type: "int", nullable: true),
LocationId = table.Column<int>(type: "int", nullable: true),
IsActive = table.Column<bool>(type: "bit", nullable: false),
IsDeleted = table.Column<bool>(type: "bit", nullable: true),
createdby = table.Column<string>(type: "nvarchar(max)", nullable: true),
DeleterUserId = table.Column<string>(type: "nvarchar(max)", nullable: true),
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true),
CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifierUserId = table.Column<int>(type: "int", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Assets", x => x.Id);
table.ForeignKey(
name: "FK_Assets_Accounts_AccountId",
column: x => x.AccountId,
principalTable: "Accounts",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_Assets_Locations_LocationId",
column: x => x.LocationId,
principalTable: "Locations",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "Employees",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
FirstName = table.Column<string>(type: "nvarchar(max)", nullable: false),
MiddleName = table.Column<string>(type: "nvarchar(max)", nullable: true),
LastName = table.Column<string>(type: "nvarchar(max)", nullable: false),
DepartmentId = table.Column<int>(type: "int", nullable: true),
TimeZone = table.Column<string>(type: "nvarchar(max)", nullable: true),
Gender = table.Column<int>(type: "int", nullable: true),
DateOfBirth = table.Column<DateTime>(type: "datetime2", nullable: true),
JobTitleId = table.Column<int>(type: "int", nullable: true),
EmployeeNumber = table.Column<string>(type: "nvarchar(max)", nullable: true),
HireDate = table.Column<DateTime>(type: "datetime2", nullable: true),
RegionId = table.Column<int>(type: "int", nullable: true),
CanChangeProviderNumber = table.Column<bool>(type: "bit", nullable: true),
About = table.Column<string>(type: "nvarchar(max)", nullable: true),
PermissionGroupId = table.Column<int>(type: "int", nullable: true),
UserName = table.Column<string>(type: "nvarchar(max)", nullable: true),
ConfirmUserName = table.Column<string>(type: "nvarchar(max)", nullable: true),
SMSAddress = table.Column<string>(type: "nvarchar(max)", nullable: true),
Website = table.Column<string>(type: "nvarchar(max)", nullable: true),
FacebookUrl = table.Column<string>(type: "nvarchar(max)", nullable: true),
LinkedInUrl = table.Column<string>(type: "nvarchar(max)", nullable: true),
TwitterUrl = table.Column<string>(type: "nvarchar(max)", nullable: true),
Status = table.Column<string>(type: "nvarchar(max)", nullable: true),
LastLogin = table.Column<DateTime>(type: "datetime2", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: true),
CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifierUserId = table.Column<int>(type: "int", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Employees", x => x.Id);
table.ForeignKey(
name: "FK_Employees_Departments_DepartmentId",
column: x => x.DepartmentId,
principalTable: "Departments",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_Employees_JobTitles_JobTitleId",
column: x => x.JobTitleId,
principalTable: "JobTitles",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_Employees_Regions_RegionId",
column: x => x.RegionId,
principalTable: "Regions",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "PMSchedules",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
Frequency = table.Column<string>(type: "nvarchar(max)", nullable: false),
StartDate = table.Column<DateTime>(type: "datetime2", nullable: false),
IsActive = table.Column<bool>(type: "bit", nullable: false),
AssetId = table.Column<int>(type: "int", nullable: true),
LocationId = table.Column<int>(type: "int", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: true),
createdby = table.Column<string>(type: "nvarchar(max)", nullable: true),
DeleterUserId = table.Column<string>(type: "nvarchar(max)", nullable: true),
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true),
CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifierUserId = table.Column<int>(type: "int", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_PMSchedules", x => x.Id);
table.ForeignKey(
name: "FK_PMSchedules_Assets_AssetId",
column: x => x.AssetId,
principalTable: "Assets",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_PMSchedules_Locations_LocationId",
column: x => x.LocationId,
principalTable: "Locations",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "EmployeeAddresses",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
EmployeeId = table.Column<int>(type: "int", nullable: false),
Street = table.Column<string>(type: "nvarchar(max)", nullable: true),
StreetLineTwo = table.Column<string>(type: "nvarchar(max)", nullable: true),
City = table.Column<string>(type: "nvarchar(max)", nullable: true),
Zip = table.Column<string>(type: "nvarchar(max)", nullable: true),
CountryCode = table.Column<string>(type: "nvarchar(max)", nullable: true),
StateCode = table.Column<string>(type: "nvarchar(max)", nullable: true),
CountyId = table.Column<int>(type: "int", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_EmployeeAddresses", x => x.Id);
table.ForeignKey(
name: "FK_EmployeeAddresses_Employees_EmployeeId",
column: x => x.EmployeeId,
principalTable: "Employees",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "EmployeeEmails",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
EmployeeId = table.Column<int>(type: "int", nullable: false),
EmailTypeId = table.Column<int>(type: "int", nullable: true),
Address = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
IsPrimary = table.Column<bool>(type: "bit", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: true),
createdby = table.Column<string>(type: "nvarchar(max)", nullable: true),
DeleterUserId = table.Column<string>(type: "nvarchar(max)", nullable: true),
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true),
CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifierUserId = table.Column<int>(type: "int", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_EmployeeEmails", x => x.Id);
table.ForeignKey(
name: "FK_EmployeeEmails_Employees_EmployeeId",
column: x => x.EmployeeId,
principalTable: "Employees",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "EmployeePhones",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
EmployeeId = table.Column<int>(type: "int", nullable: false),
PhoneTypeId = table.Column<int>(type: "int", nullable: true),
Number = table.Column<string>(type: "nvarchar(max)", nullable: true),
Extension = table.Column<string>(type: "nvarchar(max)", nullable: true),
IsPrimary = table.Column<bool>(type: "bit", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_EmployeePhones", x => x.Id);
table.ForeignKey(
name: "FK_EmployeePhones_Employees_EmployeeId",
column: x => x.EmployeeId,
principalTable: "Employees",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "FollowUps",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Reason = table.Column<string>(type: "nvarchar(max)", nullable: false),
ScheduleDate = table.Column<DateTime>(type: "datetime2", nullable: false),
ScheduleStartTime = table.Column<TimeSpan>(type: "time", nullable: false),
Status = table.Column<string>(type: "nvarchar(max)", nullable: false),
EmployeeId = table.Column<int>(type: "int", nullable: true),
WorkOrderId = table.Column<int>(type: "int", nullable: true),
AccountId = table.Column<int>(type: "int", nullable: true),
LocationId = table.Column<int>(type: "int", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: true),
createdby = table.Column<string>(type: "nvarchar(max)", nullable: true),
DeleterUserId = table.Column<string>(type: "nvarchar(max)", nullable: true),
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true),
CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifierUserId = table.Column<int>(type: "int", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_FollowUps", x => x.Id);
table.ForeignKey(
name: "FK_FollowUps_Accounts_AccountId",
column: x => x.AccountId,
principalTable: "Accounts",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_FollowUps_Employees_EmployeeId",
column: x => x.EmployeeId,
principalTable: "Employees",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_FollowUps_Locations_LocationId",
column: x => x.LocationId,
principalTable: "Locations",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_FollowUps_workOrders_WorkOrderId",
column: x => x.WorkOrderId,
principalTable: "workOrders",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
name: "IX_Contacts_AccountId",
table: "Contacts",
column: "AccountId");
migrationBuilder.CreateIndex(
name: "IX_Contacts_LocationId",
table: "Contacts",
column: "LocationId");
migrationBuilder.CreateIndex(
name: "IX_Addresses_AccountId",
table: "Addresses",
column: "AccountId");
migrationBuilder.CreateIndex(
name: "IX_Addresses_ContactId",
table: "Addresses",
column: "ContactId");
migrationBuilder.CreateIndex(
name: "IX_Assets_AccountId",
table: "Assets",
column: "AccountId");
migrationBuilder.CreateIndex(
name: "IX_Assets_LocationId",
table: "Assets",
column: "LocationId");
migrationBuilder.CreateIndex(
name: "IX_ContactDetails_ContactId",
table: "ContactDetails",
column: "ContactId");
migrationBuilder.CreateIndex(
name: "IX_EmployeeAddresses_EmployeeId",
table: "EmployeeAddresses",
column: "EmployeeId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_EmployeeEmails_EmployeeId",
table: "EmployeeEmails",
column: "EmployeeId");
migrationBuilder.CreateIndex(
name: "IX_EmployeePhones_EmployeeId",
table: "EmployeePhones",
column: "EmployeeId");
migrationBuilder.CreateIndex(
name: "IX_Employees_DepartmentId",
table: "Employees",
column: "DepartmentId");
migrationBuilder.CreateIndex(
name: "IX_Employees_JobTitleId",
table: "Employees",
column: "JobTitleId");
migrationBuilder.CreateIndex(
name: "IX_Employees_RegionId",
table: "Employees",
column: "RegionId");
migrationBuilder.CreateIndex(
name: "IX_FollowUps_AccountId",
table: "FollowUps",
column: "AccountId");
migrationBuilder.CreateIndex(
name: "IX_FollowUps_EmployeeId",
table: "FollowUps",
column: "EmployeeId");
migrationBuilder.CreateIndex(
name: "IX_FollowUps_LocationId",
table: "FollowUps",
column: "LocationId");
migrationBuilder.CreateIndex(
name: "IX_FollowUps_WorkOrderId",
table: "FollowUps",
column: "WorkOrderId");
migrationBuilder.CreateIndex(
name: "IX_PMSchedules_AssetId",
table: "PMSchedules",
column: "AssetId");
migrationBuilder.CreateIndex(
name: "IX_PMSchedules_LocationId",
table: "PMSchedules",
column: "LocationId");
migrationBuilder.AddForeignKey(
name: "FK_Contacts_Accounts_AccountId",
table: "Contacts",
column: "AccountId",
principalTable: "Accounts",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Contacts_Locations_LocationId",
table: "Contacts",
column: "LocationId",
principalTable: "Locations",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Contacts_Accounts_AccountId",
table: "Contacts");
migrationBuilder.DropForeignKey(
name: "FK_Contacts_Locations_LocationId",
table: "Contacts");
migrationBuilder.DropTable(
name: "Addresses");
migrationBuilder.DropTable(
name: "ContactDetails");
migrationBuilder.DropTable(
name: "EmployeeAddresses");
migrationBuilder.DropTable(
name: "EmployeeEmails");
migrationBuilder.DropTable(
name: "EmployeePhones");
migrationBuilder.DropTable(
name: "FollowUps");
migrationBuilder.DropTable(
name: "PMSchedules");
migrationBuilder.DropTable(
name: "Employees");
migrationBuilder.DropTable(
name: "Assets");
migrationBuilder.DropTable(
name: "Departments");
migrationBuilder.DropTable(
name: "JobTitles");
migrationBuilder.DropTable(
name: "Regions");
migrationBuilder.DropTable(
name: "Accounts");
migrationBuilder.DropIndex(
name: "IX_Contacts_AccountId",
table: "Contacts");
migrationBuilder.DropIndex(
name: "IX_Contacts_LocationId",
table: "Contacts");
migrationBuilder.DropColumn(
name: "AccountId",
table: "Contacts");
migrationBuilder.DropColumn(
name: "Address1",
table: "Contacts");
migrationBuilder.DropColumn(
name: "Address2",
table: "Contacts");
migrationBuilder.DropColumn(
name: "City",
table: "Contacts");
migrationBuilder.DropColumn(
name: "ContactType",
table: "Contacts");
migrationBuilder.DropColumn(
name: "FacebookUrl",
table: "Contacts");
migrationBuilder.DropColumn(
name: "FirstName",
table: "Contacts");
migrationBuilder.DropColumn(
name: "LastName",
table: "Contacts");
migrationBuilder.DropColumn(
name: "LinkedInUrl",
table: "Contacts");
migrationBuilder.DropColumn(
name: "LocationId",
table: "Contacts");
migrationBuilder.DropColumn(
name: "MiddleName",
table: "Contacts");
migrationBuilder.DropColumn(
name: "Owner",
table: "Contacts");
migrationBuilder.DropColumn(
name: "State",
table: "Contacts");
migrationBuilder.DropColumn(
name: "Title",
table: "Contacts");
migrationBuilder.DropColumn(
name: "TwitterUrl",
table: "Contacts");
migrationBuilder.RenameColumn(
name: "Zip",
table: "Contacts",
newName: "Name");
migrationBuilder.AlterColumn<string>(
name: "Name",
table: "AspNetUserTokens",
type: "nvarchar(128)",
maxLength: 128,
nullable: false,
oldClrType: typeof(string),
oldType: "nvarchar(450)");
migrationBuilder.AlterColumn<string>(
name: "LoginProvider",
table: "AspNetUserTokens",
type: "nvarchar(128)",
maxLength: 128,
nullable: false,
oldClrType: typeof(string),
oldType: "nvarchar(450)");
migrationBuilder.AlterColumn<string>(
name: "ProviderKey",
table: "AspNetUserLogins",
type: "nvarchar(128)",
maxLength: 128,
nullable: false,
oldClrType: typeof(string),
oldType: "nvarchar(450)");
migrationBuilder.AlterColumn<string>(
name: "LoginProvider",
table: "AspNetUserLogins",
type: "nvarchar(128)",
maxLength: 128,
nullable: false,
oldClrType: typeof(string),
oldType: "nvarchar(450)");
}
}
}