using Microsoft.EntityFrameworkCore.Migrations; namespace CredentialManager.Migrations { /// /// Aggiunge la tabella RecordAssociations per tracciare le associazioni tra record sorgente e destinazione /// public partial class AddRecordAssociations : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "RecordAssociations", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), SourceName = table.Column(type: "TEXT", maxLength: 200, nullable: false), SourceType = table.Column(type: "TEXT", maxLength: 50, nullable: false), SourceKey = table.Column(type: "TEXT", maxLength: 500, nullable: false), DestinationEntity = table.Column(type: "TEXT", maxLength: 200, nullable: false), DestinationId = table.Column(type: "TEXT", maxLength: 200, nullable: false), RestCredentialName = table.Column(type: "TEXT", maxLength: 100, nullable: false), CreatedAt = table.Column(type: "TEXT", nullable: false, defaultValueSql: "datetime('now')"), UpdatedAt = table.Column(type: "TEXT", nullable: true), IsActive = table.Column(type: "INTEGER", nullable: false, defaultValue: true), AdditionalInfo = table.Column(type: "TEXT", maxLength: 2000, nullable: true) }, constraints: table => { table.PrimaryKey("PK_RecordAssociations", x => x.Id); }); // Indici per migliorare le performance migrationBuilder.CreateIndex( name: "IX_RecordAssociations_Unique", table: "RecordAssociations", columns: new[] { "SourceName", "SourceKey", "DestinationEntity" }, unique: true); migrationBuilder.CreateIndex( name: "IX_RecordAssociations_SourceType", table: "RecordAssociations", column: "SourceType"); migrationBuilder.CreateIndex( name: "IX_RecordAssociations_DestinationEntity", table: "RecordAssociations", column: "DestinationEntity"); migrationBuilder.CreateIndex( name: "IX_RecordAssociations_RestCredentialName", table: "RecordAssociations", column: "RestCredentialName"); migrationBuilder.CreateIndex( name: "IX_RecordAssociations_IsActive", table: "RecordAssociations", column: "IsActive"); migrationBuilder.CreateIndex( name: "IX_RecordAssociations_CreatedAt", table: "RecordAssociations", column: "CreatedAt"); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "RecordAssociations"); } } }