using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace VigilCareRecordsAPI.Data.Migrations { /// public partial class AddPromotionAttempts : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "promotion_attempts", columns: table => new { id = table.Column(type: "uuid", nullable: false, defaultValueSql: "gen_random_uuid()"), batch_id = table.Column(type: "uuid", nullable: false), attempt_number = table.Column(type: "integer", nullable: false), succeeded = table.Column(type: "boolean", nullable: false, defaultValue: false), error_message = table.Column(type: "character varying(2000)", maxLength: 2000, nullable: true), attempted_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "NOW()"), next_retry_at = table.Column(type: "timestamp with time zone", nullable: true) }, constraints: table => { table.PrimaryKey("PK_promotion_attempts", x => x.id); table.ForeignKey( name: "FK_promotion_attempts_digitization_batches_batch_id", column: x => x.batch_id, principalTable: "digitization_batches", principalColumn: "id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateIndex( name: "ix_promotion_attempts_batch_attempt", table: "promotion_attempts", columns: new[] { "batch_id", "attempt_number" }, unique: true); migrationBuilder.CreateIndex( name: "ix_promotion_attempts_pending_retry", table: "promotion_attempts", column: "next_retry_at", filter: "succeeded = false AND next_retry_at IS NOT NULL"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "promotion_attempts"); } } }