using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Socialize.Api.Migrations { /// public partial class AddApprovalWorkflowRuntime : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AddColumn( name: "WorkflowInstanceId", table: "ApprovalRequests", type: "uuid", nullable: true); migrationBuilder.AddColumn( name: "WorkflowStepRequiredApproverCount", table: "ApprovalRequests", type: "integer", nullable: true); migrationBuilder.AddColumn( name: "WorkflowStepSortOrder", table: "ApprovalRequests", type: "integer", nullable: true); migrationBuilder.AddColumn( name: "WorkflowStepTargetType", table: "ApprovalRequests", type: "character varying(32)", maxLength: 32, nullable: true); migrationBuilder.AddColumn( name: "WorkflowStepTargetValue", table: "ApprovalRequests", type: "character varying(128)", maxLength: 128, nullable: true); migrationBuilder.CreateTable( name: "ApprovalWorkflowInstances", columns: table => new { Id = table.Column(type: "uuid", nullable: false), WorkspaceId = table.Column(type: "uuid", nullable: false), ContentItemId = table.Column(type: "uuid", nullable: false), State = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), ApprovalMode = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), StartedAt = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), CompletedAt = table.Column(type: "timestamp with time zone", nullable: true) }, constraints: table => { table.PrimaryKey("PK_ApprovalWorkflowInstances", x => x.Id); }); migrationBuilder.CreateIndex( name: "IX_ApprovalRequests_WorkflowInstanceId", table: "ApprovalRequests", column: "WorkflowInstanceId"); migrationBuilder.CreateIndex( name: "IX_ApprovalWorkflowInstances_ContentItemId", table: "ApprovalWorkflowInstances", column: "ContentItemId"); migrationBuilder.CreateIndex( name: "IX_ApprovalWorkflowInstances_ContentItemId_State", table: "ApprovalWorkflowInstances", columns: new[] { "ContentItemId", "State" }, unique: true, filter: "\"State\" = 'Pending'"); migrationBuilder.CreateIndex( name: "IX_ApprovalWorkflowInstances_WorkspaceId", table: "ApprovalWorkflowInstances", column: "WorkspaceId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "ApprovalWorkflowInstances"); migrationBuilder.DropIndex( name: "IX_ApprovalRequests_WorkflowInstanceId", table: "ApprovalRequests"); migrationBuilder.DropColumn( name: "WorkflowInstanceId", table: "ApprovalRequests"); migrationBuilder.DropColumn( name: "WorkflowStepRequiredApproverCount", table: "ApprovalRequests"); migrationBuilder.DropColumn( name: "WorkflowStepSortOrder", table: "ApprovalRequests"); migrationBuilder.DropColumn( name: "WorkflowStepTargetType", table: "ApprovalRequests"); migrationBuilder.DropColumn( name: "WorkflowStepTargetValue", table: "ApprovalRequests"); } } }