using System; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; namespace Marechai.Database.Migrations { public partial class AddAuditTable : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable("Audit", table => new { Id = table.Column(nullable: false). Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), CreatedOn = table.Column(nullable: false). Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), UpdatedOn = table.Column(nullable: false). Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.ComputedColumn), Type = table.Column(nullable: false), UserId = table.Column(nullable: false), Table = table.Column(nullable: true), Keys = table.Column(nullable: true), OldValues = table.Column(nullable: true), NewValues = table.Column(nullable: true), AffectedColumns = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Audit", x => x.Id); table.ForeignKey("FK_Audit_AspNetUsers_UserId", x => x.UserId, "AspNetUsers", "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex("IX_Audit_Table", "Audit", "Table"); migrationBuilder.CreateIndex("IX_Audit_Type", "Audit", "Type"); migrationBuilder.CreateIndex("IX_Audit_UserId", "Audit", "UserId"); } protected override void Down(MigrationBuilder migrationBuilder) => migrationBuilder.DropTable("Audit"); } }