diff --git a/common/ASC.Core.Common/EF/Model/Tenant/DbTariffRow.cs b/common/ASC.Core.Common/EF/Model/Tenant/DbTariffRow.cs index 335198c495..9fa9fbd783 100644 --- a/common/ASC.Core.Common/EF/Model/Tenant/DbTariffRow.cs +++ b/common/ASC.Core.Common/EF/Model/Tenant/DbTariffRow.cs @@ -26,13 +26,17 @@ namespace ASC.Core.Common.EF; -public class DbTariffRow -{ - public int Id { get; set; } +public class DbTariffRow : BaseEntity +{ public int TariffId { get; set; } public int Quota { get; set; } public int Quantity { get; set; } - public int Tenant { get; set; } + public int Tenant { get; set; } + + public override object[] GetKeys() + { + return new object[] { Tenant, TariffId, Quota }; + } } public static class DbTariffRowExtension { @@ -49,11 +53,8 @@ public static class DbTariffRowExtension { entity.ToTable("tenants_tariffrow"); - entity.HasKey(e => e.Id) - .HasName("PRIMARY"); - - entity.Property(e => e.Id) - .HasColumnName("id"); + entity.HasKey(e => new { e.Tenant, e.TariffId, e.Quota }) + .HasName("PRIMARY"); entity.Property(e => e.TariffId) .HasColumnName("tariff_id") diff --git a/migrations/mysql/CoreDbContext/20220830141345_CoreDbContext_Upgrade1.Designer.cs b/migrations/mysql/CoreDbContext/20220830141345_CoreDbContext_Upgrade1.Designer.cs index a2c23caf49..c0b0a4a884 100644 --- a/migrations/mysql/CoreDbContext/20220830141345_CoreDbContext_Upgrade1.Designer.cs +++ b/migrations/mysql/CoreDbContext/20220830141345_CoreDbContext_Upgrade1.Designer.cs @@ -1,5 +1,7 @@ // using System; + +using ASC.Core.Billing; using ASC.Core.Common.EF; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; @@ -188,11 +190,6 @@ namespace ASC.Migrations.MySql.Migrations.CoreDb modelBuilder.Entity("ASC.Core.Common.EF.DbTariffRow", b => { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasColumnName("id"); - b.Property("Quantity") .HasColumnType("int") .HasColumnName("quantity"); @@ -209,7 +206,7 @@ namespace ASC.Migrations.MySql.Migrations.CoreDb .HasColumnType("int") .HasColumnName("tenant"); - b.HasKey("Id") + b.HasKey("Tenant", "TariffId", "Quota") .HasName("PRIMARY"); b.ToTable("tenants_tariffrow", (string)null); diff --git a/migrations/mysql/CoreDbContext/20220830141345_CoreDbContext_Upgrade1.cs b/migrations/mysql/CoreDbContext/20220830141345_CoreDbContext_Upgrade1.cs index 3fa1be10bd..00a661dcbb 100644 --- a/migrations/mysql/CoreDbContext/20220830141345_CoreDbContext_Upgrade1.cs +++ b/migrations/mysql/CoreDbContext/20220830141345_CoreDbContext_Upgrade1.cs @@ -24,7 +24,6 @@ // content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 // International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode -using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable @@ -74,8 +73,6 @@ namespace ASC.Migrations.MySql.Migrations.CoreDb name: "tenants_tariffrow", columns: table => new { - id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), tariff_id = table.Column(type: "int", nullable: false), quota = table.Column(type: "int", nullable: false), quantity = table.Column(type: "int", nullable: false), @@ -83,7 +80,7 @@ namespace ASC.Migrations.MySql.Migrations.CoreDb }, constraints: table => { - table.PrimaryKey("PRIMARY", x => x.id); + table.PrimaryKey("PRIMARY", x => new { x.tenant, x.tariff_id, x.quota }); }) .Annotation("MySql:CharSet", "utf8mb4"); diff --git a/migrations/mysql/CoreDbContext/CoreDbContextModelSnapshot.cs b/migrations/mysql/CoreDbContext/CoreDbContextModelSnapshot.cs index fdb74db9fa..4f76542682 100644 --- a/migrations/mysql/CoreDbContext/CoreDbContextModelSnapshot.cs +++ b/migrations/mysql/CoreDbContext/CoreDbContextModelSnapshot.cs @@ -177,11 +177,6 @@ namespace ASC.Migrations.MySql.Migrations modelBuilder.Entity("ASC.Core.Common.EF.DbTariffRow", b => { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasColumnName("id"); - b.Property("Quantity") .HasColumnType("int") .HasColumnName("quantity"); @@ -198,8 +193,8 @@ namespace ASC.Migrations.MySql.Migrations .HasColumnType("int") .HasColumnName("tenant"); - b.HasKey("Id") - .HasName("PRIMARY"); + b.HasKey("Tenant", "TariffId", "Quota") + .HasName("PRIMARY"); b.ToTable("tenants_tariffrow", (string)null); }); diff --git a/migrations/postgre/CoreDbContext/20220830141345_CoreDbContext_Upgrade1.Designer.cs b/migrations/postgre/CoreDbContext/20220830141345_CoreDbContext_Upgrade1.Designer.cs index dc3a98ec24..b9d124be30 100644 --- a/migrations/postgre/CoreDbContext/20220830141345_CoreDbContext_Upgrade1.Designer.cs +++ b/migrations/postgre/CoreDbContext/20220830141345_CoreDbContext_Upgrade1.Designer.cs @@ -185,11 +185,6 @@ namespace ASC.Migrations.PostgreSql.Migrations.CoreDb modelBuilder.Entity("ASC.Core.Common.EF.DbTariffRow", b => { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - b.Property("Quantity") .HasColumnType("integer"); @@ -202,7 +197,7 @@ namespace ASC.Migrations.PostgreSql.Migrations.CoreDb b.Property("Tenant") .HasColumnType("integer"); - b.HasKey("Id"); + b.HasKey("Tenant", "TariffId", "Quota"); b.ToTable("TariffRows"); }); diff --git a/migrations/postgre/CoreDbContext/20220830141345_CoreDbContext_Upgrade1.cs b/migrations/postgre/CoreDbContext/20220830141345_CoreDbContext_Upgrade1.cs index 1755b90b6f..52b43b3d53 100644 --- a/migrations/postgre/CoreDbContext/20220830141345_CoreDbContext_Upgrade1.cs +++ b/migrations/postgre/CoreDbContext/20220830141345_CoreDbContext_Upgrade1.cs @@ -26,8 +26,6 @@ using Microsoft.EntityFrameworkCore.Migrations; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - #nullable disable namespace ASC.Migrations.PostgreSql.Migrations.CoreDb @@ -80,8 +78,6 @@ namespace ASC.Migrations.PostgreSql.Migrations.CoreDb name: "TariffRows", columns: table => new { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), TariffId = table.Column(type: "integer", nullable: false), Quota = table.Column(type: "integer", nullable: false), Quantity = table.Column(type: "integer", nullable: false), @@ -89,7 +85,7 @@ namespace ASC.Migrations.PostgreSql.Migrations.CoreDb }, constraints: table => { - table.PrimaryKey("PK_TariffRows", x => x.Id); + table.PrimaryKey("PK_TariffRows", x => new { x.Tenant, x.TariffId, x.Quota }); }); migrationBuilder.UpdateData( diff --git a/migrations/postgre/CoreDbContext/CoreDbContextModelSnapshot.cs b/migrations/postgre/CoreDbContext/CoreDbContextModelSnapshot.cs index bd5cd69253..0bea710a95 100644 --- a/migrations/postgre/CoreDbContext/CoreDbContextModelSnapshot.cs +++ b/migrations/postgre/CoreDbContext/CoreDbContextModelSnapshot.cs @@ -174,11 +174,6 @@ namespace ASC.Migrations.PostgreSql.Migrations modelBuilder.Entity("ASC.Core.Common.EF.DbTariffRow", b => { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - b.Property("Quantity") .HasColumnType("integer"); @@ -191,7 +186,7 @@ namespace ASC.Migrations.PostgreSql.Migrations b.Property("Tenant") .HasColumnType("integer"); - b.HasKey("Id"); + b.HasKey("Tenant", "TariffId", "Quota"); b.ToTable("TariffRows"); });