using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace StandManager.Infrastructure.Migrations { /// public partial class AggiuntaPermessi : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AddColumn( name: "RuoloId", table: "Utente", type: "uniqueidentifier", nullable: true); migrationBuilder.CreateTable( name: "Ruolo", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), Nome = table.Column(type: "nvarchar(max)", nullable: false), DataCreazione = table.Column(type: "datetime2", nullable: false), DataModifica = table.Column(type: "datetime2", nullable: true), Eliminato = table.Column(type: "bit", nullable: false), IdUtenteCreazione = table.Column(type: "uniqueidentifier", nullable: true), IdUtenteModifica = table.Column(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(type: "uniqueidentifier", nullable: false), Nome = table.Column(type: "nvarchar(max)", nullable: false), Ordinamento = table.Column(type: "int", nullable: false), DataCreazione = table.Column(type: "datetime2", nullable: false), DataModifica = table.Column(type: "datetime2", nullable: true), Eliminato = table.Column(type: "bit", nullable: false), IdUtenteCreazione = table.Column(type: "uniqueidentifier", nullable: true), IdUtenteModifica = table.Column(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(type: "uniqueidentifier", nullable: false), Nome = table.Column(type: "nvarchar(max)", nullable: false), Descrizione = table.Column(type: "nvarchar(max)", nullable: false), Ordinamento = table.Column(type: "int", nullable: false), SezioneId = table.Column(type: "uniqueidentifier", nullable: false), Type = table.Column(type: "int", nullable: false), DataCreazione = table.Column(type: "datetime2", nullable: false), DataModifica = table.Column(type: "datetime2", nullable: true), Eliminato = table.Column(type: "bit", nullable: false), IdUtenteCreazione = table.Column(type: "uniqueidentifier", nullable: true), IdUtenteModifica = table.Column(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(type: "uniqueidentifier", nullable: false), RuoloId = table.Column(type: "uniqueidentifier", nullable: true), IdFeature = table.Column(type: "uniqueidentifier", nullable: false), DataCreazione = table.Column(type: "datetime2", nullable: false), DataModifica = table.Column(type: "datetime2", nullable: true), Eliminato = table.Column(type: "bit", nullable: false), IdUtenteCreazione = table.Column(type: "uniqueidentifier", nullable: true), IdUtenteModifica = table.Column(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"); } /// 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"); } } }