@ -0,0 +1,99 @@ | |||
using System; | |||
using Microsoft.EntityFrameworkCore; | |||
using Microsoft.EntityFrameworkCore.Infrastructure; | |||
using Microsoft.EntityFrameworkCore.Metadata; | |||
using Microsoft.EntityFrameworkCore.Migrations; | |||
using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure; | |||
namespace Catalog.API.Infrastructure.Migrations | |||
{ | |||
[DbContext(typeof(CatalogContext))] | |||
[Migration("20161103152832_Initial")] | |||
partial class Initial | |||
{ | |||
protected override void BuildTargetModel(ModelBuilder modelBuilder) | |||
{ | |||
modelBuilder | |||
.HasAnnotation("ProductVersion", "1.0.1") | |||
.HasAnnotation("SqlServer:Sequence:.catalog_brand_hilo", "'catalog_brand_hilo', '', '1', '10', '', '', 'Int64', 'False'") | |||
.HasAnnotation("SqlServer:Sequence:.catalog_hilo", "'catalog_hilo', '', '1', '10', '', '', 'Int64', 'False'") | |||
.HasAnnotation("SqlServer:Sequence:.catalog_type_hilo", "'catalog_type_hilo', '', '1', '10', '', '', 'Int64', 'False'") | |||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); | |||
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.CatalogBrand", b => | |||
{ | |||
b.Property<int>("Id") | |||
.ValueGeneratedOnAdd() | |||
.HasAnnotation("SqlServer:HiLoSequenceName", "catalog_brand_hilo") | |||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo); | |||
b.Property<string>("Brand") | |||
.IsRequired() | |||
.HasAnnotation("MaxLength", 100); | |||
b.HasKey("Id"); | |||
b.ToTable("catalogbrand"); | |||
}); | |||
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.CatalogItem", b => | |||
{ | |||
b.Property<int>("Id") | |||
.ValueGeneratedOnAdd() | |||
.HasAnnotation("SqlServer:HiLoSequenceName", "catalog_hilo") | |||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo); | |||
b.Property<int>("CatalogBrandId"); | |||
b.Property<int>("CatalogTypeId"); | |||
b.Property<string>("Description"); | |||
b.Property<string>("Name") | |||
.IsRequired() | |||
.HasAnnotation("MaxLength", 50); | |||
b.Property<string>("PictureUri"); | |||
b.Property<decimal>("Price"); | |||
b.HasKey("Id"); | |||
b.HasIndex("CatalogBrandId"); | |||
b.HasIndex("CatalogTypeId"); | |||
b.ToTable("catalog"); | |||
}); | |||
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.CatalogType", b => | |||
{ | |||
b.Property<int>("Id") | |||
.ValueGeneratedOnAdd() | |||
.HasAnnotation("SqlServer:HiLoSequenceName", "catalog_type_hilo") | |||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo); | |||
b.Property<string>("Type") | |||
.IsRequired() | |||
.HasAnnotation("MaxLength", 100); | |||
b.HasKey("Id"); | |||
b.ToTable("CatalogTypes"); | |||
}); | |||
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.CatalogItem", b => | |||
{ | |||
b.HasOne("Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.CatalogBrand", "CatalogBrand") | |||
.WithMany() | |||
.HasForeignKey("CatalogBrandId") | |||
.OnDelete(DeleteBehavior.Cascade); | |||
b.HasOne("Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.CatalogType", "CatalogType") | |||
.WithMany() | |||
.HasForeignKey("CatalogTypeId") | |||
.OnDelete(DeleteBehavior.Cascade); | |||
}); | |||
} | |||
} | |||
} |
@ -0,0 +1,108 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using Microsoft.EntityFrameworkCore.Migrations; | |||
namespace Catalog.API.Infrastructure.Migrations | |||
{ | |||
public partial class Initial : Migration | |||
{ | |||
protected override void Up(MigrationBuilder migrationBuilder) | |||
{ | |||
migrationBuilder.CreateSequence( | |||
name: "catalog_brand_hilo", | |||
incrementBy: 10); | |||
migrationBuilder.CreateSequence( | |||
name: "catalog_hilo", | |||
incrementBy: 10); | |||
migrationBuilder.CreateSequence( | |||
name: "catalog_type_hilo", | |||
incrementBy: 10); | |||
migrationBuilder.CreateTable( | |||
name: "catalogbrand", | |||
columns: table => new | |||
{ | |||
Id = table.Column<int>(nullable: false), | |||
Brand = table.Column<string>(maxLength: 100, nullable: false) | |||
}, | |||
constraints: table => | |||
{ | |||
table.PrimaryKey("PK_catalogbrand", x => x.Id); | |||
}); | |||
migrationBuilder.CreateTable( | |||
name: "CatalogTypes", | |||
columns: table => new | |||
{ | |||
Id = table.Column<int>(nullable: false), | |||
Type = table.Column<string>(maxLength: 100, nullable: false) | |||
}, | |||
constraints: table => | |||
{ | |||
table.PrimaryKey("PK_CatalogTypes", x => x.Id); | |||
}); | |||
migrationBuilder.CreateTable( | |||
name: "catalog", | |||
columns: table => new | |||
{ | |||
Id = table.Column<int>(nullable: false), | |||
CatalogBrandId = table.Column<int>(nullable: false), | |||
CatalogTypeId = table.Column<int>(nullable: false), | |||
Description = table.Column<string>(nullable: true), | |||
Name = table.Column<string>(maxLength: 50, nullable: false), | |||
PictureUri = table.Column<string>(nullable: true), | |||
Price = table.Column<decimal>(nullable: false) | |||
}, | |||
constraints: table => | |||
{ | |||
table.PrimaryKey("PK_catalog", x => x.Id); | |||
table.ForeignKey( | |||
name: "FK_catalog_catalogbrand_CatalogBrandId", | |||
column: x => x.CatalogBrandId, | |||
principalTable: "catalogbrand", | |||
principalColumn: "Id", | |||
onDelete: ReferentialAction.Cascade); | |||
table.ForeignKey( | |||
name: "FK_catalog_CatalogTypes_CatalogTypeId", | |||
column: x => x.CatalogTypeId, | |||
principalTable: "CatalogTypes", | |||
principalColumn: "Id", | |||
onDelete: ReferentialAction.Cascade); | |||
}); | |||
migrationBuilder.CreateIndex( | |||
name: "IX_catalog_CatalogBrandId", | |||
table: "catalog", | |||
column: "CatalogBrandId"); | |||
migrationBuilder.CreateIndex( | |||
name: "IX_catalog_CatalogTypeId", | |||
table: "catalog", | |||
column: "CatalogTypeId"); | |||
} | |||
protected override void Down(MigrationBuilder migrationBuilder) | |||
{ | |||
migrationBuilder.DropSequence( | |||
name: "catalog_brand_hilo"); | |||
migrationBuilder.DropSequence( | |||
name: "catalog_hilo"); | |||
migrationBuilder.DropSequence( | |||
name: "catalog_type_hilo"); | |||
migrationBuilder.DropTable( | |||
name: "catalog"); | |||
migrationBuilder.DropTable( | |||
name: "catalogbrand"); | |||
migrationBuilder.DropTable( | |||
name: "CatalogTypes"); | |||
} | |||
} | |||
} |
@ -0,0 +1,99 @@ | |||
using System; | |||
using Microsoft.EntityFrameworkCore; | |||
using Microsoft.EntityFrameworkCore.Infrastructure; | |||
using Microsoft.EntityFrameworkCore.Metadata; | |||
using Microsoft.EntityFrameworkCore.Migrations; | |||
using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure; | |||
namespace Catalog.API.Infrastructure.Migrations | |||
{ | |||
[DbContext(typeof(CatalogContext))] | |||
[Migration("20161103153420_UpdateTableNames")] | |||
partial class UpdateTableNames | |||
{ | |||
protected override void BuildTargetModel(ModelBuilder modelBuilder) | |||
{ | |||
modelBuilder | |||
.HasAnnotation("ProductVersion", "1.0.1") | |||
.HasAnnotation("SqlServer:Sequence:.catalog_brand_hilo", "'catalog_brand_hilo', '', '1', '10', '', '', 'Int64', 'False'") | |||
.HasAnnotation("SqlServer:Sequence:.catalog_hilo", "'catalog_hilo', '', '1', '10', '', '', 'Int64', 'False'") | |||
.HasAnnotation("SqlServer:Sequence:.catalog_type_hilo", "'catalog_type_hilo', '', '1', '10', '', '', 'Int64', 'False'") | |||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); | |||
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.CatalogBrand", b => | |||
{ | |||
b.Property<int>("Id") | |||
.ValueGeneratedOnAdd() | |||
.HasAnnotation("SqlServer:HiLoSequenceName", "catalog_brand_hilo") | |||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo); | |||
b.Property<string>("Brand") | |||
.IsRequired() | |||
.HasAnnotation("MaxLength", 100); | |||
b.HasKey("Id"); | |||
b.ToTable("CatalogBrand"); | |||
}); | |||
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.CatalogItem", b => | |||
{ | |||
b.Property<int>("Id") | |||
.ValueGeneratedOnAdd() | |||
.HasAnnotation("SqlServer:HiLoSequenceName", "catalog_hilo") | |||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo); | |||
b.Property<int>("CatalogBrandId"); | |||
b.Property<int>("CatalogTypeId"); | |||
b.Property<string>("Description"); | |||
b.Property<string>("Name") | |||
.IsRequired() | |||
.HasAnnotation("MaxLength", 50); | |||
b.Property<string>("PictureUri"); | |||
b.Property<decimal>("Price"); | |||
b.HasKey("Id"); | |||
b.HasIndex("CatalogBrandId"); | |||
b.HasIndex("CatalogTypeId"); | |||
b.ToTable("Catalog"); | |||
}); | |||
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.CatalogType", b => | |||
{ | |||
b.Property<int>("Id") | |||
.ValueGeneratedOnAdd() | |||
.HasAnnotation("SqlServer:HiLoSequenceName", "catalog_type_hilo") | |||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo); | |||
b.Property<string>("Type") | |||
.IsRequired() | |||
.HasAnnotation("MaxLength", 100); | |||
b.HasKey("Id"); | |||
b.ToTable("CatalogType"); | |||
}); | |||
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.CatalogItem", b => | |||
{ | |||
b.HasOne("Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.CatalogBrand", "CatalogBrand") | |||
.WithMany() | |||
.HasForeignKey("CatalogBrandId") | |||
.OnDelete(DeleteBehavior.Cascade); | |||
b.HasOne("Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.CatalogType", "CatalogType") | |||
.WithMany() | |||
.HasForeignKey("CatalogTypeId") | |||
.OnDelete(DeleteBehavior.Cascade); | |||
}); | |||
} | |||
} | |||
} |
@ -0,0 +1,161 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using Microsoft.EntityFrameworkCore.Migrations; | |||
namespace Catalog.API.Infrastructure.Migrations | |||
{ | |||
public partial class UpdateTableNames : Migration | |||
{ | |||
protected override void Up(MigrationBuilder migrationBuilder) | |||
{ | |||
migrationBuilder.DropForeignKey( | |||
name: "FK_catalog_catalogbrand_CatalogBrandId", | |||
table: "catalog"); | |||
migrationBuilder.DropForeignKey( | |||
name: "FK_catalog_CatalogTypes_CatalogTypeId", | |||
table: "catalog"); | |||
migrationBuilder.DropPrimaryKey( | |||
name: "PK_CatalogTypes", | |||
table: "CatalogTypes"); | |||
migrationBuilder.DropPrimaryKey( | |||
name: "PK_catalog", | |||
table: "catalog"); | |||
migrationBuilder.DropPrimaryKey( | |||
name: "PK_catalogbrand", | |||
table: "catalogbrand"); | |||
migrationBuilder.AddPrimaryKey( | |||
name: "PK_CatalogType", | |||
table: "CatalogTypes", | |||
column: "Id"); | |||
migrationBuilder.AddPrimaryKey( | |||
name: "PK_Catalog", | |||
table: "catalog", | |||
column: "Id"); | |||
migrationBuilder.AddPrimaryKey( | |||
name: "PK_CatalogBrand", | |||
table: "catalogbrand", | |||
column: "Id"); | |||
migrationBuilder.AddForeignKey( | |||
name: "FK_Catalog_CatalogBrand_CatalogBrandId", | |||
table: "catalog", | |||
column: "CatalogBrandId", | |||
principalTable: "catalogbrand", | |||
principalColumn: "Id", | |||
onDelete: ReferentialAction.Cascade); | |||
migrationBuilder.AddForeignKey( | |||
name: "FK_Catalog_CatalogType_CatalogTypeId", | |||
table: "catalog", | |||
column: "CatalogTypeId", | |||
principalTable: "CatalogTypes", | |||
principalColumn: "Id", | |||
onDelete: ReferentialAction.Cascade); | |||
migrationBuilder.RenameIndex( | |||
name: "IX_catalog_CatalogTypeId", | |||
table: "catalog", | |||
newName: "IX_Catalog_CatalogTypeId"); | |||
migrationBuilder.RenameIndex( | |||
name: "IX_catalog_CatalogBrandId", | |||
table: "catalog", | |||
newName: "IX_Catalog_CatalogBrandId"); | |||
migrationBuilder.RenameTable( | |||
name: "CatalogTypes", | |||
newName: "CatalogType"); | |||
migrationBuilder.RenameTable( | |||
name: "catalog", | |||
newName: "Catalog"); | |||
migrationBuilder.RenameTable( | |||
name: "catalogbrand", | |||
newName: "CatalogBrand"); | |||
} | |||
protected override void Down(MigrationBuilder migrationBuilder) | |||
{ | |||
migrationBuilder.DropForeignKey( | |||
name: "FK_Catalog_CatalogBrand_CatalogBrandId", | |||
table: "Catalog"); | |||
migrationBuilder.DropForeignKey( | |||
name: "FK_Catalog_CatalogType_CatalogTypeId", | |||
table: "Catalog"); | |||
migrationBuilder.DropPrimaryKey( | |||
name: "PK_CatalogType", | |||
table: "CatalogType"); | |||
migrationBuilder.DropPrimaryKey( | |||
name: "PK_Catalog", | |||
table: "Catalog"); | |||
migrationBuilder.DropPrimaryKey( | |||
name: "PK_CatalogBrand", | |||
table: "CatalogBrand"); | |||
migrationBuilder.AddPrimaryKey( | |||
name: "PK_CatalogTypes", | |||
table: "CatalogType", | |||
column: "Id"); | |||
migrationBuilder.AddPrimaryKey( | |||
name: "PK_catalog", | |||
table: "Catalog", | |||
column: "Id"); | |||
migrationBuilder.AddPrimaryKey( | |||
name: "PK_catalogbrand", | |||
table: "CatalogBrand", | |||
column: "Id"); | |||
migrationBuilder.AddForeignKey( | |||
name: "FK_catalog_catalogbrand_CatalogBrandId", | |||
table: "Catalog", | |||
column: "CatalogBrandId", | |||
principalTable: "CatalogBrand", | |||
principalColumn: "Id", | |||
onDelete: ReferentialAction.Cascade); | |||
migrationBuilder.AddForeignKey( | |||
name: "FK_catalog_CatalogTypes_CatalogTypeId", | |||
table: "Catalog", | |||
column: "CatalogTypeId", | |||
principalTable: "CatalogType", | |||
principalColumn: "Id", | |||
onDelete: ReferentialAction.Cascade); | |||
migrationBuilder.RenameIndex( | |||
name: "IX_Catalog_CatalogTypeId", | |||
table: "Catalog", | |||
newName: "IX_catalog_CatalogTypeId"); | |||
migrationBuilder.RenameIndex( | |||
name: "IX_Catalog_CatalogBrandId", | |||
table: "Catalog", | |||
newName: "IX_catalog_CatalogBrandId"); | |||
migrationBuilder.RenameTable( | |||
name: "CatalogType", | |||
newName: "CatalogTypes"); | |||
migrationBuilder.RenameTable( | |||
name: "Catalog", | |||
newName: "catalog"); | |||
migrationBuilder.RenameTable( | |||
name: "CatalogBrand", | |||
newName: "catalogbrand"); | |||
} | |||
} | |||
} |
@ -0,0 +1,98 @@ | |||
using System; | |||
using Microsoft.EntityFrameworkCore; | |||
using Microsoft.EntityFrameworkCore.Infrastructure; | |||
using Microsoft.EntityFrameworkCore.Metadata; | |||
using Microsoft.EntityFrameworkCore.Migrations; | |||
using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure; | |||
namespace Catalog.API.Infrastructure.Migrations | |||
{ | |||
[DbContext(typeof(CatalogContext))] | |||
partial class CatalogContextModelSnapshot : ModelSnapshot | |||
{ | |||
protected override void BuildModel(ModelBuilder modelBuilder) | |||
{ | |||
modelBuilder | |||
.HasAnnotation("ProductVersion", "1.0.1") | |||
.HasAnnotation("SqlServer:Sequence:.catalog_brand_hilo", "'catalog_brand_hilo', '', '1', '10', '', '', 'Int64', 'False'") | |||
.HasAnnotation("SqlServer:Sequence:.catalog_hilo", "'catalog_hilo', '', '1', '10', '', '', 'Int64', 'False'") | |||
.HasAnnotation("SqlServer:Sequence:.catalog_type_hilo", "'catalog_type_hilo', '', '1', '10', '', '', 'Int64', 'False'") | |||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); | |||
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.CatalogBrand", b => | |||
{ | |||
b.Property<int>("Id") | |||
.ValueGeneratedOnAdd() | |||
.HasAnnotation("SqlServer:HiLoSequenceName", "catalog_brand_hilo") | |||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo); | |||
b.Property<string>("Brand") | |||
.IsRequired() | |||
.HasAnnotation("MaxLength", 100); | |||
b.HasKey("Id"); | |||
b.ToTable("CatalogBrand"); | |||
}); | |||
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.CatalogItem", b => | |||
{ | |||
b.Property<int>("Id") | |||
.ValueGeneratedOnAdd() | |||
.HasAnnotation("SqlServer:HiLoSequenceName", "catalog_hilo") | |||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo); | |||
b.Property<int>("CatalogBrandId"); | |||
b.Property<int>("CatalogTypeId"); | |||
b.Property<string>("Description"); | |||
b.Property<string>("Name") | |||
.IsRequired() | |||
.HasAnnotation("MaxLength", 50); | |||
b.Property<string>("PictureUri"); | |||
b.Property<decimal>("Price"); | |||
b.HasKey("Id"); | |||
b.HasIndex("CatalogBrandId"); | |||
b.HasIndex("CatalogTypeId"); | |||
b.ToTable("Catalog"); | |||
}); | |||
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.CatalogType", b => | |||
{ | |||
b.Property<int>("Id") | |||
.ValueGeneratedOnAdd() | |||
.HasAnnotation("SqlServer:HiLoSequenceName", "catalog_type_hilo") | |||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo); | |||
b.Property<string>("Type") | |||
.IsRequired() | |||
.HasAnnotation("MaxLength", 100); | |||
b.HasKey("Id"); | |||
b.ToTable("CatalogType"); | |||
}); | |||
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.CatalogItem", b => | |||
{ | |||
b.HasOne("Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.CatalogBrand", "CatalogBrand") | |||
.WithMany() | |||
.HasForeignKey("CatalogBrandId") | |||
.OnDelete(DeleteBehavior.Cascade); | |||
b.HasOne("Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.CatalogType", "CatalogType") | |||
.WithMany() | |||
.HasForeignKey("CatalogTypeId") | |||
.OnDelete(DeleteBehavior.Cascade); | |||
}); | |||
} | |||
} | |||
} |