using System; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; namespace UnivateProperties_API.Migrations { public partial class SQL_DB_Create : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Agencies", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), AgencyName = table.Column(nullable: true), EAABEFFCNumber = table.Column(nullable: true), CompanyRegNumber = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Agencies", x => x.Id); }); migrationBuilder.CreateTable( name: "Banks", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), Name = table.Column(nullable: true), UniversalBranchCode = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Banks", x => x.Id); }); migrationBuilder.CreateTable( name: "Campaigns", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), StartDate = table.Column(nullable: false), EndDate = table.Column(nullable: false), Name = table.Column(nullable: true), Subject = table.Column(nullable: true), Body = table.Column(nullable: true), ItemBody = table.Column(nullable: true), ItemsPerRow = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Campaigns", x => x.Id); }); migrationBuilder.CreateTable( name: "Carousel", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), PropertyId = table.Column(nullable: false), TimeshareId = table.Column(nullable: false), Header = table.Column(nullable: true), Image = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Carousel", x => x.Id); }); migrationBuilder.CreateTable( name: "Defaults", columns: table => new { Id = table.Column(nullable: false), Value = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Defaults", x => x.Id); }); migrationBuilder.CreateTable( name: "Hosts", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), Host = table.Column(nullable: true), NeedsAuthorize = table.Column(nullable: false), User = table.Column(nullable: true), Password = table.Column(nullable: true), UseSSL = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Hosts", x => x.Id); }); migrationBuilder.CreateTable( name: "Location", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), IsTesting = table.Column(nullable: false), PropertyImageLocation = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Location", x => x.Id); }); migrationBuilder.CreateTable( name: "PlaceHolderFormats", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), DisplayName = table.Column(nullable: true), Format = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_PlaceHolderFormats", x => x.Id); }); migrationBuilder.CreateTable( name: "PropertyTypes", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), Description = table.Column(nullable: true), UsageType = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_PropertyTypes", x => x.Id); }); migrationBuilder.CreateTable( name: "Provinces", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), Description = table.Column(nullable: true), Code = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Provinces", x => x.Id); }); migrationBuilder.CreateTable( name: "SearchLogs", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), Type = table.Column(nullable: true), Search = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_SearchLogs", x => x.Id); }); migrationBuilder.CreateTable( name: "Seasons", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), Name = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Seasons", x => x.Id); }); migrationBuilder.CreateTable( name: "Status", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), Code = table.Column(nullable: true), Description = table.Column(nullable: true), StatusType = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Status", x => x.Id); }); migrationBuilder.CreateTable( name: "UnitConfigurations", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), Code = table.Column(nullable: true), Bedrooms = table.Column(nullable: false), Adults = table.Column(nullable: false), Children = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_UnitConfigurations", x => x.Id); }); migrationBuilder.CreateTable( name: "UserDefinedGroups", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), Description = table.Column(nullable: true), UsageType = table.Column(nullable: false), Rank = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_UserDefinedGroups", x => x.Id); }); migrationBuilder.CreateTable( name: "Users", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), Username = table.Column(nullable: true), Role = table.Column(nullable: true), PasswordHash = table.Column(nullable: true), PasswordSalt = table.Column(nullable: true), Verified = table.Column(nullable: false), Token = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Users", x => x.Id); }); migrationBuilder.CreateTable( name: "CampaignPlaceHolders", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), Name = table.Column(nullable: true), BoundToClass = table.Column(nullable: true), BoundToClassDisplay = table.Column(nullable: true), BoundTo = table.Column(nullable: true), Format = table.Column(nullable: true), CampaignId = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_CampaignPlaceHolders", x => x.Id); table.ForeignKey( name: "FK_CampaignPlaceHolders_Campaigns_CampaignId", column: x => x.CampaignId, principalTable: "Campaigns", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Accounts", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), Address = table.Column(nullable: true), DisplayName = table.Column(nullable: true), Default = table.Column(nullable: false), SMTPHostId = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Accounts", x => x.Id); table.ForeignKey( name: "FK_Accounts_Hosts_SMTPHostId", column: x => x.SMTPHostId, principalTable: "Hosts", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Cities", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), ProvinceId = table.Column(nullable: false), Description = table.Column(nullable: true), Code = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Cities", x => x.Id); table.ForeignKey( name: "FK_Cities_Provinces_ProvinceId", column: x => x.ProvinceId, principalTable: "Provinces", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "UnitConfigurationTypes", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), Description = table.Column(nullable: true), UnitConfigurationId = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_UnitConfigurationTypes", x => x.Id); table.ForeignKey( name: "FK_UnitConfigurationTypes_UnitConfigurations_UnitConfigurationId", column: x => x.UnitConfigurationId, principalTable: "UnitConfigurations", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "UserDefinedFields", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), GroupId = table.Column(nullable: false), FieldName = table.Column(nullable: true), FieldType = table.Column(nullable: true), Rank = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_UserDefinedFields", x => x.Id); table.ForeignKey( name: "FK_UserDefinedFields_UserDefinedGroups_GroupId", column: x => x.GroupId, principalTable: "UserDefinedGroups", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Person", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), UserId = table.Column(nullable: true), Name = table.Column(nullable: true), Surname = table.Column(nullable: true), Email = table.Column(nullable: true), Telephone = table.Column(nullable: true), CellNumber = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Person", x => x.Id); table.ForeignKey( name: "FK_Person_Users_UserId", column: x => x.UserId, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Emails", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), SenderId = table.Column(nullable: false), Comment = table.Column(nullable: true), Subject = table.Column(nullable: true), IsBodyHtml = table.Column(nullable: false), CC = table.Column(nullable: true), BCC = table.Column(nullable: true), Body = table.Column(nullable: true), To = table.Column(nullable: true), ToDisplay = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Emails", x => x.Id); table.ForeignKey( name: "FK_Emails_Accounts_SenderId", column: x => x.SenderId, principalTable: "Accounts", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Templates", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), Name = table.Column(nullable: true), Subject = table.Column(nullable: true), Body = table.Column(nullable: true), SenderId = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Templates", x => x.Id); table.ForeignKey( name: "FK_Templates_Accounts_SenderId", column: x => x.SenderId, principalTable: "Accounts", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Suburbs", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), CityId = table.Column(nullable: false), Description = table.Column(nullable: true), PostalCode = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Suburbs", x => x.Id); table.ForeignKey( name: "FK_Suburbs_Cities_CityId", column: x => x.CityId, principalTable: "Cities", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Agents", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), UserId = table.Column(nullable: true), Name = table.Column(nullable: true), Surname = table.Column(nullable: true), Email = table.Column(nullable: true), Telephone = table.Column(nullable: true), CellNumber = table.Column(nullable: true), AgencyId = table.Column(nullable: true), TemplateId = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Agents", x => x.Id); table.ForeignKey( name: "FK_Agents_Agencies_AgencyId", column: x => x.AgencyId, principalTable: "Agencies", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Agents_Templates_TemplateId", column: x => x.TemplateId, principalTable: "Templates", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Agents_Users_UserId", column: x => x.UserId, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "PlaceHolders", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), Name = table.Column(nullable: true), BoundToClass = table.Column(nullable: true), BoundToClassDisplay = table.Column(nullable: true), BoundTo = table.Column(nullable: true), TemplateId = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_PlaceHolders", x => x.Id); table.ForeignKey( name: "FK_PlaceHolders_Templates_TemplateId", column: x => x.TemplateId, principalTable: "Templates", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Individuals", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), UserId = table.Column(nullable: true), Name = table.Column(nullable: true), Surname = table.Column(nullable: true), Email = table.Column(nullable: true), Telephone = table.Column(nullable: true), CellNumber = table.Column(nullable: true), IdNumber = table.Column(nullable: true), CompanyRegNumber = table.Column(nullable: true), MaritalStatus = table.Column(nullable: true), AddressId = table.Column(nullable: true), IncomeTaxNumber = table.Column(nullable: true), BankAccountId = table.Column(nullable: true), TemplateId = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Individuals", x => x.Id); table.ForeignKey( name: "FK_Individuals_Templates_TemplateId", column: x => x.TemplateId, principalTable: "Templates", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Individuals_Users_UserId", column: x => x.UserId, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Addresses", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), StreetNumber = table.Column(nullable: true), Street = table.Column(nullable: true), Suburb = table.Column(nullable: true), City = table.Column(nullable: true), PostalCode = table.Column(nullable: true), Province = table.Column(nullable: true), OwnerId = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Addresses", x => x.Id); table.ForeignKey( name: "FK_Addresses_Individuals_OwnerId", column: x => x.OwnerId, principalTable: "Individuals", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "BankAccounts", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), AccountHolder = table.Column(nullable: true), AccountNumber = table.Column(nullable: true), BankId = table.Column(nullable: true), OwnerId = table.Column(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.Restrict); table.ForeignKey( name: "FK_BankAccounts_Individuals_OwnerId", column: x => x.OwnerId, principalTable: "Individuals", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Properties", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), PropertyTypeId = table.Column(nullable: false), PropertyName = table.Column(nullable: true), Unit = table.Column(nullable: true), OperationalCosts = table.Column(nullable: false), Price = table.Column(nullable: false), PricePer = table.Column(nullable: true), IsSale = table.Column(nullable: false), Description = table.Column(nullable: true), ShortDescription = table.Column(nullable: true), AddressLine1 = table.Column(nullable: true), AddressLine2 = table.Column(nullable: true), AddressLine3 = table.Column(nullable: true), SuburbId = table.Column(nullable: false), CityId = table.Column(nullable: false), ProvinceId = table.Column(nullable: false), Published = table.Column(nullable: false), DatePublished = table.Column(nullable: false), VirtualTour = table.Column(nullable: true), Video = table.Column(nullable: true), StatusId = table.Column(nullable: true), OwnerId = table.Column(nullable: true), AgentId = table.Column(nullable: true), AgencyId = table.Column(nullable: true), DateAvailable = table.Column(nullable: false), StatusDate = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Properties", x => x.Id); table.ForeignKey( name: "FK_Properties_Agencies_AgencyId", column: x => x.AgencyId, principalTable: "Agencies", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Properties_Agents_AgentId", column: x => x.AgentId, principalTable: "Agents", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Properties_Individuals_OwnerId", column: x => x.OwnerId, principalTable: "Individuals", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Weeks", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), ReferedByAgent = table.Column(nullable: false), AgentId = table.Column(nullable: true), AgencyId = table.Column(nullable: true), OwnerId = table.Column(nullable: false), AgentAsRep = table.Column(nullable: false), OtherResort = table.Column(nullable: false), OtherResortName = table.Column(nullable: true), ResortCode = table.Column(nullable: true), ResortName = table.Column(nullable: true), RegionId = table.Column(nullable: false), Season = table.Column(nullable: true), Module = table.Column(nullable: true), Bedrooms = table.Column(nullable: false), MaxSleep = table.Column(nullable: false), UnitNumber = table.Column(nullable: true), WeekNumber = table.Column(nullable: true), LevyAmount = table.Column(nullable: false), CurrentYearBanked = table.Column(nullable: false), BankedWith = table.Column(nullable: true), LeviesPaidInFull = table.Column(nullable: false), WeekPlacedForRental = table.Column(nullable: false), OriginalPurchasePrice = table.Column(nullable: false), OriginalPurchaseDate = table.Column(nullable: false), ArrivalDate = table.Column(nullable: false), DepartureDate = table.Column(nullable: false), SellPrice = table.Column(nullable: false), AgentCommision = table.Column(nullable: false), Mandate = table.Column(nullable: true), StatusId = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Weeks", x => x.Id); table.ForeignKey( name: "FK_Weeks_Agencies_AgencyId", column: x => x.AgencyId, principalTable: "Agencies", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Weeks_Agents_AgentId", column: x => x.AgentId, principalTable: "Agents", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Weeks_Individuals_OwnerId", column: x => x.OwnerId, principalTable: "Individuals", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Weeks_Provinces_RegionId", column: x => x.RegionId, principalTable: "Provinces", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Weeks_Status_StatusId", column: x => x.StatusId, principalTable: "Status", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "PropertyImages", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), PropertyId = table.Column(nullable: false), Image = table.Column(nullable: true), IsDefault = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_PropertyImages", x => x.Id); table.ForeignKey( name: "FK_PropertyImages_Properties_PropertyId", column: x => x.PropertyId, principalTable: "Properties", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "PropertyUserFields", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), PropertyId = table.Column(nullable: false), UserDefinedFieldId = table.Column(nullable: false), Value = table.Column(nullable: true), Description = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_PropertyUserFields", x => x.Id); table.ForeignKey( name: "FK_PropertyUserFields_Properties_PropertyId", column: x => x.PropertyId, principalTable: "Properties", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_PropertyUserFields_UserDefinedFields_UserDefinedFieldId", column: x => x.UserDefinedFieldId, principalTable: "UserDefinedFields", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "BidItems", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), Amount = table.Column(nullable: false), StatusId = table.Column(nullable: true), BidMakerId = table.Column(nullable: true), TimeshareWeekId = table.Column(nullable: true), PropertyId = table.Column(nullable: true), Comment = table.Column(nullable: true), DeclinedReason = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_BidItems", x => x.Id); table.ForeignKey( name: "FK_BidItems_Individuals_BidMakerId", column: x => x.BidMakerId, principalTable: "Individuals", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_BidItems_Properties_PropertyId", column: x => x.PropertyId, principalTable: "Properties", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_BidItems_Status_StatusId", column: x => x.StatusId, principalTable: "Status", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_BidItems_Weeks_TimeshareWeekId", column: x => x.TimeshareWeekId, principalTable: "Weeks", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "CampaignItems", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), CampaignId = table.Column(nullable: false), WeekId = table.Column(nullable: false), Image = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_CampaignItems", x => x.Id); table.ForeignKey( name: "FK_CampaignItems_Campaigns_CampaignId", column: x => x.CampaignId, principalTable: "Campaigns", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_CampaignItems_Weeks_WeekId", column: x => x.WeekId, principalTable: "Weeks", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Payments", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), TimeshareWeekId = table.Column(nullable: true), PropertyId = table.Column(nullable: true), CreatedById = table.Column(nullable: false), Amount = table.Column(nullable: false), PaymentStatus = table.Column(nullable: true), PaymentToken = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Payments", x => x.Id); table.ForeignKey( name: "FK_Payments_Users_CreatedById", column: x => x.CreatedById, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Payments_Properties_PropertyId", column: x => x.PropertyId, principalTable: "Properties", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Payments_Weeks_TimeshareWeekId", column: x => x.TimeshareWeekId, principalTable: "Weeks", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "ProcessFlows", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), TimeshareID = table.Column(nullable: true), PropertyID = table.Column(nullable: true), StatusID = table.Column(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: "CampaignItemPlaceHolders", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), CampaignItemId = table.Column(nullable: false), PlaceHolder = table.Column(nullable: true), Value = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_CampaignItemPlaceHolders", x => x.Id); table.ForeignKey( name: "FK_CampaignItemPlaceHolders_CampaignItems_CampaignItemId", column: x => x.CampaignItemId, principalTable: "CampaignItems", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_Accounts_SMTPHostId", table: "Accounts", column: "SMTPHostId"); migrationBuilder.CreateIndex( name: "IX_Addresses_OwnerId", table: "Addresses", column: "OwnerId"); migrationBuilder.CreateIndex( name: "IX_Agents_AgencyId", table: "Agents", column: "AgencyId"); migrationBuilder.CreateIndex( name: "IX_Agents_TemplateId", table: "Agents", column: "TemplateId"); migrationBuilder.CreateIndex( name: "IX_Agents_UserId", table: "Agents", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_BankAccounts_BankId", table: "BankAccounts", column: "BankId"); migrationBuilder.CreateIndex( name: "IX_BankAccounts_OwnerId", table: "BankAccounts", column: "OwnerId"); migrationBuilder.CreateIndex( name: "IX_BidItems_BidMakerId", table: "BidItems", column: "BidMakerId"); migrationBuilder.CreateIndex( name: "IX_BidItems_PropertyId", table: "BidItems", column: "PropertyId"); migrationBuilder.CreateIndex( name: "IX_BidItems_StatusId", table: "BidItems", column: "StatusId"); migrationBuilder.CreateIndex( name: "IX_BidItems_TimeshareWeekId", table: "BidItems", column: "TimeshareWeekId"); migrationBuilder.CreateIndex( name: "IX_CampaignItemPlaceHolders_CampaignItemId", table: "CampaignItemPlaceHolders", column: "CampaignItemId"); migrationBuilder.CreateIndex( name: "IX_CampaignItems_CampaignId", table: "CampaignItems", column: "CampaignId"); migrationBuilder.CreateIndex( name: "IX_CampaignItems_WeekId", table: "CampaignItems", column: "WeekId"); migrationBuilder.CreateIndex( name: "IX_CampaignPlaceHolders_CampaignId", table: "CampaignPlaceHolders", column: "CampaignId"); migrationBuilder.CreateIndex( name: "IX_Cities_ProvinceId", table: "Cities", column: "ProvinceId"); migrationBuilder.CreateIndex( name: "IX_Emails_SenderId", table: "Emails", column: "SenderId"); migrationBuilder.CreateIndex( name: "IX_Individuals_AddressId", table: "Individuals", column: "AddressId"); migrationBuilder.CreateIndex( name: "IX_Individuals_BankAccountId", table: "Individuals", column: "BankAccountId"); migrationBuilder.CreateIndex( name: "IX_Individuals_TemplateId", table: "Individuals", column: "TemplateId"); migrationBuilder.CreateIndex( name: "IX_Individuals_UserId", table: "Individuals", column: "UserId"); 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.CreateIndex( name: "IX_Payments_CreatedById", table: "Payments", column: "CreatedById"); migrationBuilder.CreateIndex( name: "IX_Payments_PropertyId", table: "Payments", column: "PropertyId"); migrationBuilder.CreateIndex( name: "IX_Payments_TimeshareWeekId", table: "Payments", column: "TimeshareWeekId"); migrationBuilder.CreateIndex( name: "IX_Person_UserId", table: "Person", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_PlaceHolders_TemplateId", table: "PlaceHolders", column: "TemplateId"); 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.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_PropertyImages_PropertyId", table: "PropertyImages", column: "PropertyId"); migrationBuilder.CreateIndex( name: "IX_PropertyUserFields_PropertyId", table: "PropertyUserFields", column: "PropertyId"); migrationBuilder.CreateIndex( name: "IX_PropertyUserFields_UserDefinedFieldId", table: "PropertyUserFields", column: "UserDefinedFieldId"); migrationBuilder.CreateIndex( name: "IX_Suburbs_CityId", table: "Suburbs", column: "CityId"); migrationBuilder.CreateIndex( name: "IX_Templates_SenderId", table: "Templates", column: "SenderId"); migrationBuilder.CreateIndex( name: "IX_UnitConfigurations_Code", table: "UnitConfigurations", column: "Code", unique: true, filter: "[Code] IS NOT NULL"); migrationBuilder.CreateIndex( name: "IX_UnitConfigurationTypes_UnitConfigurationId", table: "UnitConfigurationTypes", column: "UnitConfigurationId"); migrationBuilder.CreateIndex( name: "IX_UserDefinedFields_GroupId", table: "UserDefinedFields", column: "GroupId"); migrationBuilder.CreateIndex( name: "IX_Users_Username", table: "Users", column: "Username", unique: true, filter: "[Username] IS NOT NULL"); migrationBuilder.CreateIndex( name: "IX_Weeks_AgencyId", table: "Weeks", column: "AgencyId"); migrationBuilder.CreateIndex( name: "IX_Weeks_AgentId", table: "Weeks", column: "AgentId"); migrationBuilder.CreateIndex( name: "IX_Weeks_OwnerId", table: "Weeks", column: "OwnerId"); migrationBuilder.CreateIndex( name: "IX_Weeks_RegionId", table: "Weeks", column: "RegionId"); migrationBuilder.CreateIndex( name: "IX_Weeks_StatusId", table: "Weeks", column: "StatusId"); migrationBuilder.AddForeignKey( name: "FK_Individuals_Addresses_AddressId", table: "Individuals", column: "AddressId", principalTable: "Addresses", principalColumn: "Id", onDelete: ReferentialAction.Restrict); migrationBuilder.AddForeignKey( name: "FK_Individuals_BankAccounts_BankAccountId", table: "Individuals", column: "BankAccountId", principalTable: "BankAccounts", principalColumn: "Id", onDelete: ReferentialAction.Restrict); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_Accounts_Hosts_SMTPHostId", table: "Accounts"); migrationBuilder.DropForeignKey( name: "FK_Addresses_Individuals_OwnerId", table: "Addresses"); migrationBuilder.DropForeignKey( name: "FK_BankAccounts_Individuals_OwnerId", table: "BankAccounts"); migrationBuilder.DropTable( name: "BidItems"); migrationBuilder.DropTable( name: "CampaignItemPlaceHolders"); migrationBuilder.DropTable( name: "CampaignPlaceHolders"); migrationBuilder.DropTable( name: "Carousel"); migrationBuilder.DropTable( name: "Defaults"); migrationBuilder.DropTable( name: "Emails"); migrationBuilder.DropTable( name: "Location"); migrationBuilder.DropTable( name: "Payments"); migrationBuilder.DropTable( name: "Person"); migrationBuilder.DropTable( name: "PlaceHolderFormats"); migrationBuilder.DropTable( name: "PlaceHolders"); migrationBuilder.DropTable( name: "ProcessFlows"); migrationBuilder.DropTable( name: "PropertyImages"); migrationBuilder.DropTable( name: "PropertyTypes"); migrationBuilder.DropTable( name: "PropertyUserFields"); migrationBuilder.DropTable( name: "SearchLogs"); migrationBuilder.DropTable( name: "Seasons"); migrationBuilder.DropTable( name: "Suburbs"); migrationBuilder.DropTable( name: "UnitConfigurationTypes"); migrationBuilder.DropTable( name: "CampaignItems"); migrationBuilder.DropTable( name: "Properties"); migrationBuilder.DropTable( name: "UserDefinedFields"); migrationBuilder.DropTable( name: "Cities"); migrationBuilder.DropTable( name: "UnitConfigurations"); migrationBuilder.DropTable( name: "Campaigns"); migrationBuilder.DropTable( name: "Weeks"); migrationBuilder.DropTable( name: "UserDefinedGroups"); migrationBuilder.DropTable( name: "Agents"); migrationBuilder.DropTable( name: "Provinces"); migrationBuilder.DropTable( name: "Status"); migrationBuilder.DropTable( name: "Agencies"); migrationBuilder.DropTable( name: "Hosts"); migrationBuilder.DropTable( name: "Individuals"); migrationBuilder.DropTable( name: "Addresses"); migrationBuilder.DropTable( name: "BankAccounts"); migrationBuilder.DropTable( name: "Templates"); migrationBuilder.DropTable( name: "Users"); migrationBuilder.DropTable( name: "Banks"); migrationBuilder.DropTable( name: "Accounts"); } } }