update inital migration

This commit is contained in:
Christian Arenas 2017-06-02 16:31:35 +02:00
parent 1bd13747f4
commit c132d944d7
3 changed files with 30 additions and 19 deletions

View File

@ -5,10 +5,10 @@ using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure;
namespace Microsoft.eShopOnContainers.Services.Marketing.API.Migrations
namespace Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.MarketingMigrations
{
[DbContext(typeof(MarketingContext))]
[Migration("20170601175200_Initial")]
[Migration("20170602122539_Initial")]
partial class Initial
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@ -16,6 +16,7 @@ namespace Microsoft.eShopOnContainers.Services.Marketing.API.Migrations
modelBuilder
.HasAnnotation("ProductVersion", "1.1.2")
.HasAnnotation("SqlServer:Sequence:.campaign_hilo", "'campaign_hilo', '', '1', '10', '', '', 'Int64', 'False'")
.HasAnnotation("SqlServer:Sequence:.rule_hilo", "'rule_hilo', '', '1', '10', '', '', 'Int64', 'False'")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Marketing.API.Model.Campaign", b =>
@ -45,7 +46,9 @@ namespace Microsoft.eShopOnContainers.Services.Marketing.API.Migrations
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Marketing.API.Model.Rule", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
.ValueGeneratedOnAdd()
.HasAnnotation("SqlServer:HiLoSequenceName", "rule_hilo")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo);
b.Property<int>("CampaignId");
@ -59,7 +62,7 @@ namespace Microsoft.eShopOnContainers.Services.Marketing.API.Migrations
b.HasIndex("CampaignId");
b.ToTable("Rules");
b.ToTable("Rule");
b.HasDiscriminator<int>("RuleTypeId");
});
@ -98,7 +101,7 @@ namespace Microsoft.eShopOnContainers.Services.Marketing.API.Migrations
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Marketing.API.Model.Rule", b =>
{
b.HasOne("Microsoft.eShopOnContainers.Services.Marketing.API.Model.Campaign", "Campaign")
b.HasOne("Microsoft.eShopOnContainers.Services.Marketing.API.Model.Campaign")
.WithMany("Rules")
.HasForeignKey("CampaignId")
.OnDelete(DeleteBehavior.Cascade);

View File

@ -1,9 +1,8 @@
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Metadata;
namespace Microsoft.eShopOnContainers.Services.Marketing.API.Migrations
namespace Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.MarketingMigrations
{
public partial class Initial : Migration
{
@ -13,6 +12,10 @@ namespace Microsoft.eShopOnContainers.Services.Marketing.API.Migrations
name: "campaign_hilo",
incrementBy: 10);
migrationBuilder.CreateSequence(
name: "rule_hilo",
incrementBy: 10);
migrationBuilder.CreateTable(
name: "Campaign",
columns: table => new
@ -29,11 +32,10 @@ namespace Microsoft.eShopOnContainers.Services.Marketing.API.Migrations
});
migrationBuilder.CreateTable(
name: "Rules",
name: "Rule",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
Id = table.Column<int>(nullable: false),
CampaignId = table.Column<int>(nullable: false),
Description = table.Column<string>(nullable: false),
RuleTypeId = table.Column<int>(nullable: false),
@ -41,9 +43,9 @@ namespace Microsoft.eShopOnContainers.Services.Marketing.API.Migrations
},
constraints: table =>
{
table.PrimaryKey("PK_Rules", x => x.Id);
table.PrimaryKey("PK_Rule", x => x.Id);
table.ForeignKey(
name: "FK_Rules_Campaign_CampaignId",
name: "FK_Rule_Campaign_CampaignId",
column: x => x.CampaignId,
principalTable: "Campaign",
principalColumn: "Id",
@ -51,21 +53,24 @@ namespace Microsoft.eShopOnContainers.Services.Marketing.API.Migrations
});
migrationBuilder.CreateIndex(
name: "IX_Rules_CampaignId",
table: "Rules",
name: "IX_Rule_CampaignId",
table: "Rule",
column: "CampaignId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Rules");
name: "Rule");
migrationBuilder.DropTable(
name: "Campaign");
migrationBuilder.DropSequence(
name: "campaign_hilo");
migrationBuilder.DropSequence(
name: "rule_hilo");
}
}
}

View File

@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure;
namespace Microsoft.eShopOnContainers.Services.Marketing.API.Migrations
namespace Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.MarketingMigrations
{
[DbContext(typeof(MarketingContext))]
partial class MarketingContextModelSnapshot : ModelSnapshot
@ -15,6 +15,7 @@ namespace Microsoft.eShopOnContainers.Services.Marketing.API.Migrations
modelBuilder
.HasAnnotation("ProductVersion", "1.1.2")
.HasAnnotation("SqlServer:Sequence:.campaign_hilo", "'campaign_hilo', '', '1', '10', '', '', 'Int64', 'False'")
.HasAnnotation("SqlServer:Sequence:.rule_hilo", "'rule_hilo', '', '1', '10', '', '', 'Int64', 'False'")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Marketing.API.Model.Campaign", b =>
@ -44,7 +45,9 @@ namespace Microsoft.eShopOnContainers.Services.Marketing.API.Migrations
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Marketing.API.Model.Rule", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
.ValueGeneratedOnAdd()
.HasAnnotation("SqlServer:HiLoSequenceName", "rule_hilo")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo);
b.Property<int>("CampaignId");
@ -58,7 +61,7 @@ namespace Microsoft.eShopOnContainers.Services.Marketing.API.Migrations
b.HasIndex("CampaignId");
b.ToTable("Rules");
b.ToTable("Rule");
b.HasDiscriminator<int>("RuleTypeId");
});
@ -97,7 +100,7 @@ namespace Microsoft.eShopOnContainers.Services.Marketing.API.Migrations
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Marketing.API.Model.Rule", b =>
{
b.HasOne("Microsoft.eShopOnContainers.Services.Marketing.API.Model.Campaign", "Campaign")
b.HasOne("Microsoft.eShopOnContainers.Services.Marketing.API.Model.Campaign")
.WithMany("Rules")
.HasForeignKey("CampaignId")
.OnDelete(DeleteBehavior.Cascade);