Files
marechai/Marechai.Database/Migrations/20260502094559_AddMachineDescriptions.cs
Natalia Portillo 3ba25cfc4b Add Machine Descriptions functionality
- Created a new migration to add the MachineDescriptions table with necessary fields and constraints.
- Updated the MarechaiContext to include DbSet for MachineDescriptions and configured its relationships.
- Implemented the MachineDescription model to represent descriptions for machines.
- Enhanced MachinesController to manage descriptions, including endpoints for retrieving, creating, updating, and deleting descriptions.
- Added a new Razor component for managing machine descriptions in the admin panel.
- Updated the Machines view to display descriptions and integrated the service layer for fetching and managing descriptions.
- Implemented service methods for handling descriptions in MachinesService.
2026-05-02 10:58:58 +01:00

77 lines
3.4 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Marechai.Database.Migrations
{
/// <inheritdoc />
public partial class AddMachineDescriptions : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "MachineDescriptions",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
MachineId = table.Column<int>(type: "int(11)", nullable: false),
LanguageCode = table.Column<string>(type: "char(3)", maxLength: 3, nullable: false, collation: "utf8mb4_general_ci")
.Annotation("MySql:CharSet", "utf8mb4"),
Text = table.Column<string>(type: "longtext", maxLength: 262144, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Html = table.Column<string>(type: "longtext", maxLength: 262144, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
CreatedOn = table.Column<DateTime>(type: "datetime(6)", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
UpdatedOn = table.Column<DateTime>(type: "datetime(6)", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.ComputedColumn)
},
constraints: table =>
{
table.PrimaryKey("PK_MachineDescriptions", x => x.Id);
table.ForeignKey(
name: "FK_MachineDescriptions_machines_MachineId",
column: x => x.MachineId,
principalTable: "machines",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "fk_machine_descriptions_language",
column: x => x.LanguageCode,
principalTable: "ISO_639-3",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "idx_machine_descriptions_machine_language",
table: "MachineDescriptions",
columns: new[] { "MachineId", "LanguageCode" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_MachineDescriptions_LanguageCode",
table: "MachineDescriptions",
column: "LanguageCode");
migrationBuilder.CreateIndex(
name: "IX_MachineDescriptions_Text",
table: "MachineDescriptions",
column: "Text")
.Annotation("MySql:FullTextIndex", true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "MachineDescriptions");
}
}
}