using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace UnivateProperties_API.Migrations { public partial class publish20200624 : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AddColumn( name: "StatusDate", table: "Properties", nullable: false, defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); migrationBuilder.CreateTable( name: "Campaigns", columns: table => new { Id = table.Column(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), 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: "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: "PlaceHolderFormats", columns: table => new { Id = table.Column(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), 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: "CampaignItems", columns: table => new { Id = table.Column(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), 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: "CampaignPlaceHolders", columns: table => new { Id = table.Column(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), 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: "CampaignItemPlaceHolders", columns: table => new { Id = table.Column(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), 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_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"); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "CampaignItemPlaceHolders"); migrationBuilder.DropTable( name: "CampaignPlaceHolders"); migrationBuilder.DropTable( name: "Defaults"); migrationBuilder.DropTable( name: "PlaceHolderFormats"); migrationBuilder.DropTable( name: "CampaignItems"); migrationBuilder.DropTable( name: "Campaigns"); migrationBuilder.DropColumn( name: "StatusDate", table: "Properties"); } } }