update inital migration

This commit is contained in:
Christian Arenas 2017-06-02 16:31:35 +02:00
parent 05fe4ccd6d
commit 5f976e90d4
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.EntityFrameworkCore.Migrations;
using Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure; 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))] [DbContext(typeof(MarketingContext))]
[Migration("20170601175200_Initial")] [Migration("20170602122539_Initial")]
partial class Initial partial class Initial
{ {
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)
@ -16,6 +16,7 @@ namespace Microsoft.eShopOnContainers.Services.Marketing.API.Migrations
modelBuilder modelBuilder
.HasAnnotation("ProductVersion", "1.1.2") .HasAnnotation("ProductVersion", "1.1.2")
.HasAnnotation("SqlServer:Sequence:.campaign_hilo", "'campaign_hilo', '', '1', '10', '', '', 'Int64', 'False'") .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); .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Marketing.API.Model.Campaign", b => 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 => modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Marketing.API.Model.Rule", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd(); .ValueGeneratedOnAdd()
.HasAnnotation("SqlServer:HiLoSequenceName", "rule_hilo")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo);
b.Property<int>("CampaignId"); b.Property<int>("CampaignId");
@ -59,7 +62,7 @@ namespace Microsoft.eShopOnContainers.Services.Marketing.API.Migrations
b.HasIndex("CampaignId"); b.HasIndex("CampaignId");
b.ToTable("Rules"); b.ToTable("Rule");
b.HasDiscriminator<int>("RuleTypeId"); 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 => 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") .WithMany("Rules")
.HasForeignKey("CampaignId") .HasForeignKey("CampaignId")
.OnDelete(DeleteBehavior.Cascade); .OnDelete(DeleteBehavior.Cascade);

View File

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

View File

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