diff --git a/MagMan.Data.Tenant/Migrations/20240122174314_InitDb.Designer.cs b/MagMan.Data.Tenant/Migrations/20240122174314_InitDb.Designer.cs deleted file mode 100644 index 5a5a6dc..0000000 --- a/MagMan.Data.Tenant/Migrations/20240122174314_InitDb.Designer.cs +++ /dev/null @@ -1,297 +0,0 @@ -// -using System; -using MagMan.Data.Tenant; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace MagMan.Data.Tenant.Migrations -{ - [DbContext(typeof(MagManContext))] - [Migration("20240122174314_InitDb")] - partial class InitDb - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.25") - .HasAnnotation("Relational:MaxIdentifierLength", 64); - - modelBuilder.Entity("MagMan.Data.Tenant.DbModels.AliasModel", b => - { - b.Property("Family") - .HasColumnType("varchar(255)"); - - b.Property("ValueOriginal") - .HasColumnType("varchar(255)"); - - b.Property("ValueAlias") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Family", "ValueOriginal"); - - b.ToTable("AliasList"); - }); - - modelBuilder.Entity("MagMan.Data.Tenant.DbModels.ConfigModel", b => - { - b.Property("KeyName") - .HasMaxLength(50) - .HasColumnType("varchar(50)") - .HasColumnOrder(0); - - b.Property("Note") - .IsRequired() - .HasMaxLength(250) - .HasColumnType("varchar(250)") - .HasColumnOrder(3); - - b.Property("Val") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("varchar(50)") - .HasColumnOrder(1); - - b.Property("ValStd") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("varchar(50)") - .HasColumnOrder(2) - .HasComment("Valore di default/riferimento per la variabile"); - - b.HasKey("KeyName"); - - b.ToTable("Config"); - }); - - modelBuilder.Entity("MagMan.Data.Tenant.DbModels.MaterialModel", b => - { - b.Property("MatId") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("HMm") - .HasColumnType("decimal(65,30)"); - - b.Property("LMm") - .HasColumnType("decimal(65,30)"); - - b.Property("MatCode") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("MatDesc") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("WMm") - .HasColumnType("decimal(65,30)"); - - b.HasKey("MatId"); - - b.ToTable("MaterialsList"); - }); - - modelBuilder.Entity("MagMan.Data.Tenant.DbModels.ProjModel", b => - { - b.Property("ProjExtDbId") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("BTLFileName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("DtCreated") - .HasColumnType("datetime(6)"); - - b.Property("DtLastAction") - .HasColumnType("datetime(6)"); - - b.Property("DtSchedule") - .HasColumnType("datetime(6)"); - - b.Property("DtStartProd") - .HasColumnType("datetime(6)"); - - b.Property("IsActive") - .HasColumnType("tinyint(1)"); - - b.Property("IsArchived") - .HasColumnType("tinyint(1)"); - - b.Property("KeyNum") - .HasColumnType("int"); - - b.Property("ListName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Machine") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("MachineID") - .HasColumnType("int"); - - b.Property("PType") - .HasColumnType("int"); - - b.Property("ProcTimeEst") - .HasColumnType("double"); - - b.Property("ProcTimeReal") - .HasColumnType("double"); - - b.Property("ProjDescription") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ProjExtDbId") - .HasColumnType("int"); - - b.Property("ProjExtId") - .HasColumnType("int"); - - b.HasKey("ProjExtDbId"); - - b.HasIndex("IsActive"); - - b.HasIndex("IsArchived"); - - b.HasIndex("KeyNum"); - - b.HasIndex("MachineID"); - - b.HasIndex("ProjExtDbId"); - - b.ToTable("ProjList"); - }); - - modelBuilder.Entity("MagMan.Data.Tenant.DbModels.RawItemModel", b => - { - b.Property("RawItemId") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("HMm") - .HasColumnType("decimal(65,30)"); - - b.Property("IsActive") - .HasColumnType("tinyint(1)"); - - b.Property("IsRemn") - .HasColumnType("tinyint(1)"); - - b.Property("LMm") - .HasColumnType("decimal(65,30)"); - - b.Property("Location") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("MatId") - .HasColumnType("int"); - - b.Property("Note") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("QtyAvail") - .HasColumnType("int"); - - b.Property("WMm") - .HasColumnType("decimal(65,30)"); - - b.HasKey("RawItemId"); - - b.HasIndex("MatId"); - - b.ToTable("RawItemList"); - }); - - modelBuilder.Entity("MagMan.Data.Tenant.DbModels.RequestPlanModel", b => - { - b.Property("RequestId") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("DtRequest") - .HasColumnType("datetime(6)"); - - b.Property("IsActive") - .HasColumnType("tinyint(1)"); - - b.Property("ProjExtDbId") - .HasColumnType("int"); - - b.Property("ReqState") - .HasColumnType("int"); - - b.HasKey("RequestId"); - - b.ToTable("RequestPlan"); - }); - - modelBuilder.Entity("MagMan.Data.Tenant.DbModels.ResourceModel", b => - { - b.Property("ResourceId") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Qty") - .HasColumnType("int"); - - b.Property("RawItemId") - .HasColumnType("int"); - - b.Property("RequestId") - .HasColumnType("int"); - - b.HasKey("ResourceId"); - - b.HasIndex("RequestId"); - - b.ToTable("ResourceList"); - }); - - modelBuilder.Entity("MagMan.Data.Tenant.DbModels.RawItemModel", b => - { - b.HasOne("MagMan.Data.Tenant.DbModels.MaterialModel", "MaterialNav") - .WithMany("RawItemList") - .HasForeignKey("MatId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("MaterialNav"); - }); - - modelBuilder.Entity("MagMan.Data.Tenant.DbModels.ResourceModel", b => - { - b.HasOne("MagMan.Data.Tenant.DbModels.RequestPlanModel", "RequestNav") - .WithMany("ResourcesList") - .HasForeignKey("RequestId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("RequestNav"); - }); - - modelBuilder.Entity("MagMan.Data.Tenant.DbModels.MaterialModel", b => - { - b.Navigation("RawItemList"); - }); - - modelBuilder.Entity("MagMan.Data.Tenant.DbModels.RequestPlanModel", b => - { - b.Navigation("ResourcesList"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/MagMan.Data.Tenant/Migrations/20240125174127_AddMovMag.cs b/MagMan.Data.Tenant/Migrations/20240125174127_AddMovMag.cs deleted file mode 100644 index e146473..0000000 --- a/MagMan.Data.Tenant/Migrations/20240125174127_AddMovMag.cs +++ /dev/null @@ -1,130 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace MagMan.Data.Tenant.Migrations -{ - public partial class AddMovMag : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropPrimaryKey( - name: "PK_ProjList", - table: "ProjList"); - - migrationBuilder.RenameColumn( - name: "ProjExtDbId", - table: "RequestPlan", - newName: "ProjDbId"); - - migrationBuilder.AlterColumn( - name: "ProjExtDbId", - table: "ProjList", - type: "int", - nullable: false, - oldClrType: typeof(int), - oldType: "int") - .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); - - migrationBuilder.AddColumn( - name: "ProjDbId", - table: "ProjList", - type: "int", - nullable: false, - defaultValue: 0) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); - - migrationBuilder.AddPrimaryKey( - name: "PK_ProjList", - table: "ProjList", - column: "ProjDbId"); - - migrationBuilder.CreateTable( - name: "MovMag", - columns: table => new - { - MovID = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - DtRec = table.Column(type: "datetime(6)", nullable: false), - RawItemId = table.Column(type: "int", nullable: false), - QtyRec = table.Column(type: "int", nullable: false), - UserId = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Note = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_MovMag", x => x.MovID); - table.ForeignKey( - name: "FK_MovMag_RawItemList_RawItemId", - column: x => x.RawItemId, - principalTable: "RawItemList", - principalColumn: "RawItemId", - onDelete: ReferentialAction.Restrict); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateIndex( - name: "IX_ResourceList_RawItemId", - table: "ResourceList", - column: "RawItemId"); - - migrationBuilder.CreateIndex( - name: "IX_MovMag_RawItemId", - table: "MovMag", - column: "RawItemId"); - - migrationBuilder.AddForeignKey( - name: "FK_ResourceList_RawItemList_RawItemId", - table: "ResourceList", - column: "RawItemId", - principalTable: "RawItemList", - principalColumn: "RawItemId", - onDelete: ReferentialAction.Restrict); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_ResourceList_RawItemList_RawItemId", - table: "ResourceList"); - - migrationBuilder.DropTable( - name: "MovMag"); - - migrationBuilder.DropIndex( - name: "IX_ResourceList_RawItemId", - table: "ResourceList"); - - migrationBuilder.DropPrimaryKey( - name: "PK_ProjList", - table: "ProjList"); - - migrationBuilder.DropColumn( - name: "ProjDbId", - table: "ProjList"); - - migrationBuilder.RenameColumn( - name: "ProjDbId", - table: "RequestPlan", - newName: "ProjExtDbId"); - - migrationBuilder.AlterColumn( - name: "ProjExtDbId", - table: "ProjList", - type: "int", - nullable: false, - oldClrType: typeof(int), - oldType: "int") - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); - - migrationBuilder.AddPrimaryKey( - name: "PK_ProjList", - table: "ProjList", - column: "ProjExtDbId"); - } - } -} diff --git a/MagMan.Data.Tenant/Migrations/20240125174127_AddMovMag.Designer.cs b/MagMan.Data.Tenant/Migrations/20240125174457_InitDb.Designer.cs similarity index 99% rename from MagMan.Data.Tenant/Migrations/20240125174127_AddMovMag.Designer.cs rename to MagMan.Data.Tenant/Migrations/20240125174457_InitDb.Designer.cs index 6087aa3..13dbc34 100644 --- a/MagMan.Data.Tenant/Migrations/20240125174127_AddMovMag.Designer.cs +++ b/MagMan.Data.Tenant/Migrations/20240125174457_InitDb.Designer.cs @@ -11,8 +11,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace MagMan.Data.Tenant.Migrations { [DbContext(typeof(MagManContext))] - [Migration("20240125174127_AddMovMag")] - partial class AddMovMag + [Migration("20240125174457_InitDb")] + partial class InitDb { protected override void BuildTargetModel(ModelBuilder modelBuilder) { diff --git a/MagMan.Data.Tenant/Migrations/20240122174314_InitDb.cs b/MagMan.Data.Tenant/Migrations/20240125174457_InitDb.cs similarity index 84% rename from MagMan.Data.Tenant/Migrations/20240122174314_InitDb.cs rename to MagMan.Data.Tenant/Migrations/20240125174457_InitDb.cs index 57b8471..f5d00c4 100644 --- a/MagMan.Data.Tenant/Migrations/20240122174314_InitDb.cs +++ b/MagMan.Data.Tenant/Migrations/20240125174457_InitDb.cs @@ -150,6 +150,32 @@ namespace MagMan.Data.Tenant.Migrations }) .Annotation("MySql:CharSet", "utf8mb4"); + migrationBuilder.CreateTable( + name: "MovMag", + columns: table => new + { + MovID = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + DtRec = table.Column(type: "datetime(6)", nullable: false), + RawItemId = table.Column(type: "int", nullable: false), + QtyRec = table.Column(type: "int", nullable: false), + UserId = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Note = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_MovMag", x => x.MovID); + table.ForeignKey( + name: "FK_MovMag_RawItemList_RawItemId", + column: x => x.RawItemId, + principalTable: "RawItemList", + principalColumn: "RawItemId", + onDelete: ReferentialAction.Restrict); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + migrationBuilder.CreateTable( name: "ResourceList", columns: table => new @@ -163,6 +189,12 @@ namespace MagMan.Data.Tenant.Migrations constraints: table => { table.PrimaryKey("PK_ResourceList", x => x.ResourceId); + table.ForeignKey( + name: "FK_ResourceList_RawItemList_RawItemId", + column: x => x.RawItemId, + principalTable: "RawItemList", + principalColumn: "RawItemId", + onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_ResourceList_RequestPlan_RequestId", column: x => x.RequestId, @@ -172,6 +204,11 @@ namespace MagMan.Data.Tenant.Migrations }) .Annotation("MySql:CharSet", "utf8mb4"); + migrationBuilder.CreateIndex( + name: "IX_MovMag_RawItemId", + table: "MovMag", + column: "RawItemId"); + migrationBuilder.CreateIndex( name: "IX_ProjList_IsActive", table: "ProjList", @@ -202,6 +239,11 @@ namespace MagMan.Data.Tenant.Migrations table: "RawItemList", column: "MatId"); + migrationBuilder.CreateIndex( + name: "IX_ResourceList_RawItemId", + table: "ResourceList", + column: "RawItemId"); + migrationBuilder.CreateIndex( name: "IX_ResourceList_RequestId", table: "ResourceList", @@ -217,19 +259,22 @@ namespace MagMan.Data.Tenant.Migrations name: "Config"); migrationBuilder.DropTable( - name: "ProjList"); + name: "MovMag"); migrationBuilder.DropTable( - name: "RawItemList"); + name: "ProjList"); migrationBuilder.DropTable( name: "ResourceList"); migrationBuilder.DropTable( - name: "MaterialsList"); + name: "RawItemList"); migrationBuilder.DropTable( name: "RequestPlan"); + + migrationBuilder.DropTable( + name: "MaterialsList"); } } }