-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: DB Agnostic architecture with SqlServer, MySql and PostgreSQL (#…
…120) feat: DB Agnostic architecture with SqlServer, MySql and PostgreSQL
- Loading branch information
Showing
39 changed files
with
1,418 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/VirtoCommerce.InventoryModule.Data.MySql/DbContextOptionsBuilderExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace VirtoCommerce.InventoryModule.Data.MySql | ||
{ | ||
public static class DbContextOptionsBuilderExtensions | ||
{ | ||
/// <summary> | ||
/// Configures the context to use PostgreSql. | ||
/// </summary> | ||
public static DbContextOptionsBuilder UseMySqlDatabase(this DbContextOptionsBuilder builder, string connectionString) => | ||
builder.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString), db => db | ||
.MigrationsAssembly(typeof(MySqlDbContextFactory).Assembly.GetName().Name)); | ||
} | ||
} |
209 changes: 209 additions & 0 deletions
209
src/VirtoCommerce.InventoryModule.Data.MySql/Migrations/20221221132732_Initial.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
129 changes: 129 additions & 0 deletions
129
src/VirtoCommerce.InventoryModule.Data.MySql/Migrations/20221221132732_Initial.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
using System; | ||
using Microsoft.EntityFrameworkCore.Migrations; | ||
|
||
#nullable disable | ||
|
||
namespace VirtoCommerce.InventoryModule.Data.MySql.Migrations | ||
{ | ||
public partial class Initial : Migration | ||
{ | ||
protected override void Up(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.AlterDatabase() | ||
.Annotation("MySql:CharSet", "utf8mb4"); | ||
|
||
migrationBuilder.CreateTable( | ||
name: "FulfillmentCenter", | ||
columns: table => new | ||
{ | ||
Id = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false) | ||
.Annotation("MySql:CharSet", "utf8mb4"), | ||
Name = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false) | ||
.Annotation("MySql:CharSet", "utf8mb4"), | ||
Description = table.Column<string>(type: "longtext", nullable: true) | ||
.Annotation("MySql:CharSet", "utf8mb4"), | ||
ShortDescription = table.Column<string>(type: "longtext", nullable: true) | ||
.Annotation("MySql:CharSet", "utf8mb4"), | ||
Line1 = table.Column<string>(type: "varchar(1024)", maxLength: 1024, nullable: true) | ||
.Annotation("MySql:CharSet", "utf8mb4"), | ||
Line2 = table.Column<string>(type: "varchar(1024)", maxLength: 1024, nullable: true) | ||
.Annotation("MySql:CharSet", "utf8mb4"), | ||
City = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: true) | ||
.Annotation("MySql:CharSet", "utf8mb4"), | ||
CountryCode = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: true) | ||
.Annotation("MySql:CharSet", "utf8mb4"), | ||
StateProvince = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: true) | ||
.Annotation("MySql:CharSet", "utf8mb4"), | ||
CountryName = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: true) | ||
.Annotation("MySql:CharSet", "utf8mb4"), | ||
PostalCode = table.Column<string>(type: "varchar(32)", maxLength: 32, nullable: true) | ||
.Annotation("MySql:CharSet", "utf8mb4"), | ||
RegionId = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: true) | ||
.Annotation("MySql:CharSet", "utf8mb4"), | ||
RegionName = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: true) | ||
.Annotation("MySql:CharSet", "utf8mb4"), | ||
DaytimePhoneNumber = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: true) | ||
.Annotation("MySql:CharSet", "utf8mb4"), | ||
Email = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true) | ||
.Annotation("MySql:CharSet", "utf8mb4"), | ||
OrganizationId = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: true) | ||
.Annotation("MySql:CharSet", "utf8mb4"), | ||
GeoLocation = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: true) | ||
.Annotation("MySql:CharSet", "utf8mb4"), | ||
OuterId = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: true) | ||
.Annotation("MySql:CharSet", "utf8mb4"), | ||
CreatedDate = table.Column<DateTime>(type: "datetime(6)", nullable: false), | ||
ModifiedDate = table.Column<DateTime>(type: "datetime(6)", nullable: true), | ||
CreatedBy = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: true) | ||
.Annotation("MySql:CharSet", "utf8mb4"), | ||
ModifiedBy = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: true) | ||
.Annotation("MySql:CharSet", "utf8mb4") | ||
}, | ||
constraints: table => | ||
{ | ||
table.PrimaryKey("PK_FulfillmentCenter", x => x.Id); | ||
}) | ||
.Annotation("MySql:CharSet", "utf8mb4"); | ||
|
||
migrationBuilder.CreateTable( | ||
name: "Inventory", | ||
columns: table => new | ||
{ | ||
Id = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false) | ||
.Annotation("MySql:CharSet", "utf8mb4"), | ||
InStockQuantity = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false), | ||
ReservedQuantity = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false), | ||
ReorderMinQuantity = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false), | ||
PreorderQuantity = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false), | ||
BackorderQuantity = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false), | ||
AllowBackorder = table.Column<bool>(type: "tinyint(1)", nullable: false), | ||
AllowPreorder = table.Column<bool>(type: "tinyint(1)", nullable: false), | ||
Status = table.Column<int>(type: "int", nullable: false), | ||
PreorderAvailabilityDate = table.Column<DateTime>(type: "datetime(6)", nullable: true), | ||
BackorderAvailabilityDate = table.Column<DateTime>(type: "datetime(6)", nullable: true), | ||
Sku = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false) | ||
.Annotation("MySql:CharSet", "utf8mb4"), | ||
OuterId = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: true) | ||
.Annotation("MySql:CharSet", "utf8mb4"), | ||
FulfillmentCenterId = table.Column<string>(type: "varchar(128)", nullable: false) | ||
.Annotation("MySql:CharSet", "utf8mb4"), | ||
CreatedDate = table.Column<DateTime>(type: "datetime(6)", nullable: false), | ||
ModifiedDate = table.Column<DateTime>(type: "datetime(6)", nullable: true), | ||
CreatedBy = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: true) | ||
.Annotation("MySql:CharSet", "utf8mb4"), | ||
ModifiedBy = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: true) | ||
.Annotation("MySql:CharSet", "utf8mb4") | ||
}, | ||
constraints: table => | ||
{ | ||
table.PrimaryKey("PK_Inventory", x => x.Id); | ||
table.ForeignKey( | ||
name: "FK_Inventory_FulfillmentCenter_FulfillmentCenterId", | ||
column: x => x.FulfillmentCenterId, | ||
principalTable: "FulfillmentCenter", | ||
principalColumn: "Id", | ||
onDelete: ReferentialAction.Cascade); | ||
}) | ||
.Annotation("MySql:CharSet", "utf8mb4"); | ||
|
||
migrationBuilder.CreateIndex( | ||
name: "IX_Inventory_FulfillmentCenterId", | ||
table: "Inventory", | ||
column: "FulfillmentCenterId"); | ||
|
||
migrationBuilder.CreateIndex( | ||
name: "IX_Inventory_Sku_ModifiedDate", | ||
table: "Inventory", | ||
columns: new[] { "Sku", "ModifiedDate" }); | ||
} | ||
|
||
protected override void Down(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.DropTable( | ||
name: "Inventory"); | ||
|
||
migrationBuilder.DropTable( | ||
name: "FulfillmentCenter"); | ||
} | ||
} | ||
} |
Oops, something went wrong.