Files
StandManager/StandManager.Infrastructure/Migrations/20251217075552_AggiuntaPermessi.cs
2025-12-17 08:56:38 +01:00

248 lines
11 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace StandManager.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AggiuntaPermessi : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<Guid>(
name: "RuoloId",
table: "Utente",
type: "uniqueidentifier",
nullable: true);
migrationBuilder.CreateTable(
name: "Ruolo",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Nome = table.Column<string>(type: "nvarchar(max)", nullable: false),
DataCreazione = table.Column<DateTime>(type: "datetime2", nullable: false),
DataModifica = table.Column<DateTime>(type: "datetime2", nullable: true),
Eliminato = table.Column<bool>(type: "bit", nullable: false),
IdUtenteCreazione = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
IdUtenteModifica = table.Column<Guid>(type: "uniqueidentifier", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Ruolo", x => x.Id);
table.ForeignKey(
name: "FK_Ruolo_Utente_IdUtenteCreazione",
column: x => x.IdUtenteCreazione,
principalTable: "Utente",
principalColumn: "Id");
table.ForeignKey(
name: "FK_Ruolo_Utente_IdUtenteModifica",
column: x => x.IdUtenteModifica,
principalTable: "Utente",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "Sezione",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Nome = table.Column<string>(type: "nvarchar(max)", nullable: false),
Ordinamento = table.Column<int>(type: "int", nullable: false),
DataCreazione = table.Column<DateTime>(type: "datetime2", nullable: false),
DataModifica = table.Column<DateTime>(type: "datetime2", nullable: true),
Eliminato = table.Column<bool>(type: "bit", nullable: false),
IdUtenteCreazione = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
IdUtenteModifica = table.Column<Guid>(type: "uniqueidentifier", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Sezione", x => x.Id);
table.ForeignKey(
name: "FK_Sezione_Utente_IdUtenteCreazione",
column: x => x.IdUtenteCreazione,
principalTable: "Utente",
principalColumn: "Id");
table.ForeignKey(
name: "FK_Sezione_Utente_IdUtenteModifica",
column: x => x.IdUtenteModifica,
principalTable: "Utente",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "Feature",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Nome = table.Column<string>(type: "nvarchar(max)", nullable: false),
Descrizione = table.Column<string>(type: "nvarchar(max)", nullable: false),
Ordinamento = table.Column<int>(type: "int", nullable: false),
SezioneId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Type = table.Column<int>(type: "int", nullable: false),
DataCreazione = table.Column<DateTime>(type: "datetime2", nullable: false),
DataModifica = table.Column<DateTime>(type: "datetime2", nullable: true),
Eliminato = table.Column<bool>(type: "bit", nullable: false),
IdUtenteCreazione = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
IdUtenteModifica = table.Column<Guid>(type: "uniqueidentifier", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Feature", x => x.Id);
table.ForeignKey(
name: "FK_Feature_Sezione_SezioneId",
column: x => x.SezioneId,
principalTable: "Sezione",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Feature_Utente_IdUtenteCreazione",
column: x => x.IdUtenteCreazione,
principalTable: "Utente",
principalColumn: "Id");
table.ForeignKey(
name: "FK_Feature_Utente_IdUtenteModifica",
column: x => x.IdUtenteModifica,
principalTable: "Utente",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "Permission",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
RuoloId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
IdFeature = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
DataCreazione = table.Column<DateTime>(type: "datetime2", nullable: false),
DataModifica = table.Column<DateTime>(type: "datetime2", nullable: true),
Eliminato = table.Column<bool>(type: "bit", nullable: false),
IdUtenteCreazione = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
IdUtenteModifica = table.Column<Guid>(type: "uniqueidentifier", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Permission", x => x.Id);
table.ForeignKey(
name: "FK_Permission_Feature_IdFeature",
column: x => x.IdFeature,
principalTable: "Feature",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Permission_Ruolo_RuoloId",
column: x => x.RuoloId,
principalTable: "Ruolo",
principalColumn: "Id");
table.ForeignKey(
name: "FK_Permission_Utente_IdUtenteCreazione",
column: x => x.IdUtenteCreazione,
principalTable: "Utente",
principalColumn: "Id");
table.ForeignKey(
name: "FK_Permission_Utente_IdUtenteModifica",
column: x => x.IdUtenteModifica,
principalTable: "Utente",
principalColumn: "Id");
});
migrationBuilder.CreateIndex(
name: "IX_Utente_RuoloId",
table: "Utente",
column: "RuoloId");
migrationBuilder.CreateIndex(
name: "IX_Feature_IdUtenteCreazione",
table: "Feature",
column: "IdUtenteCreazione");
migrationBuilder.CreateIndex(
name: "IX_Feature_IdUtenteModifica",
table: "Feature",
column: "IdUtenteModifica");
migrationBuilder.CreateIndex(
name: "IX_Feature_SezioneId",
table: "Feature",
column: "SezioneId");
migrationBuilder.CreateIndex(
name: "IX_Permission_IdFeature",
table: "Permission",
column: "IdFeature");
migrationBuilder.CreateIndex(
name: "IX_Permission_IdUtenteCreazione",
table: "Permission",
column: "IdUtenteCreazione");
migrationBuilder.CreateIndex(
name: "IX_Permission_IdUtenteModifica",
table: "Permission",
column: "IdUtenteModifica");
migrationBuilder.CreateIndex(
name: "IX_Permission_RuoloId",
table: "Permission",
column: "RuoloId");
migrationBuilder.CreateIndex(
name: "IX_Ruolo_IdUtenteCreazione",
table: "Ruolo",
column: "IdUtenteCreazione");
migrationBuilder.CreateIndex(
name: "IX_Ruolo_IdUtenteModifica",
table: "Ruolo",
column: "IdUtenteModifica");
migrationBuilder.CreateIndex(
name: "IX_Sezione_IdUtenteCreazione",
table: "Sezione",
column: "IdUtenteCreazione");
migrationBuilder.CreateIndex(
name: "IX_Sezione_IdUtenteModifica",
table: "Sezione",
column: "IdUtenteModifica");
migrationBuilder.AddForeignKey(
name: "FK_Utente_Ruolo_RuoloId",
table: "Utente",
column: "RuoloId",
principalTable: "Ruolo",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Utente_Ruolo_RuoloId",
table: "Utente");
migrationBuilder.DropTable(
name: "Permission");
migrationBuilder.DropTable(
name: "Feature");
migrationBuilder.DropTable(
name: "Ruolo");
migrationBuilder.DropTable(
name: "Sezione");
migrationBuilder.DropIndex(
name: "IX_Utente_RuoloId",
table: "Utente");
migrationBuilder.DropColumn(
name: "RuoloId",
table: "Utente");
}
}
}