tasker-engine 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (601) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +22 -0
  3. data/README.md +440 -0
  4. data/Rakefile +10 -0
  5. data/app/controllers/tasker/analytics_controller.rb +179 -0
  6. data/app/controllers/tasker/application_controller.rb +45 -0
  7. data/app/controllers/tasker/graphql_controller.rb +193 -0
  8. data/app/controllers/tasker/handlers_controller.rb +217 -0
  9. data/app/controllers/tasker/health_controller.rb +229 -0
  10. data/app/controllers/tasker/metrics_controller.rb +111 -0
  11. data/app/controllers/tasker/page_sort.rb +97 -0
  12. data/app/controllers/tasker/tasks_controller.rb +123 -0
  13. data/app/controllers/tasker/workflow_steps_controller.rb +69 -0
  14. data/app/graphql/examples/all_tasks.graphql +22 -0
  15. data/app/graphql/examples/pending_tasks.graphql +23 -0
  16. data/app/graphql/tasker/graph_ql_types/annotation_type.rb +14 -0
  17. data/app/graphql/tasker/graph_ql_types/base_argument.rb +9 -0
  18. data/app/graphql/tasker/graph_ql_types/base_connection.rb +11 -0
  19. data/app/graphql/tasker/graph_ql_types/base_edge.rb +10 -0
  20. data/app/graphql/tasker/graph_ql_types/base_enum.rb +9 -0
  21. data/app/graphql/tasker/graph_ql_types/base_field.rb +10 -0
  22. data/app/graphql/tasker/graph_ql_types/base_input_object.rb +10 -0
  23. data/app/graphql/tasker/graph_ql_types/base_interface.rb +14 -0
  24. data/app/graphql/tasker/graph_ql_types/base_object.rb +10 -0
  25. data/app/graphql/tasker/graph_ql_types/base_scalar.rb +9 -0
  26. data/app/graphql/tasker/graph_ql_types/base_union.rb +11 -0
  27. data/app/graphql/tasker/graph_ql_types/dependent_system_object_map_type.rb +18 -0
  28. data/app/graphql/tasker/graph_ql_types/dependent_system_type.rb +13 -0
  29. data/app/graphql/tasker/graph_ql_types/mutation_type.rb +16 -0
  30. data/app/graphql/tasker/graph_ql_types/named_step_type.rb +16 -0
  31. data/app/graphql/tasker/graph_ql_types/named_task_type.rb +14 -0
  32. data/app/graphql/tasker/graph_ql_types/named_tasks_named_step_type.rb +19 -0
  33. data/app/graphql/tasker/graph_ql_types/node_type.rb +12 -0
  34. data/app/graphql/tasker/graph_ql_types/query_type.rb +20 -0
  35. data/app/graphql/tasker/graph_ql_types/task_annotation_type.rb +17 -0
  36. data/app/graphql/tasker/graph_ql_types/task_interface.rb +17 -0
  37. data/app/graphql/tasker/graph_ql_types/task_type.rb +26 -0
  38. data/app/graphql/tasker/graph_ql_types/workflow_step_type.rb +154 -0
  39. data/app/graphql/tasker/graph_ql_types.rb +42 -0
  40. data/app/graphql/tasker/mutations/base_mutation.rb +13 -0
  41. data/app/graphql/tasker/mutations/cancel_step.rb +29 -0
  42. data/app/graphql/tasker/mutations/cancel_task.rb +29 -0
  43. data/app/graphql/tasker/mutations/create_task.rb +52 -0
  44. data/app/graphql/tasker/mutations/update_step.rb +36 -0
  45. data/app/graphql/tasker/mutations/update_task.rb +41 -0
  46. data/app/graphql/tasker/queries/all_annotation_types.rb +17 -0
  47. data/app/graphql/tasker/queries/all_tasks.rb +23 -0
  48. data/app/graphql/tasker/queries/base_query.rb +9 -0
  49. data/app/graphql/tasker/queries/helpers.rb +16 -0
  50. data/app/graphql/tasker/queries/one_step.rb +24 -0
  51. data/app/graphql/tasker/queries/one_task.rb +18 -0
  52. data/app/graphql/tasker/queries/tasks_by_annotation.rb +31 -0
  53. data/app/graphql/tasker/queries/tasks_by_status.rb +30 -0
  54. data/app/graphql/tasker/tasker_rails_schema.rb +52 -0
  55. data/app/jobs/tasker/application_job.rb +8 -0
  56. data/app/jobs/tasker/metrics_export_job.rb +252 -0
  57. data/app/jobs/tasker/task_runner_job.rb +224 -0
  58. data/app/models/tasker/annotation_type.rb +26 -0
  59. data/app/models/tasker/application_record.rb +70 -0
  60. data/app/models/tasker/dependent_system.rb +26 -0
  61. data/app/models/tasker/dependent_system_object_map.rb +64 -0
  62. data/app/models/tasker/named_step.rb +41 -0
  63. data/app/models/tasker/named_task.rb +121 -0
  64. data/app/models/tasker/named_tasks_named_step.rb +82 -0
  65. data/app/models/tasker/step_dag_relationship.rb +65 -0
  66. data/app/models/tasker/step_readiness_status.rb +59 -0
  67. data/app/models/tasker/task.rb +414 -0
  68. data/app/models/tasker/task_annotation.rb +36 -0
  69. data/app/models/tasker/task_execution_context.rb +29 -0
  70. data/app/models/tasker/task_namespace.rb +41 -0
  71. data/app/models/tasker/task_transition.rb +235 -0
  72. data/app/models/tasker/workflow_step.rb +461 -0
  73. data/app/models/tasker/workflow_step_edge.rb +95 -0
  74. data/app/models/tasker/workflow_step_transition.rb +434 -0
  75. data/app/serializers/tasker/annotation_type_serializer.rb +8 -0
  76. data/app/serializers/tasker/handler_serializer.rb +109 -0
  77. data/app/serializers/tasker/task_annotation_serializer.rb +32 -0
  78. data/app/serializers/tasker/task_serializer.rb +168 -0
  79. data/app/serializers/tasker/workflow_step_serializer.rb +27 -0
  80. data/app/services/tasker/analytics_service.rb +409 -0
  81. data/config/initializers/dry_struct.rb +11 -0
  82. data/config/initializers/statesman.rb +6 -0
  83. data/config/initializers/tasker_orchestration.rb +17 -0
  84. data/config/initializers/time_formats.rb +4 -0
  85. data/config/routes.rb +34 -0
  86. data/config/tasker/subscriptions/example_integrations.yml +67 -0
  87. data/config/tasker/system_events.yml +305 -0
  88. data/db/functions/calculate_dependency_levels_v01.sql +45 -0
  89. data/db/functions/get_analytics_metrics_v01.sql +137 -0
  90. data/db/functions/get_slowest_steps_v01.sql +82 -0
  91. data/db/functions/get_slowest_tasks_v01.sql +96 -0
  92. data/db/functions/get_step_readiness_status_batch_v01.sql +140 -0
  93. data/db/functions/get_step_readiness_status_single_and_batch_v02.sql +223 -0
  94. data/db/functions/get_step_readiness_status_v01.sql +139 -0
  95. data/db/functions/get_system_health_counts_v01.sql +108 -0
  96. data/db/functions/get_task_execution_context_v01.sql +108 -0
  97. data/db/functions/get_task_execution_contexts_batch_v01.sql +104 -0
  98. data/db/init/schema.sql +2254 -0
  99. data/db/migrate/20250701165431_initial_tasker_schema.rb +116 -0
  100. data/db/migrate/20250710110830_step_readiness_sql_functions_v02.rb +39 -0
  101. data/db/views/tasker_step_dag_relationships_v01.sql +69 -0
  102. data/docs/APPLICATION_GENERATOR.md +384 -0
  103. data/docs/AUTH.md +1741 -0
  104. data/docs/CIRCUIT_BREAKER.md +224 -0
  105. data/docs/DEVELOPER_GUIDE.md +2664 -0
  106. data/docs/EVENT_SYSTEM.md +637 -0
  107. data/docs/EXECUTION_CONFIGURATION.md +341 -0
  108. data/docs/FLOW_CHART.md +149 -0
  109. data/docs/HEALTH.md +542 -0
  110. data/docs/METRICS.md +731 -0
  111. data/docs/OPTIMIZATION_PLAN.md +1479 -0
  112. data/docs/OVERVIEW.md +548 -0
  113. data/docs/QUICK_START.md +270 -0
  114. data/docs/REGISTRY_SYSTEMS.md +373 -0
  115. data/docs/REST_API.md +632 -0
  116. data/docs/REVERSIONING.md +404 -0
  117. data/docs/ROADMAP.md +221 -0
  118. data/docs/SQL_FUNCTIONS.md +1408 -0
  119. data/docs/TASK_EXECUTION_CONTROL_FLOW.md +237 -0
  120. data/docs/TELEMETRY.md +795 -0
  121. data/docs/TROUBLESHOOTING.md +756 -0
  122. data/docs/TaskHandlerGenerator.html +255 -0
  123. data/docs/Tasker/Analysis/RuntimeGraphAnalyzer.html +907 -0
  124. data/docs/Tasker/Analysis/TemplateGraphAnalyzer.html +1236 -0
  125. data/docs/Tasker/Analysis.html +117 -0
  126. data/docs/Tasker/AnalyticsController.html +450 -0
  127. data/docs/Tasker/AnalyticsService/BottleneckAnalytics.html +816 -0
  128. data/docs/Tasker/AnalyticsService/PerformanceAnalytics.html +586 -0
  129. data/docs/Tasker/AnalyticsService.html +2221 -0
  130. data/docs/Tasker/AnnotationType.html +137 -0
  131. data/docs/Tasker/AnnotationTypeSerializer.html +124 -0
  132. data/docs/Tasker/ApplicationController.html +147 -0
  133. data/docs/Tasker/ApplicationJob.html +128 -0
  134. data/docs/Tasker/ApplicationRecord.html +378 -0
  135. data/docs/Tasker/Authentication/AuthenticationError.html +124 -0
  136. data/docs/Tasker/Authentication/ConfigurationError.html +124 -0
  137. data/docs/Tasker/Authentication/Coordinator.html +242 -0
  138. data/docs/Tasker/Authentication/Interface.html +560 -0
  139. data/docs/Tasker/Authentication/InterfaceError.html +124 -0
  140. data/docs/Tasker/Authentication/NoneAuthenticator.html +338 -0
  141. data/docs/Tasker/Authentication.html +119 -0
  142. data/docs/Tasker/Authorization/AuthorizationError.html +139 -0
  143. data/docs/Tasker/Authorization/BaseCoordinator.html +927 -0
  144. data/docs/Tasker/Authorization/ConfigurationError.html +153 -0
  145. data/docs/Tasker/Authorization/ResourceConstants/ACTIONS.html +428 -0
  146. data/docs/Tasker/Authorization/ResourceConstants/RESOURCES.html +360 -0
  147. data/docs/Tasker/Authorization/ResourceConstants.html +146 -0
  148. data/docs/Tasker/Authorization/ResourceRegistry.html +875 -0
  149. data/docs/Tasker/Authorization/UnauthorizedError.html +153 -0
  150. data/docs/Tasker/Authorization.html +582 -0
  151. data/docs/Tasker/CacheCapabilities.html +167 -0
  152. data/docs/Tasker/CacheStrategy.html +1297 -0
  153. data/docs/Tasker/Concerns/Authenticatable.html +116 -0
  154. data/docs/Tasker/Concerns/Authorizable/AdminStatusChecker.html +256 -0
  155. data/docs/Tasker/Concerns/Authorizable.html +816 -0
  156. data/docs/Tasker/Concerns/ControllerAuthorizable.html +157 -0
  157. data/docs/Tasker/Concerns/EventPublisher.html +4023 -0
  158. data/docs/Tasker/Concerns/IdempotentStateTransitions.html +806 -0
  159. data/docs/Tasker/Concerns/LifecycleEventHelpers.html +129 -0
  160. data/docs/Tasker/Concerns/OrchestrationPublisher.html +129 -0
  161. data/docs/Tasker/Concerns/StateMachineBase/ClassMethods.html +1075 -0
  162. data/docs/Tasker/Concerns/StateMachineBase/StateMachineBase/ClassMethods.html +191 -0
  163. data/docs/Tasker/Concerns/StateMachineBase/StateMachineBase.html +126 -0
  164. data/docs/Tasker/Concerns/StateMachineBase.html +153 -0
  165. data/docs/Tasker/Concerns/StructuredLogging.html +1413 -0
  166. data/docs/Tasker/Concerns.html +117 -0
  167. data/docs/Tasker/Configuration/AuthConfiguration.html +1023 -0
  168. data/docs/Tasker/Configuration/ConfigurationProxy.html +581 -0
  169. data/docs/Tasker/Configuration/DatabaseConfiguration.html +475 -0
  170. data/docs/Tasker/Configuration/EngineConfiguration.html +1265 -0
  171. data/docs/Tasker/Configuration/HealthConfiguration.html +791 -0
  172. data/docs/Tasker/Configuration/TelemetryConfiguration.html +1308 -0
  173. data/docs/Tasker/Configuration/TelemetryConfigurationProxy.html +388 -0
  174. data/docs/Tasker/Configuration.html +1669 -0
  175. data/docs/Tasker/ConfigurationError.html +143 -0
  176. data/docs/Tasker/ConfiguredTask.html +514 -0
  177. data/docs/Tasker/Constants/EventDefinitions.html +590 -0
  178. data/docs/Tasker/Constants/LifecycleEvents.html +137 -0
  179. data/docs/Tasker/Constants/ObservabilityEvents/Step.html +152 -0
  180. data/docs/Tasker/Constants/ObservabilityEvents/Task.html +142 -0
  181. data/docs/Tasker/Constants/ObservabilityEvents.html +126 -0
  182. data/docs/Tasker/Constants/RegistryEvents.html +285 -0
  183. data/docs/Tasker/Constants/StepEvents.html +177 -0
  184. data/docs/Tasker/Constants/TaskEvents.html +167 -0
  185. data/docs/Tasker/Constants/TaskExecution/ExecutionStatus.html +207 -0
  186. data/docs/Tasker/Constants/TaskExecution/HealthStatus.html +191 -0
  187. data/docs/Tasker/Constants/TaskExecution/RecommendedAction.html +207 -0
  188. data/docs/Tasker/Constants/TaskExecution.html +126 -0
  189. data/docs/Tasker/Constants/TaskFinalization/ErrorMessages.html +132 -0
  190. data/docs/Tasker/Constants/TaskFinalization/PendingReasons.html +207 -0
  191. data/docs/Tasker/Constants/TaskFinalization/ReenqueueReasons.html +239 -0
  192. data/docs/Tasker/Constants/TaskFinalization.html +126 -0
  193. data/docs/Tasker/Constants/TaskStatuses.html +223 -0
  194. data/docs/Tasker/Constants/TestEvents.html +163 -0
  195. data/docs/Tasker/Constants/WorkflowEvents.html +222 -0
  196. data/docs/Tasker/Constants/WorkflowStepStatuses.html +223 -0
  197. data/docs/Tasker/Constants.html +561 -0
  198. data/docs/Tasker/DependentSystem.html +137 -0
  199. data/docs/Tasker/DependentSystemObjectMap.html +250 -0
  200. data/docs/Tasker/DetectorRegistry.html +598 -0
  201. data/docs/Tasker/Diagram/Edge.html +1191 -0
  202. data/docs/Tasker/Diagram/Flowchart.html +1539 -0
  203. data/docs/Tasker/Diagram/Node.html +1165 -0
  204. data/docs/Tasker/Diagram.html +117 -0
  205. data/docs/Tasker/Engine.html +215 -0
  206. data/docs/Tasker/Error.html +139 -0
  207. data/docs/Tasker/Events/Bus.html +1226 -0
  208. data/docs/Tasker/Events/Catalog/CatalogPrinter.html +258 -0
  209. data/docs/Tasker/Events/Catalog/CustomEventRegistrar.html +276 -0
  210. data/docs/Tasker/Events/Catalog/ExamplePayloadGenerator.html +294 -0
  211. data/docs/Tasker/Events/Catalog.html +1291 -0
  212. data/docs/Tasker/Events/CustomRegistry.html +943 -0
  213. data/docs/Tasker/Events/DefinitionLoader.html +575 -0
  214. data/docs/Tasker/Events/EventPayloadBuilder/ErrorInfoExtractor.html +286 -0
  215. data/docs/Tasker/Events/EventPayloadBuilder/StepPayloadBuilder.html +312 -0
  216. data/docs/Tasker/Events/EventPayloadBuilder.html +664 -0
  217. data/docs/Tasker/Events/Publisher.html +365 -0
  218. data/docs/Tasker/Events/Subscribers/BaseSubscriber/ErrorCategorizer/ErrorTypeClassifier.html +1128 -0
  219. data/docs/Tasker/Events/Subscribers/BaseSubscriber/ErrorCategorizer.html +270 -0
  220. data/docs/Tasker/Events/Subscribers/BaseSubscriber/MetricTagsExtractor.html +266 -0
  221. data/docs/Tasker/Events/Subscribers/BaseSubscriber.html +2556 -0
  222. data/docs/Tasker/Events/Subscribers/MetricsSubscriber.html +723 -0
  223. data/docs/Tasker/Events/Subscribers/TelemetrySubscriber.html +2251 -0
  224. data/docs/Tasker/Events/Subscribers.html +117 -0
  225. data/docs/Tasker/Events/SubscriptionLoader.html +493 -0
  226. data/docs/Tasker/Events.html +294 -0
  227. data/docs/Tasker/EventsGenerator.html +459 -0
  228. data/docs/Tasker/Functions/FunctionBasedAnalyticsMetrics/AnalyticsMetrics.html +135 -0
  229. data/docs/Tasker/Functions/FunctionBasedAnalyticsMetrics.html +412 -0
  230. data/docs/Tasker/Functions/FunctionBasedDependencyLevels.html +598 -0
  231. data/docs/Tasker/Functions/FunctionBasedSlowestSteps/SlowestStep.html +135 -0
  232. data/docs/Tasker/Functions/FunctionBasedSlowestSteps.html +453 -0
  233. data/docs/Tasker/Functions/FunctionBasedSlowestTasks/SlowestTask.html +135 -0
  234. data/docs/Tasker/Functions/FunctionBasedSlowestTasks.html +453 -0
  235. data/docs/Tasker/Functions/FunctionBasedStepReadinessStatus.html +1457 -0
  236. data/docs/Tasker/Functions/FunctionBasedSystemHealthCounts/HealthMetrics.html +135 -0
  237. data/docs/Tasker/Functions/FunctionBasedSystemHealthCounts.html +370 -0
  238. data/docs/Tasker/Functions/FunctionBasedTaskExecutionContext.html +1250 -0
  239. data/docs/Tasker/Functions/FunctionWrapper.html +479 -0
  240. data/docs/Tasker/Functions.html +117 -0
  241. data/docs/Tasker/Generators/AuthenticatorGenerator/UsageInstructionsFormatter.html +244 -0
  242. data/docs/Tasker/Generators/AuthenticatorGenerator.html +373 -0
  243. data/docs/Tasker/Generators/AuthorizationCoordinatorGenerator.html +430 -0
  244. data/docs/Tasker/Generators/SubscriberGenerator.html +377 -0
  245. data/docs/Tasker/Generators/TaskHandlerGenerator.html +263 -0
  246. data/docs/Tasker/Generators.html +117 -0
  247. data/docs/Tasker/GraphQLTypes/AnnotationType.html +132 -0
  248. data/docs/Tasker/GraphQLTypes/BaseArgument.html +124 -0
  249. data/docs/Tasker/GraphQLTypes/BaseConnection.html +124 -0
  250. data/docs/Tasker/GraphQLTypes/BaseEdge.html +130 -0
  251. data/docs/Tasker/GraphQLTypes/BaseEnum.html +124 -0
  252. data/docs/Tasker/GraphQLTypes/BaseField.html +124 -0
  253. data/docs/Tasker/GraphQLTypes/BaseInputObject.html +124 -0
  254. data/docs/Tasker/GraphQLTypes/BaseInterface.html +116 -0
  255. data/docs/Tasker/GraphQLTypes/BaseObject.html +128 -0
  256. data/docs/Tasker/GraphQLTypes/BaseScalar.html +124 -0
  257. data/docs/Tasker/GraphQLTypes/BaseUnion.html +124 -0
  258. data/docs/Tasker/GraphQLTypes/DependentSystemObjectMapType.html +132 -0
  259. data/docs/Tasker/GraphQLTypes/DependentSystemType.html +132 -0
  260. data/docs/Tasker/GraphQLTypes/MutationType.html +132 -0
  261. data/docs/Tasker/GraphQLTypes/NamedStepType.html +132 -0
  262. data/docs/Tasker/GraphQLTypes/NamedTaskType.html +132 -0
  263. data/docs/Tasker/GraphQLTypes/NamedTasksNamedStepType.html +132 -0
  264. data/docs/Tasker/GraphQLTypes/NodeType.html +118 -0
  265. data/docs/Tasker/GraphQLTypes/QueryType.html +139 -0
  266. data/docs/Tasker/GraphQLTypes/TaskAnnotationType.html +132 -0
  267. data/docs/Tasker/GraphQLTypes/TaskInterface.html +111 -0
  268. data/docs/Tasker/GraphQLTypes/TaskType.html +201 -0
  269. data/docs/Tasker/GraphQLTypes/WorkflowStepType.html +694 -0
  270. data/docs/Tasker/GraphQLTypes.html +130 -0
  271. data/docs/Tasker/GraphqlController.html +251 -0
  272. data/docs/Tasker/HandlerFactory.html +1528 -0
  273. data/docs/Tasker/HandlerSerializer.html +682 -0
  274. data/docs/Tasker/HandlersController.html +574 -0
  275. data/docs/Tasker/HashIdentityStrategy.html +278 -0
  276. data/docs/Tasker/Health/ReadinessChecker.html +712 -0
  277. data/docs/Tasker/Health/StatusChecker.html +653 -0
  278. data/docs/Tasker/Health.html +117 -0
  279. data/docs/Tasker/HealthController.html +523 -0
  280. data/docs/Tasker/IdentityStrategy.html +276 -0
  281. data/docs/Tasker/InvalidTaskHandlerConfig.html +135 -0
  282. data/docs/Tasker/LifecycleEvents/Events/Step.html +162 -0
  283. data/docs/Tasker/LifecycleEvents/Events/Task.html +162 -0
  284. data/docs/Tasker/LifecycleEvents/Events.html +204 -0
  285. data/docs/Tasker/LifecycleEvents/Publisher.html +132 -0
  286. data/docs/Tasker/LifecycleEvents.html +799 -0
  287. data/docs/Tasker/Logging/CorrelationIdGenerator.html +688 -0
  288. data/docs/Tasker/Logging.html +115 -0
  289. data/docs/Tasker/MetricsController.html +293 -0
  290. data/docs/Tasker/MetricsExportJob.html +414 -0
  291. data/docs/Tasker/Mutations/BaseMutation.html +128 -0
  292. data/docs/Tasker/Mutations/CancelStep.html +219 -0
  293. data/docs/Tasker/Mutations/CancelTask.html +221 -0
  294. data/docs/Tasker/Mutations/CreateTask.html +243 -0
  295. data/docs/Tasker/Mutations/UpdateStep.html +243 -0
  296. data/docs/Tasker/Mutations/UpdateTask.html +243 -0
  297. data/docs/Tasker/Mutations.html +117 -0
  298. data/docs/Tasker/NamedStep.html +216 -0
  299. data/docs/Tasker/NamedTask.html +910 -0
  300. data/docs/Tasker/NamedTasksNamedStep.html +435 -0
  301. data/docs/Tasker/Orchestration/BackoffCalculator.html +404 -0
  302. data/docs/Tasker/Orchestration/ConnectionBuilder/ConfigValidator.html +258 -0
  303. data/docs/Tasker/Orchestration/ConnectionBuilder.html +435 -0
  304. data/docs/Tasker/Orchestration/ConnectionPoolIntelligence.html +513 -0
  305. data/docs/Tasker/Orchestration/Coordinator.html +641 -0
  306. data/docs/Tasker/Orchestration/FutureStateAnalyzer.html +1045 -0
  307. data/docs/Tasker/Orchestration/Orchestrator.html +679 -0
  308. data/docs/Tasker/Orchestration/PluginIntegration.html +1127 -0
  309. data/docs/Tasker/Orchestration/ResponseProcessor.html +504 -0
  310. data/docs/Tasker/Orchestration/RetryHeaderParser.html +304 -0
  311. data/docs/Tasker/Orchestration/StepExecutor.html +995 -0
  312. data/docs/Tasker/Orchestration/StepSequenceFactory.html +644 -0
  313. data/docs/Tasker/Orchestration/TaskFinalizer/BlockageChecker.html +264 -0
  314. data/docs/Tasker/Orchestration/TaskFinalizer/ContextManager.html +254 -0
  315. data/docs/Tasker/Orchestration/TaskFinalizer/DelayCalculator.html +556 -0
  316. data/docs/Tasker/Orchestration/TaskFinalizer/FinalizationDecisionMaker.html +348 -0
  317. data/docs/Tasker/Orchestration/TaskFinalizer/FinalizationProcessor.html +286 -0
  318. data/docs/Tasker/Orchestration/TaskFinalizer/ReasonDeterminer.html +432 -0
  319. data/docs/Tasker/Orchestration/TaskFinalizer/ReenqueueManager.html +296 -0
  320. data/docs/Tasker/Orchestration/TaskFinalizer/UnclearStateHandler.html +314 -0
  321. data/docs/Tasker/Orchestration/TaskFinalizer.html +1212 -0
  322. data/docs/Tasker/Orchestration/TaskInitializer.html +766 -0
  323. data/docs/Tasker/Orchestration/TaskReenqueuer.html +506 -0
  324. data/docs/Tasker/Orchestration/ViableStepDiscovery.html +442 -0
  325. data/docs/Tasker/Orchestration/WorkflowCoordinator.html +510 -0
  326. data/docs/Tasker/Orchestration.html +130 -0
  327. data/docs/Tasker/PageSort/PageSortParamsBuilder.html +296 -0
  328. data/docs/Tasker/PageSort.html +247 -0
  329. data/docs/Tasker/PermanentError.html +518 -0
  330. data/docs/Tasker/ProceduralError.html +147 -0
  331. data/docs/Tasker/Queries/AllAnnotationTypes.html +217 -0
  332. data/docs/Tasker/Queries/AllTasks.html +221 -0
  333. data/docs/Tasker/Queries/BaseQuery.html +128 -0
  334. data/docs/Tasker/Queries/Helpers.html +187 -0
  335. data/docs/Tasker/Queries/OneStep.html +225 -0
  336. data/docs/Tasker/Queries/OneTask.html +217 -0
  337. data/docs/Tasker/Queries/TasksByAnnotation.html +231 -0
  338. data/docs/Tasker/Queries/TasksByStatus.html +233 -0
  339. data/docs/Tasker/Queries.html +119 -0
  340. data/docs/Tasker/Railtie.html +124 -0
  341. data/docs/Tasker/Registry/BaseRegistry.html +1690 -0
  342. data/docs/Tasker/Registry/EventPublisher.html +667 -0
  343. data/docs/Tasker/Registry/InterfaceValidator.html +569 -0
  344. data/docs/Tasker/Registry/RegistrationError.html +132 -0
  345. data/docs/Tasker/Registry/RegistryError.html +139 -0
  346. data/docs/Tasker/Registry/StatisticsCollector.html +841 -0
  347. data/docs/Tasker/Registry/SubscriberRegistry.html +1504 -0
  348. data/docs/Tasker/Registry/ValidationError.html +132 -0
  349. data/docs/Tasker/Registry.html +119 -0
  350. data/docs/Tasker/RetryableError.html +515 -0
  351. data/docs/Tasker/StateMachine/Compatibility.html +282 -0
  352. data/docs/Tasker/StateMachine/InvalidStateTransition.html +135 -0
  353. data/docs/Tasker/StateMachine/StepStateMachine/StandardizedPayloadBuilder.html +260 -0
  354. data/docs/Tasker/StateMachine/StepStateMachine.html +2215 -0
  355. data/docs/Tasker/StateMachine/TaskStateMachine.html +734 -0
  356. data/docs/Tasker/StateMachine.html +602 -0
  357. data/docs/Tasker/StepDagRelationship.html +657 -0
  358. data/docs/Tasker/StepHandler/Api/Config.html +1091 -0
  359. data/docs/Tasker/StepHandler/Api.html +884 -0
  360. data/docs/Tasker/StepHandler/AutomaticEventPublishing.html +321 -0
  361. data/docs/Tasker/StepHandler/Base.html +970 -0
  362. data/docs/Tasker/StepHandler.html +119 -0
  363. data/docs/Tasker/StepReadinessStatus.html +836 -0
  364. data/docs/Tasker/Task.html +2478 -0
  365. data/docs/Tasker/TaskAnnotation.html +137 -0
  366. data/docs/Tasker/TaskAnnotationSerializer.html +124 -0
  367. data/docs/Tasker/TaskBuilder/StepNameValidator.html +264 -0
  368. data/docs/Tasker/TaskBuilder/StepTemplateDefiner.html +264 -0
  369. data/docs/Tasker/TaskBuilder.html +764 -0
  370. data/docs/Tasker/TaskDiagram/StepToStepEdgeBuilder.html +260 -0
  371. data/docs/Tasker/TaskDiagram/TaskToRootStepEdgeBuilder.html +290 -0
  372. data/docs/Tasker/TaskDiagram.html +548 -0
  373. data/docs/Tasker/TaskDiagramsController.html +240 -0
  374. data/docs/Tasker/TaskExecutionContext.html +469 -0
  375. data/docs/Tasker/TaskHandler/ClassMethods/StepTemplateDefiner/ClassBasedEventRegistrar.html +238 -0
  376. data/docs/Tasker/TaskHandler/ClassMethods/StepTemplateDefiner/YamlEventRegistrar.html +254 -0
  377. data/docs/Tasker/TaskHandler/ClassMethods/StepTemplateDefiner.html +988 -0
  378. data/docs/Tasker/TaskHandler/ClassMethods.html +395 -0
  379. data/docs/Tasker/TaskHandler/InstanceMethods.html +1396 -0
  380. data/docs/Tasker/TaskHandler/StepGroup.html +1748 -0
  381. data/docs/Tasker/TaskHandler.html +271 -0
  382. data/docs/Tasker/TaskNamespace.html +312 -0
  383. data/docs/Tasker/TaskRunnerJob.html +406 -0
  384. data/docs/Tasker/TaskSerializer.html +474 -0
  385. data/docs/Tasker/TaskTransition.html +1517 -0
  386. data/docs/Tasker/TaskWorkflowSummary.html +988 -0
  387. data/docs/Tasker/TaskerRailsSchema/InvalidObjectTypeError.html +132 -0
  388. data/docs/Tasker/TaskerRailsSchema/TypeResolutionError.html +139 -0
  389. data/docs/Tasker/TaskerRailsSchema/UnknownInterfaceError.html +132 -0
  390. data/docs/Tasker/TaskerRailsSchema.html +384 -0
  391. data/docs/Tasker/TasksController.html +595 -0
  392. data/docs/Tasker/Telemetry/EventMapping.html +1307 -0
  393. data/docs/Tasker/Telemetry/EventRouter.html +2178 -0
  394. data/docs/Tasker/Telemetry/Events/ExportEvents.html +246 -0
  395. data/docs/Tasker/Telemetry/Events.html +115 -0
  396. data/docs/Tasker/Telemetry/ExportCoordinator/DistributedLockTimeoutError.html +135 -0
  397. data/docs/Tasker/Telemetry/ExportCoordinator.html +2137 -0
  398. data/docs/Tasker/Telemetry/IntelligentCacheManager.html +1083 -0
  399. data/docs/Tasker/Telemetry/LogBackend.html +1088 -0
  400. data/docs/Tasker/Telemetry/MetricTypes/Counter.html +1054 -0
  401. data/docs/Tasker/Telemetry/MetricTypes/Gauge.html +1270 -0
  402. data/docs/Tasker/Telemetry/MetricTypes/Histogram.html +1492 -0
  403. data/docs/Tasker/Telemetry/MetricTypes.html +153 -0
  404. data/docs/Tasker/Telemetry/MetricsBackend.html +2510 -0
  405. data/docs/Tasker/Telemetry/MetricsExportService.html +578 -0
  406. data/docs/Tasker/Telemetry/PluginRegistry.html +1774 -0
  407. data/docs/Tasker/Telemetry/Plugins/BaseExporter.html +1835 -0
  408. data/docs/Tasker/Telemetry/Plugins/CsvExporter.html +768 -0
  409. data/docs/Tasker/Telemetry/Plugins/JsonExporter.html +747 -0
  410. data/docs/Tasker/Telemetry/Plugins.html +117 -0
  411. data/docs/Tasker/Telemetry/PrometheusExporter.html +481 -0
  412. data/docs/Tasker/Telemetry/TraceBackend.html +891 -0
  413. data/docs/Tasker/Telemetry.html +130 -0
  414. data/docs/Tasker/Types/AuthConfig.html +886 -0
  415. data/docs/Tasker/Types/BackoffConfig.html +1063 -0
  416. data/docs/Tasker/Types/BaseConfig.html +227 -0
  417. data/docs/Tasker/Types/CacheConfig.html +1731 -0
  418. data/docs/Tasker/Types/DatabaseConfig.html +388 -0
  419. data/docs/Tasker/Types/DependencyGraph.html +526 -0
  420. data/docs/Tasker/Types/DependencyGraphConfig.html +753 -0
  421. data/docs/Tasker/Types/EngineConfig.html +1181 -0
  422. data/docs/Tasker/Types/ExecutionConfig.html +1963 -0
  423. data/docs/Tasker/Types/GraphEdge.html +517 -0
  424. data/docs/Tasker/Types/GraphMetadata.html +781 -0
  425. data/docs/Tasker/Types/GraphNode.html +694 -0
  426. data/docs/Tasker/Types/HealthConfig.html +784 -0
  427. data/docs/Tasker/Types/StepSequence.html +353 -0
  428. data/docs/Tasker/Types/StepTemplate.html +1193 -0
  429. data/docs/Tasker/Types/TaskRequest.html +1179 -0
  430. data/docs/Tasker/Types/TelemetryConfig.html +2746 -0
  431. data/docs/Tasker/Types.html +154 -0
  432. data/docs/Tasker/WorkflowStep/StepFinder.html +282 -0
  433. data/docs/Tasker/WorkflowStep.html +2724 -0
  434. data/docs/Tasker/WorkflowStepEdge.html +306 -0
  435. data/docs/Tasker/WorkflowStepSerializer.html +305 -0
  436. data/docs/Tasker/WorkflowStepTransition/TransitionDescriptionFormatter.html +282 -0
  437. data/docs/Tasker/WorkflowStepTransition.html +2201 -0
  438. data/docs/Tasker/WorkflowStepsController.html +462 -0
  439. data/docs/Tasker.html +468 -0
  440. data/docs/VISION.md +584 -0
  441. data/docs/WHY.md +21 -0
  442. data/docs/_index.html +2319 -0
  443. data/docs/class_list.html +54 -0
  444. data/docs/css/common.css +1 -0
  445. data/docs/css/full_list.css +58 -0
  446. data/docs/css/style.css +503 -0
  447. data/docs/events/migration_plan_outcomes.md +80 -0
  448. data/docs/file.README.html +537 -0
  449. data/docs/file_list.html +59 -0
  450. data/docs/frames.html +22 -0
  451. data/docs/index.html +537 -0
  452. data/docs/js/app.js +344 -0
  453. data/docs/js/full_list.js +242 -0
  454. data/docs/js/jquery.js +4 -0
  455. data/docs/method_list.html +8854 -0
  456. data/docs/top-level-namespace.html +110 -0
  457. data/lib/generators/tasker/authenticator_generator.rb +301 -0
  458. data/lib/generators/tasker/authorization_coordinator_generator.rb +139 -0
  459. data/lib/generators/tasker/events_generator.rb +91 -0
  460. data/lib/generators/tasker/subscriber_generator.rb +107 -0
  461. data/lib/generators/tasker/task_handler_generator.rb +138 -0
  462. data/lib/generators/tasker/templates/api_token_authenticator.rb.erb +113 -0
  463. data/lib/generators/tasker/templates/api_token_authenticator_spec.rb.erb +144 -0
  464. data/lib/generators/tasker/templates/authorization_coordinator.rb.erb +82 -0
  465. data/lib/generators/tasker/templates/authorization_coordinator_spec.rb.erb +136 -0
  466. data/lib/generators/tasker/templates/custom_authenticator.rb.erb +108 -0
  467. data/lib/generators/tasker/templates/custom_authenticator_spec.rb.erb +162 -0
  468. data/lib/generators/tasker/templates/custom_events.yml.erb +62 -0
  469. data/lib/generators/tasker/templates/custom_subscriber.rb.erb +72 -0
  470. data/lib/generators/tasker/templates/devise_authenticator.rb.erb +101 -0
  471. data/lib/generators/tasker/templates/devise_authenticator_spec.rb.erb +126 -0
  472. data/lib/generators/tasker/templates/initialize.rb.erb +202 -0
  473. data/lib/generators/tasker/templates/jwt_authenticator.rb.erb +144 -0
  474. data/lib/generators/tasker/templates/jwt_authenticator_spec.rb.erb +298 -0
  475. data/lib/generators/tasker/templates/metrics_subscriber.rb.erb +258 -0
  476. data/lib/generators/tasker/templates/metrics_subscriber_spec.rb.erb +308 -0
  477. data/lib/generators/tasker/templates/omniauth_authenticator.rb.erb +135 -0
  478. data/lib/generators/tasker/templates/omniauth_authenticator_spec.rb.erb +196 -0
  479. data/lib/generators/tasker/templates/opentelemetry_initializer.rb +52 -0
  480. data/lib/generators/tasker/templates/subscriber.rb.erb +64 -0
  481. data/lib/generators/tasker/templates/subscriber_spec.rb.erb +80 -0
  482. data/lib/generators/tasker/templates/task_config.yaml.erb +117 -0
  483. data/lib/generators/tasker/templates/task_handler.rb.erb +60 -0
  484. data/lib/generators/tasker/templates/task_handler_spec.rb.erb +165 -0
  485. data/lib/tasker/analysis/runtime_graph_analyzer.rb +1168 -0
  486. data/lib/tasker/analysis/template_graph_analyzer.rb +328 -0
  487. data/lib/tasker/authentication/coordinator.rb +78 -0
  488. data/lib/tasker/authentication/errors.rb +9 -0
  489. data/lib/tasker/authentication/interface.rb +36 -0
  490. data/lib/tasker/authentication/none_authenticator.rb +26 -0
  491. data/lib/tasker/authorization/base_coordinator.rb +112 -0
  492. data/lib/tasker/authorization/errors.rb +26 -0
  493. data/lib/tasker/authorization/resource_constants.rb +73 -0
  494. data/lib/tasker/authorization/resource_registry.rb +136 -0
  495. data/lib/tasker/authorization.rb +75 -0
  496. data/lib/tasker/cache_capabilities.rb +131 -0
  497. data/lib/tasker/cache_strategy.rb +469 -0
  498. data/lib/tasker/concerns/authenticatable.rb +41 -0
  499. data/lib/tasker/concerns/authorizable.rb +204 -0
  500. data/lib/tasker/concerns/controller_authorizable.rb +124 -0
  501. data/lib/tasker/concerns/event_publisher.rb +716 -0
  502. data/lib/tasker/concerns/idempotent_state_transitions.rb +128 -0
  503. data/lib/tasker/concerns/state_machine_base.rb +218 -0
  504. data/lib/tasker/concerns/structured_logging.rb +387 -0
  505. data/lib/tasker/configuration.rb +325 -0
  506. data/lib/tasker/constants/event_definitions.rb +147 -0
  507. data/lib/tasker/constants/registry_events.rb +54 -0
  508. data/lib/tasker/constants.rb +417 -0
  509. data/lib/tasker/engine.rb +90 -0
  510. data/lib/tasker/errors.rb +90 -0
  511. data/lib/tasker/events/catalog.rb +432 -0
  512. data/lib/tasker/events/custom_registry.rb +175 -0
  513. data/lib/tasker/events/definition_loader.rb +199 -0
  514. data/lib/tasker/events/event_payload_builder.rb +461 -0
  515. data/lib/tasker/events/publisher.rb +149 -0
  516. data/lib/tasker/events/subscribers/base_subscriber.rb +601 -0
  517. data/lib/tasker/events/subscribers/metrics_subscriber.rb +120 -0
  518. data/lib/tasker/events/subscribers/telemetry_subscriber.rb +462 -0
  519. data/lib/tasker/events/subscription_loader.rb +161 -0
  520. data/lib/tasker/events.rb +37 -0
  521. data/lib/tasker/functions/function_based_analytics_metrics.rb +103 -0
  522. data/lib/tasker/functions/function_based_dependency_levels.rb +54 -0
  523. data/lib/tasker/functions/function_based_slowest_steps.rb +84 -0
  524. data/lib/tasker/functions/function_based_slowest_tasks.rb +84 -0
  525. data/lib/tasker/functions/function_based_step_readiness_status.rb +183 -0
  526. data/lib/tasker/functions/function_based_system_health_counts.rb +94 -0
  527. data/lib/tasker/functions/function_based_task_execution_context.rb +148 -0
  528. data/lib/tasker/functions/function_wrapper.rb +42 -0
  529. data/lib/tasker/functions.rb +12 -0
  530. data/lib/tasker/handler_factory.rb +327 -0
  531. data/lib/tasker/health/readiness_checker.rb +186 -0
  532. data/lib/tasker/health/status_checker.rb +203 -0
  533. data/lib/tasker/identity_strategy.rb +38 -0
  534. data/lib/tasker/logging/correlation_id_generator.rb +120 -0
  535. data/lib/tasker/orchestration/backoff_calculator.rb +184 -0
  536. data/lib/tasker/orchestration/connection_builder.rb +122 -0
  537. data/lib/tasker/orchestration/connection_pool_intelligence.rb +177 -0
  538. data/lib/tasker/orchestration/coordinator.rb +119 -0
  539. data/lib/tasker/orchestration/future_state_analyzer.rb +137 -0
  540. data/lib/tasker/orchestration/plugin_integration.rb +124 -0
  541. data/lib/tasker/orchestration/response_processor.rb +168 -0
  542. data/lib/tasker/orchestration/retry_header_parser.rb +78 -0
  543. data/lib/tasker/orchestration/step_executor.rb +941 -0
  544. data/lib/tasker/orchestration/step_sequence_factory.rb +67 -0
  545. data/lib/tasker/orchestration/task_finalizer.rb +564 -0
  546. data/lib/tasker/orchestration/task_initializer.rb +140 -0
  547. data/lib/tasker/orchestration/task_reenqueuer.rb +71 -0
  548. data/lib/tasker/orchestration/viable_step_discovery.rb +65 -0
  549. data/lib/tasker/orchestration/workflow_coordinator.rb +294 -0
  550. data/lib/tasker/orchestration.rb +45 -0
  551. data/lib/tasker/railtie.rb +9 -0
  552. data/lib/tasker/registry/base_registry.rb +177 -0
  553. data/lib/tasker/registry/event_publisher.rb +91 -0
  554. data/lib/tasker/registry/interface_validator.rb +140 -0
  555. data/lib/tasker/registry/statistics_collector.rb +381 -0
  556. data/lib/tasker/registry/subscriber_registry.rb +285 -0
  557. data/lib/tasker/registry.rb +22 -0
  558. data/lib/tasker/state_machine/step_state_machine.rb +508 -0
  559. data/lib/tasker/state_machine/task_state_machine.rb +192 -0
  560. data/lib/tasker/state_machine.rb +83 -0
  561. data/lib/tasker/step_handler/api.rb +410 -0
  562. data/lib/tasker/step_handler/base.rb +206 -0
  563. data/lib/tasker/task_builder.rb +432 -0
  564. data/lib/tasker/task_handler/class_methods.rb +327 -0
  565. data/lib/tasker/task_handler/instance_methods.rb +293 -0
  566. data/lib/tasker/task_handler/step_group.rb +182 -0
  567. data/lib/tasker/task_handler.rb +43 -0
  568. data/lib/tasker/telemetry/event_mapping.rb +126 -0
  569. data/lib/tasker/telemetry/event_router.rb +318 -0
  570. data/lib/tasker/telemetry/events/export_events.rb +38 -0
  571. data/lib/tasker/telemetry/export_coordinator.rb +497 -0
  572. data/lib/tasker/telemetry/intelligent_cache_manager.rb +508 -0
  573. data/lib/tasker/telemetry/log_backend.rb +224 -0
  574. data/lib/tasker/telemetry/metric_types.rb +416 -0
  575. data/lib/tasker/telemetry/metrics_backend.rb +1227 -0
  576. data/lib/tasker/telemetry/metrics_export_service.rb +392 -0
  577. data/lib/tasker/telemetry/plugin_registry.rb +333 -0
  578. data/lib/tasker/telemetry/plugins/base_exporter.rb +246 -0
  579. data/lib/tasker/telemetry/plugins/csv_exporter.rb +198 -0
  580. data/lib/tasker/telemetry/plugins/json_exporter.rb +141 -0
  581. data/lib/tasker/telemetry/prometheus_exporter.rb +249 -0
  582. data/lib/tasker/telemetry/trace_backend.rb +186 -0
  583. data/lib/tasker/telemetry.rb +59 -0
  584. data/lib/tasker/types/auth_config.rb +81 -0
  585. data/lib/tasker/types/backoff_config.rb +142 -0
  586. data/lib/tasker/types/cache_config.rb +257 -0
  587. data/lib/tasker/types/database_config.rb +39 -0
  588. data/lib/tasker/types/dependency_graph.rb +225 -0
  589. data/lib/tasker/types/dependency_graph_config.rb +149 -0
  590. data/lib/tasker/types/engine_config.rb +131 -0
  591. data/lib/tasker/types/execution_config.rb +289 -0
  592. data/lib/tasker/types/health_config.rb +84 -0
  593. data/lib/tasker/types/step_sequence.rb +24 -0
  594. data/lib/tasker/types/step_template.rb +63 -0
  595. data/lib/tasker/types/task_request.rb +60 -0
  596. data/lib/tasker/types/telemetry_config.rb +273 -0
  597. data/lib/tasker/types.rb +64 -0
  598. data/lib/tasker/version.rb +8 -0
  599. data/lib/tasker.rb +82 -0
  600. data/lib/tasks/tasker_tasks.rake +383 -0
  601. metadata +954 -0
@@ -0,0 +1,2254 @@
1
+ --
2
+ -- Name: calculate_dependency_levels(bigint); Type: FUNCTION; Schema: public; Owner: -
3
+ --
4
+
5
+ CREATE FUNCTION public.calculate_dependency_levels(input_task_id bigint) RETURNS TABLE(workflow_step_id bigint, dependency_level integer)
6
+ LANGUAGE plpgsql STABLE
7
+ AS $$
8
+ BEGIN
9
+ RETURN QUERY
10
+ WITH RECURSIVE dependency_levels AS (
11
+ -- Base case: Find root nodes (steps with no dependencies)
12
+ SELECT
13
+ ws.workflow_step_id,
14
+ 0 as level
15
+ FROM tasker_workflow_steps ws
16
+ WHERE ws.task_id = input_task_id
17
+ AND NOT EXISTS (
18
+ SELECT 1
19
+ FROM tasker_workflow_step_edges wse
20
+ WHERE wse.to_step_id = ws.workflow_step_id
21
+ )
22
+
23
+ UNION ALL
24
+
25
+ -- Recursive case: Find children of current level nodes
26
+ SELECT
27
+ wse.to_step_id as workflow_step_id,
28
+ dl.level + 1 as level
29
+ FROM dependency_levels dl
30
+ JOIN tasker_workflow_step_edges wse ON wse.from_step_id = dl.workflow_step_id
31
+ JOIN tasker_workflow_steps ws ON ws.workflow_step_id = wse.to_step_id
32
+ WHERE ws.task_id = input_task_id
33
+ )
34
+ SELECT
35
+ dl.workflow_step_id,
36
+ MAX(dl.level) as dependency_level -- Use MAX to handle multiple paths to same node
37
+ FROM dependency_levels dl
38
+ GROUP BY dl.workflow_step_id
39
+ ORDER BY dependency_level, workflow_step_id;
40
+ END;
41
+ $$;
42
+
43
+
44
+ --
45
+ -- Name: get_analytics_metrics_v01(timestamp with time zone); Type: FUNCTION; Schema: public; Owner: -
46
+ --
47
+
48
+ CREATE FUNCTION public.get_analytics_metrics_v01(since_timestamp timestamp with time zone DEFAULT NULL::timestamp with time zone) RETURNS TABLE(active_tasks_count bigint, total_namespaces_count bigint, unique_task_types_count bigint, system_health_score numeric, task_throughput bigint, completion_count bigint, error_count bigint, completion_rate numeric, error_rate numeric, avg_task_duration numeric, avg_step_duration numeric, step_throughput bigint, analysis_period_start timestamp with time zone, calculated_at timestamp with time zone)
49
+ LANGUAGE plpgsql STABLE
50
+ AS $$
51
+ DECLARE
52
+ analysis_start TIMESTAMPTZ;
53
+ BEGIN
54
+ -- Set analysis start time (default to 1 hour ago if not provided)
55
+ analysis_start := COALESCE(since_timestamp, NOW() - INTERVAL '1 hour');
56
+
57
+ RETURN QUERY
58
+ WITH active_tasks AS (
59
+ SELECT COUNT(DISTINCT t.task_id) as active_count
60
+ FROM tasker_tasks t
61
+ INNER JOIN tasker_workflow_steps ws ON ws.task_id = t.task_id
62
+ INNER JOIN tasker_workflow_step_transitions wst ON wst.workflow_step_id = ws.workflow_step_id
63
+ WHERE wst.most_recent = true
64
+ AND wst.to_state NOT IN ('complete', 'error', 'skipped', 'resolved_manually')
65
+ ),
66
+ namespace_summary AS (
67
+ SELECT COUNT(DISTINCT tn.name) as namespace_count
68
+ FROM tasker_task_namespaces tn
69
+ INNER JOIN tasker_named_tasks nt ON nt.task_namespace_id = tn.task_namespace_id
70
+ INNER JOIN tasker_tasks t ON t.named_task_id = nt.named_task_id
71
+ ),
72
+ task_type_summary AS (
73
+ SELECT COUNT(DISTINCT nt.name) as task_type_count
74
+ FROM tasker_named_tasks nt
75
+ INNER JOIN tasker_tasks t ON t.named_task_id = nt.named_task_id
76
+ ),
77
+ recent_task_health AS (
78
+ SELECT
79
+ COUNT(DISTINCT t.task_id) as total_recent_tasks,
80
+ COUNT(DISTINCT t.task_id) FILTER (
81
+ WHERE wst.to_state = 'complete' AND wst.most_recent = true
82
+ ) as completed_tasks,
83
+ COUNT(DISTINCT t.task_id) FILTER (
84
+ WHERE wst.to_state = 'error' AND wst.most_recent = true
85
+ ) as error_tasks
86
+ FROM tasker_tasks t
87
+ INNER JOIN tasker_workflow_steps ws ON ws.task_id = t.task_id
88
+ INNER JOIN tasker_workflow_step_transitions wst ON wst.workflow_step_id = ws.workflow_step_id
89
+ WHERE t.created_at > NOW() - INTERVAL '1 hour'
90
+ ),
91
+ period_metrics AS (
92
+ SELECT
93
+ COUNT(DISTINCT t.task_id) as throughput,
94
+ COUNT(DISTINCT t.task_id) FILTER (
95
+ WHERE completed_wst.to_state = 'complete' AND completed_wst.most_recent = true
96
+ ) as completions,
97
+ COUNT(DISTINCT t.task_id) FILTER (
98
+ WHERE error_wst.to_state = 'error' AND error_wst.most_recent = true
99
+ ) as errors,
100
+ COUNT(DISTINCT ws.workflow_step_id) as step_count,
101
+ AVG(
102
+ CASE
103
+ WHEN completed_wst.to_state = 'complete' AND completed_wst.most_recent = true
104
+ THEN EXTRACT(EPOCH FROM (completed_wst.created_at - t.created_at))
105
+ ELSE NULL
106
+ END
107
+ ) as avg_task_seconds,
108
+ AVG(
109
+ CASE
110
+ WHEN step_completed.to_state = 'complete' AND step_completed.most_recent = true
111
+ THEN EXTRACT(EPOCH FROM (step_completed.created_at - ws.created_at))
112
+ ELSE NULL
113
+ END
114
+ ) as avg_step_seconds
115
+ FROM tasker_tasks t
116
+ LEFT JOIN tasker_workflow_steps ws ON ws.task_id = t.task_id
117
+ LEFT JOIN tasker_workflow_step_transitions completed_wst ON completed_wst.workflow_step_id = ws.workflow_step_id
118
+ AND completed_wst.to_state = 'complete' AND completed_wst.most_recent = true
119
+ LEFT JOIN tasker_workflow_step_transitions error_wst ON error_wst.workflow_step_id = ws.workflow_step_id
120
+ AND error_wst.to_state = 'error' AND error_wst.most_recent = true
121
+ LEFT JOIN tasker_workflow_step_transitions step_completed ON step_completed.workflow_step_id = ws.workflow_step_id
122
+ AND step_completed.to_state = 'complete' AND step_completed.most_recent = true
123
+ WHERE t.created_at > analysis_start
124
+ )
125
+ SELECT
126
+ at.active_count,
127
+ ns.namespace_count,
128
+ tts.task_type_count,
129
+ CASE
130
+ WHEN (rth.completed_tasks + rth.error_tasks) > 0
131
+ THEN ROUND((rth.completed_tasks::NUMERIC / (rth.completed_tasks + rth.error_tasks)), 3)
132
+ ELSE 1.0
133
+ END as health_score,
134
+ pm.throughput,
135
+ pm.completions,
136
+ pm.errors,
137
+ CASE
138
+ WHEN pm.throughput > 0
139
+ THEN ROUND((pm.completions::NUMERIC / pm.throughput * 100), 2)
140
+ ELSE 0.0
141
+ END as completion_rate_pct,
142
+ CASE
143
+ WHEN pm.throughput > 0
144
+ THEN ROUND((pm.errors::NUMERIC / pm.throughput * 100), 2)
145
+ ELSE 0.0
146
+ END as error_rate_pct,
147
+ ROUND(COALESCE(pm.avg_task_seconds, 0), 3),
148
+ ROUND(COALESCE(pm.avg_step_seconds, 0), 3),
149
+ pm.step_count,
150
+ analysis_start,
151
+ NOW()
152
+ FROM active_tasks at
153
+ CROSS JOIN namespace_summary ns
154
+ CROSS JOIN task_type_summary tts
155
+ CROSS JOIN recent_task_health rth
156
+ CROSS JOIN period_metrics pm;
157
+ END;
158
+ $$;
159
+
160
+
161
+ --
162
+ -- Name: get_slowest_steps_v01(timestamp with time zone, integer, text, text, text); Type: FUNCTION; Schema: public; Owner: -
163
+ --
164
+
165
+ CREATE FUNCTION public.get_slowest_steps_v01(since_timestamp timestamp with time zone DEFAULT NULL::timestamp with time zone, limit_count integer DEFAULT 10, namespace_filter text DEFAULT NULL::text, task_name_filter text DEFAULT NULL::text, version_filter text DEFAULT NULL::text) RETURNS TABLE(workflow_step_id bigint, task_id bigint, step_name character varying, task_name character varying, namespace_name character varying, version character varying, duration_seconds numeric, attempts integer, created_at timestamp with time zone, completed_at timestamp with time zone, retryable boolean, step_status character varying)
166
+ LANGUAGE plpgsql STABLE
167
+ AS $$
168
+ DECLARE
169
+ analysis_start TIMESTAMPTZ;
170
+ BEGIN
171
+ -- Set analysis start time (default to 24 hours ago if not provided)
172
+ analysis_start := COALESCE(since_timestamp, NOW() - INTERVAL '24 hours');
173
+
174
+ RETURN QUERY
175
+ WITH step_durations AS (
176
+ SELECT
177
+ ws.workflow_step_id,
178
+ ws.task_id,
179
+ ns.name as step_name,
180
+ nt.name as task_name,
181
+ tn.name as namespace_name,
182
+ nt.version,
183
+ ws.created_at,
184
+ ws.attempts,
185
+ ws.retryable,
186
+ -- Find the completion time
187
+ wst.created_at as completion_time,
188
+ wst.to_state as final_state,
189
+ -- Calculate duration from step creation to completion
190
+ EXTRACT(EPOCH FROM (wst.created_at - ws.created_at)) as duration_seconds
191
+ FROM tasker_workflow_steps ws
192
+ INNER JOIN tasker_named_steps ns ON ns.named_step_id = ws.named_step_id
193
+ INNER JOIN tasker_tasks t ON t.task_id = ws.task_id
194
+ INNER JOIN tasker_named_tasks nt ON nt.named_task_id = t.named_task_id
195
+ INNER JOIN tasker_task_namespaces tn ON tn.task_namespace_id = nt.task_namespace_id
196
+ INNER JOIN tasker_workflow_step_transitions wst ON wst.workflow_step_id = ws.workflow_step_id
197
+ WHERE ws.created_at > analysis_start
198
+ AND wst.most_recent = true
199
+ AND wst.to_state = 'complete' -- Only include completed steps for accurate duration
200
+ AND (namespace_filter IS NULL OR tn.name = namespace_filter)
201
+ AND (task_name_filter IS NULL OR nt.name = task_name_filter)
202
+ AND (version_filter IS NULL OR nt.version = version_filter)
203
+ )
204
+ SELECT
205
+ sd.workflow_step_id,
206
+ sd.task_id,
207
+ sd.step_name,
208
+ sd.task_name,
209
+ sd.namespace_name,
210
+ sd.version,
211
+ ROUND(sd.duration_seconds, 3),
212
+ sd.attempts,
213
+ sd.created_at,
214
+ sd.completion_time,
215
+ sd.retryable,
216
+ sd.final_state
217
+ FROM step_durations sd
218
+ WHERE sd.duration_seconds IS NOT NULL
219
+ AND sd.duration_seconds > 0 -- Filter out negative durations (data integrity check)
220
+ ORDER BY sd.duration_seconds DESC
221
+ LIMIT limit_count;
222
+ END;
223
+ $$;
224
+
225
+
226
+ --
227
+ -- Name: get_slowest_tasks_v01(timestamp with time zone, integer, text, text, text); Type: FUNCTION; Schema: public; Owner: -
228
+ --
229
+
230
+ CREATE FUNCTION public.get_slowest_tasks_v01(since_timestamp timestamp with time zone DEFAULT NULL::timestamp with time zone, limit_count integer DEFAULT 10, namespace_filter text DEFAULT NULL::text, task_name_filter text DEFAULT NULL::text, version_filter text DEFAULT NULL::text) RETURNS TABLE(task_id bigint, task_name character varying, namespace_name character varying, version character varying, duration_seconds numeric, step_count bigint, completed_steps bigint, error_steps bigint, created_at timestamp with time zone, completed_at timestamp with time zone, initiator character varying, source_system character varying)
231
+ LANGUAGE plpgsql STABLE
232
+ AS $$
233
+ DECLARE
234
+ analysis_start TIMESTAMPTZ;
235
+ BEGIN
236
+ -- Set analysis start time (default to 24 hours ago if not provided)
237
+ analysis_start := COALESCE(since_timestamp, NOW() - INTERVAL '24 hours');
238
+
239
+ RETURN QUERY
240
+ WITH task_durations AS (
241
+ SELECT
242
+ t.task_id,
243
+ nt.name as task_name,
244
+ tn.name as namespace_name,
245
+ nt.version,
246
+ t.created_at,
247
+ t.initiator,
248
+ t.source_system,
249
+ -- Find the latest completion time across all steps
250
+ MAX(wst.created_at) FILTER (
251
+ WHERE wst.to_state IN ('complete', 'error') AND wst.most_recent = true
252
+ ) as latest_completion,
253
+ -- Calculate duration from task creation to latest step completion
254
+ EXTRACT(EPOCH FROM (
255
+ MAX(wst.created_at) FILTER (
256
+ WHERE wst.to_state IN ('complete', 'error') AND wst.most_recent = true
257
+ ) - t.created_at
258
+ )) as duration_seconds,
259
+ COUNT(ws.workflow_step_id) as total_steps,
260
+ COUNT(ws.workflow_step_id) FILTER (
261
+ WHERE complete_wst.to_state = 'complete' AND complete_wst.most_recent = true
262
+ ) as completed_step_count,
263
+ COUNT(ws.workflow_step_id) FILTER (
264
+ WHERE error_wst.to_state = 'error' AND error_wst.most_recent = true
265
+ ) as error_step_count
266
+ FROM tasker_tasks t
267
+ INNER JOIN tasker_named_tasks nt ON nt.named_task_id = t.named_task_id
268
+ INNER JOIN tasker_task_namespaces tn ON tn.task_namespace_id = nt.task_namespace_id
269
+ INNER JOIN tasker_workflow_steps ws ON ws.task_id = t.task_id
270
+ LEFT JOIN tasker_workflow_step_transitions wst ON wst.workflow_step_id = ws.workflow_step_id
271
+ LEFT JOIN tasker_workflow_step_transitions complete_wst ON complete_wst.workflow_step_id = ws.workflow_step_id
272
+ AND complete_wst.to_state = 'complete' AND complete_wst.most_recent = true
273
+ LEFT JOIN tasker_workflow_step_transitions error_wst ON error_wst.workflow_step_id = ws.workflow_step_id
274
+ AND error_wst.to_state = 'error' AND error_wst.most_recent = true
275
+ WHERE t.created_at > analysis_start
276
+ AND (namespace_filter IS NULL OR tn.name = namespace_filter)
277
+ AND (task_name_filter IS NULL OR nt.name = task_name_filter)
278
+ AND (version_filter IS NULL OR nt.version = version_filter)
279
+ GROUP BY t.task_id, nt.name, tn.name, nt.version, t.created_at, t.initiator, t.source_system
280
+ HAVING MAX(wst.created_at) FILTER (
281
+ WHERE wst.to_state IN ('complete', 'error') AND wst.most_recent = true
282
+ ) IS NOT NULL -- Only include tasks that have at least one completed/failed step
283
+ )
284
+ SELECT
285
+ td.task_id,
286
+ td.task_name,
287
+ td.namespace_name,
288
+ td.version,
289
+ ROUND(td.duration_seconds, 3),
290
+ td.total_steps,
291
+ td.completed_step_count,
292
+ td.error_step_count,
293
+ td.created_at,
294
+ td.latest_completion,
295
+ td.initiator,
296
+ td.source_system
297
+ FROM task_durations td
298
+ WHERE td.duration_seconds IS NOT NULL
299
+ ORDER BY td.duration_seconds DESC
300
+ LIMIT limit_count;
301
+ END;
302
+ $$;
303
+
304
+
305
+ --
306
+ -- Name: get_step_readiness_status(bigint, bigint[]); Type: FUNCTION; Schema: public; Owner: -
307
+ --
308
+
309
+ CREATE FUNCTION public.get_step_readiness_status(input_task_id bigint, step_ids bigint[] DEFAULT NULL::bigint[]) RETURNS TABLE(workflow_step_id bigint, task_id bigint, named_step_id integer, name text, current_state text, dependencies_satisfied boolean, retry_eligible boolean, ready_for_execution boolean, last_failure_at timestamp without time zone, next_retry_at timestamp without time zone, total_parents integer, completed_parents integer, attempts integer, retry_limit integer, backoff_request_seconds integer, last_attempted_at timestamp without time zone)
310
+ LANGUAGE plpgsql STABLE
311
+ AS $$
312
+ BEGIN
313
+ RETURN QUERY
314
+ SELECT
315
+ ws.workflow_step_id,
316
+ ws.task_id,
317
+ ws.named_step_id,
318
+ ns.name::TEXT,
319
+
320
+ -- Current State Information (optimized using most_recent flag)
321
+ COALESCE(current_state.to_state, 'pending')::TEXT as current_state,
322
+
323
+ -- Dependency Analysis (calculated from direct joins)
324
+ CASE
325
+ WHEN dep_edges.to_step_id IS NULL THEN true -- Root steps (no parents)
326
+ WHEN COUNT(dep_edges.from_step_id) = 0 THEN true -- Steps with zero dependencies
327
+ WHEN COUNT(CASE WHEN parent_states.to_state IN ('complete', 'resolved_manually') THEN 1 END) = COUNT(dep_edges.from_step_id) THEN true
328
+ ELSE false
329
+ END as dependencies_satisfied,
330
+
331
+ -- Simplified Retry & Backoff Analysis
332
+ CASE
333
+ WHEN ws.attempts >= COALESCE(ws.retry_limit, 3) THEN false
334
+ WHEN ws.attempts > 0 AND COALESCE(ws.retryable, true) = false THEN false
335
+ WHEN last_failure.created_at IS NULL THEN true
336
+ WHEN ws.backoff_request_seconds IS NOT NULL AND ws.last_attempted_at IS NOT NULL THEN
337
+ ws.last_attempted_at + (ws.backoff_request_seconds * interval '1 second') <= NOW()
338
+ WHEN last_failure.created_at IS NOT NULL THEN
339
+ last_failure.created_at + (
340
+ LEAST(power(2, COALESCE(ws.attempts, 1)) * interval '1 second', interval '30 seconds')
341
+ ) <= NOW()
342
+ ELSE true
343
+ END as retry_eligible,
344
+
345
+ -- Simplified Final Readiness Calculation
346
+ CASE
347
+ WHEN COALESCE(current_state.to_state, 'pending') IN ('pending', 'error')
348
+ AND (ws.processed = false OR ws.processed IS NULL) -- CRITICAL: Only unprocessed steps can be ready
349
+ AND (dep_edges.to_step_id IS NULL OR
350
+ COUNT(dep_edges.from_step_id) = 0 OR
351
+ COUNT(CASE WHEN parent_states.to_state IN ('complete', 'resolved_manually') THEN 1 END) = COUNT(dep_edges.from_step_id))
352
+ AND (ws.attempts < COALESCE(ws.retry_limit, 3))
353
+ AND (COALESCE(ws.retryable, true) = true)
354
+ AND (ws.in_process = false OR ws.in_process IS NULL)
355
+ AND (
356
+ -- Check explicit backoff timing (most restrictive)
357
+ -- If backoff is set, the backoff period must have expired
358
+ CASE
359
+ WHEN ws.backoff_request_seconds IS NOT NULL AND ws.last_attempted_at IS NOT NULL THEN
360
+ ws.last_attempted_at + (ws.backoff_request_seconds * interval '1 second') <= NOW()
361
+ ELSE true -- No explicit backoff set
362
+ END
363
+ AND
364
+ -- Then check failure-based backoff
365
+ (last_failure.created_at IS NULL OR
366
+ last_failure.created_at + (LEAST(power(2, COALESCE(ws.attempts, 1)) * interval '1 second', interval '30 seconds')) <= NOW())
367
+ )
368
+ THEN true
369
+ ELSE false
370
+ END as ready_for_execution,
371
+
372
+ -- Timing Information
373
+ last_failure.created_at as last_failure_at,
374
+ CASE
375
+ WHEN ws.backoff_request_seconds IS NOT NULL AND ws.last_attempted_at IS NOT NULL THEN
376
+ ws.last_attempted_at + (ws.backoff_request_seconds * interval '1 second')
377
+ WHEN last_failure.created_at IS NOT NULL THEN
378
+ last_failure.created_at + (LEAST(power(2, COALESCE(ws.attempts, 1)) * interval '1 second', interval '30 seconds'))
379
+ ELSE NULL
380
+ END as next_retry_at,
381
+
382
+ -- Dependency Context (calculated from joins)
383
+ COALESCE(COUNT(dep_edges.from_step_id), 0)::INTEGER as total_parents,
384
+ COALESCE(COUNT(CASE WHEN parent_states.to_state IN ('complete', 'resolved_manually') THEN 1 END), 0)::INTEGER as completed_parents,
385
+
386
+ -- Retry Context
387
+ ws.attempts,
388
+ COALESCE(ws.retry_limit, 3) as retry_limit,
389
+ ws.backoff_request_seconds,
390
+ ws.last_attempted_at
391
+
392
+ FROM tasker_workflow_steps ws
393
+ JOIN tasker_named_steps ns ON ns.named_step_id = ws.named_step_id
394
+
395
+ -- OPTIMIZED: Current State using most_recent flag instead of DISTINCT ON
396
+ LEFT JOIN tasker_workflow_step_transitions current_state
397
+ ON current_state.workflow_step_id = ws.workflow_step_id
398
+ AND current_state.most_recent = true
399
+
400
+ -- OPTIMIZED: Dependency check using direct joins (no subquery)
401
+ LEFT JOIN tasker_workflow_step_edges dep_edges
402
+ ON dep_edges.to_step_id = ws.workflow_step_id
403
+ LEFT JOIN tasker_workflow_step_transitions parent_states
404
+ ON parent_states.workflow_step_id = dep_edges.from_step_id
405
+ AND parent_states.most_recent = true
406
+
407
+ -- OPTIMIZED: Last failure using index-optimized approach
408
+ LEFT JOIN tasker_workflow_step_transitions last_failure
409
+ ON last_failure.workflow_step_id = ws.workflow_step_id
410
+ AND last_failure.to_state = 'error'
411
+ AND last_failure.most_recent = true
412
+
413
+ -- KEY PERFORMANCE IMPROVEMENT: Filter by task first, then optionally by step IDs
414
+ -- CRITICAL FIX: Include ALL steps for task execution context calculation
415
+ -- Only filter by processed status when specifically querying for ready steps
416
+ WHERE ws.task_id = input_task_id
417
+ AND (step_ids IS NULL OR ws.workflow_step_id = ANY(step_ids))
418
+
419
+ GROUP BY
420
+ ws.workflow_step_id, ws.task_id, ws.named_step_id, ns.name,
421
+ current_state.to_state, last_failure.created_at,
422
+ ws.attempts, ws.retry_limit, ws.backoff_request_seconds, ws.last_attempted_at,
423
+ ws.in_process, ws.processed, ws.retryable, dep_edges.to_step_id,
424
+ current_state.workflow_step_id, last_failure.workflow_step_id;
425
+ END;
426
+ $$;
427
+
428
+
429
+ --
430
+ -- Name: get_step_readiness_status_batch(bigint[]); Type: FUNCTION; Schema: public; Owner: -
431
+ --
432
+
433
+ CREATE FUNCTION public.get_step_readiness_status_batch(input_task_ids bigint[]) RETURNS TABLE(workflow_step_id bigint, task_id bigint, named_step_id integer, name text, current_state text, dependencies_satisfied boolean, retry_eligible boolean, ready_for_execution boolean, last_failure_at timestamp without time zone, next_retry_at timestamp without time zone, total_parents integer, completed_parents integer, attempts integer, retry_limit integer, backoff_request_seconds integer, last_attempted_at timestamp without time zone)
434
+ LANGUAGE plpgsql STABLE
435
+ AS $$
436
+ BEGIN
437
+ RETURN QUERY
438
+ SELECT
439
+ ws.workflow_step_id,
440
+ ws.task_id,
441
+ ws.named_step_id,
442
+ ns.name::TEXT,
443
+
444
+ -- Current State Information (optimized using most_recent flag)
445
+ COALESCE(current_state.to_state, 'pending')::TEXT as current_state,
446
+
447
+ -- Dependency Analysis (calculated from direct joins)
448
+ CASE
449
+ WHEN dep_edges.to_step_id IS NULL THEN true -- Root steps (no parents)
450
+ WHEN COUNT(dep_edges.from_step_id) = 0 THEN true -- Steps with zero dependencies
451
+ WHEN COUNT(CASE WHEN parent_states.to_state IN ('complete', 'resolved_manually') THEN 1 END) = COUNT(dep_edges.from_step_id) THEN true
452
+ ELSE false
453
+ END as dependencies_satisfied,
454
+
455
+ -- Simplified Retry & Backoff Analysis
456
+ CASE
457
+ WHEN ws.attempts >= COALESCE(ws.retry_limit, 3) THEN false
458
+ WHEN ws.attempts > 0 AND COALESCE(ws.retryable, true) = false THEN false
459
+ WHEN last_failure.created_at IS NULL THEN true
460
+ WHEN ws.backoff_request_seconds IS NOT NULL AND ws.last_attempted_at IS NOT NULL THEN
461
+ ws.last_attempted_at + (ws.backoff_request_seconds * interval '1 second') <= NOW()
462
+ WHEN last_failure.created_at IS NOT NULL THEN
463
+ last_failure.created_at + (
464
+ LEAST(power(2, COALESCE(ws.attempts, 1)) * interval '1 second', interval '30 seconds')
465
+ ) <= NOW()
466
+ ELSE true
467
+ END as retry_eligible,
468
+
469
+ -- Simplified Final Readiness Calculation
470
+ CASE
471
+ WHEN COALESCE(current_state.to_state, 'pending') IN ('pending', 'error')
472
+ AND (ws.processed = false OR ws.processed IS NULL) -- CRITICAL: Only unprocessed steps can be ready
473
+ AND (dep_edges.to_step_id IS NULL OR
474
+ COUNT(dep_edges.from_step_id) = 0 OR
475
+ COUNT(CASE WHEN parent_states.to_state IN ('complete', 'resolved_manually') THEN 1 END) = COUNT(dep_edges.from_step_id))
476
+ AND (ws.attempts < COALESCE(ws.retry_limit, 3))
477
+ AND (COALESCE(ws.retryable, true) = true)
478
+ AND (ws.in_process = false OR ws.in_process IS NULL)
479
+ AND (
480
+ -- Check explicit backoff timing (most restrictive)
481
+ -- If backoff is set, the backoff period must have expired
482
+ CASE
483
+ WHEN ws.backoff_request_seconds IS NOT NULL AND ws.last_attempted_at IS NOT NULL THEN
484
+ ws.last_attempted_at + (ws.backoff_request_seconds * interval '1 second') <= NOW()
485
+ ELSE true -- No explicit backoff set
486
+ END
487
+ AND
488
+ -- Then check failure-based backoff
489
+ (last_failure.created_at IS NULL OR
490
+ last_failure.created_at + (LEAST(power(2, COALESCE(ws.attempts, 1)) * interval '1 second', interval '30 seconds')) <= NOW())
491
+ )
492
+ THEN true
493
+ ELSE false
494
+ END as ready_for_execution,
495
+
496
+ -- Timing Information
497
+ last_failure.created_at as last_failure_at,
498
+ CASE
499
+ WHEN ws.backoff_request_seconds IS NOT NULL AND ws.last_attempted_at IS NOT NULL THEN
500
+ ws.last_attempted_at + (ws.backoff_request_seconds * interval '1 second')
501
+ WHEN last_failure.created_at IS NOT NULL THEN
502
+ last_failure.created_at + (LEAST(power(2, COALESCE(ws.attempts, 1)) * interval '1 second', interval '30 seconds'))
503
+ ELSE NULL
504
+ END as next_retry_at,
505
+
506
+ -- Dependency Context (calculated from joins)
507
+ COALESCE(COUNT(dep_edges.from_step_id), 0)::INTEGER as total_parents,
508
+ COALESCE(COUNT(CASE WHEN parent_states.to_state IN ('complete', 'resolved_manually') THEN 1 END), 0)::INTEGER as completed_parents,
509
+
510
+ -- Retry Context
511
+ ws.attempts,
512
+ COALESCE(ws.retry_limit, 3) as retry_limit,
513
+ ws.backoff_request_seconds,
514
+ ws.last_attempted_at
515
+
516
+ FROM tasker_workflow_steps ws
517
+ JOIN tasker_named_steps ns ON ns.named_step_id = ws.named_step_id
518
+
519
+ -- OPTIMIZED: Current State using most_recent flag instead of DISTINCT ON
520
+ LEFT JOIN tasker_workflow_step_transitions current_state
521
+ ON current_state.workflow_step_id = ws.workflow_step_id
522
+ AND current_state.most_recent = true
523
+
524
+ -- OPTIMIZED: Dependency check using direct joins (no subquery)
525
+ LEFT JOIN tasker_workflow_step_edges dep_edges
526
+ ON dep_edges.to_step_id = ws.workflow_step_id
527
+ LEFT JOIN tasker_workflow_step_transitions parent_states
528
+ ON parent_states.workflow_step_id = dep_edges.from_step_id
529
+ AND parent_states.most_recent = true
530
+
531
+ -- OPTIMIZED: Last failure using index-optimized approach
532
+ LEFT JOIN tasker_workflow_step_transitions last_failure
533
+ ON last_failure.workflow_step_id = ws.workflow_step_id
534
+ AND last_failure.to_state = 'error'
535
+ AND last_failure.most_recent = true
536
+
537
+ -- KEY PERFORMANCE IMPROVEMENT: Filter by multiple tasks at once
538
+ -- CRITICAL FIX: Include ALL steps for task execution context calculation
539
+ -- Only filter by processed status when specifically querying for ready steps
540
+ WHERE ws.task_id = ANY(input_task_ids)
541
+
542
+ GROUP BY
543
+ ws.workflow_step_id, ws.task_id, ws.named_step_id, ns.name,
544
+ current_state.to_state, last_failure.created_at,
545
+ ws.attempts, ws.retry_limit, ws.backoff_request_seconds, ws.last_attempted_at,
546
+ ws.in_process, ws.processed, ws.retryable, dep_edges.to_step_id
547
+
548
+ -- IMPORTANT: Order by task_id, then workflow_step_id for consistent grouping
549
+ ORDER BY ws.task_id, ws.workflow_step_id;
550
+ END;
551
+ $$;
552
+
553
+
554
+ --
555
+ -- Name: get_system_health_counts_v01(); Type: FUNCTION; Schema: public; Owner: -
556
+ --
557
+
558
+ CREATE FUNCTION public.get_system_health_counts_v01() RETURNS TABLE(total_tasks bigint, pending_tasks bigint, in_progress_tasks bigint, complete_tasks bigint, error_tasks bigint, cancelled_tasks bigint, total_steps bigint, pending_steps bigint, in_progress_steps bigint, complete_steps bigint, error_steps bigint, retryable_error_steps bigint, exhausted_retry_steps bigint, in_backoff_steps bigint, active_connections bigint, max_connections bigint)
559
+ LANGUAGE plpgsql STABLE
560
+ AS $$
561
+ BEGIN
562
+ RETURN QUERY
563
+ WITH task_counts AS (
564
+ SELECT
565
+ COUNT(*) as total_tasks,
566
+ COUNT(*) FILTER (WHERE task_state.to_state = 'pending') as pending_tasks,
567
+ COUNT(*) FILTER (WHERE task_state.to_state = 'in_progress') as in_progress_tasks,
568
+ COUNT(*) FILTER (WHERE task_state.to_state = 'complete') as complete_tasks,
569
+ COUNT(*) FILTER (WHERE task_state.to_state = 'error') as error_tasks,
570
+ COUNT(*) FILTER (WHERE task_state.to_state = 'cancelled') as cancelled_tasks
571
+ FROM tasker_tasks t
572
+ LEFT JOIN tasker_task_transitions task_state ON task_state.task_id = t.task_id
573
+ AND task_state.most_recent = true
574
+ ),
575
+ step_counts AS (
576
+ SELECT
577
+ COUNT(*) as total_steps,
578
+ COUNT(*) FILTER (WHERE step_state.to_state = 'pending') as pending_steps,
579
+ COUNT(*) FILTER (WHERE step_state.to_state = 'in_progress') as in_progress_steps,
580
+ COUNT(*) FILTER (WHERE step_state.to_state = 'complete') as complete_steps,
581
+ COUNT(*) FILTER (WHERE step_state.to_state = 'error') as error_steps,
582
+
583
+ -- Retry-specific logic - retryable errors
584
+ COUNT(*) FILTER (
585
+ WHERE step_state.to_state = 'error'
586
+ AND ws.attempts < ws.retry_limit
587
+ AND COALESCE(ws.retryable, true) = true
588
+ ) as retryable_error_steps,
589
+
590
+ -- Exhausted retries
591
+ COUNT(*) FILTER (
592
+ WHERE step_state.to_state = 'error'
593
+ AND ws.attempts >= ws.retry_limit
594
+ ) as exhausted_retry_steps,
595
+
596
+ -- In backoff (error state but not exhausted retries and has last_attempted_at)
597
+ COUNT(*) FILTER (
598
+ WHERE step_state.to_state = 'error'
599
+ AND ws.attempts < ws.retry_limit
600
+ AND COALESCE(ws.retryable, true) = true
601
+ AND ws.last_attempted_at IS NOT NULL
602
+ ) as in_backoff_steps
603
+
604
+ FROM tasker_workflow_steps ws
605
+ LEFT JOIN tasker_workflow_step_transitions step_state ON step_state.workflow_step_id = ws.workflow_step_id
606
+ AND step_state.most_recent = true
607
+ ),
608
+ connection_info AS (
609
+ SELECT
610
+ COUNT(*) as active_connections,
611
+ COALESCE((SELECT setting::BIGINT FROM pg_settings WHERE name = 'max_connections'), 0) as max_connections
612
+ FROM pg_stat_activity
613
+ WHERE datname = current_database()
614
+ AND state = 'active'
615
+ )
616
+ SELECT
617
+ tc.total_tasks,
618
+ tc.pending_tasks,
619
+ tc.in_progress_tasks,
620
+ tc.complete_tasks,
621
+ tc.error_tasks,
622
+ tc.cancelled_tasks,
623
+ sc.total_steps,
624
+ sc.pending_steps,
625
+ sc.in_progress_steps,
626
+ sc.complete_steps,
627
+ sc.error_steps,
628
+ sc.retryable_error_steps,
629
+ sc.exhausted_retry_steps,
630
+ sc.in_backoff_steps,
631
+ ci.active_connections,
632
+ ci.max_connections
633
+ FROM task_counts tc
634
+ CROSS JOIN step_counts sc
635
+ CROSS JOIN connection_info ci;
636
+ END;
637
+ $$;
638
+
639
+
640
+ --
641
+ -- Name: get_task_execution_context(bigint); Type: FUNCTION; Schema: public; Owner: -
642
+ --
643
+
644
+ CREATE FUNCTION public.get_task_execution_context(input_task_id bigint) RETURNS TABLE(task_id bigint, named_task_id integer, status text, total_steps bigint, pending_steps bigint, in_progress_steps bigint, completed_steps bigint, failed_steps bigint, ready_steps bigint, execution_status text, recommended_action text, completion_percentage numeric, health_status text)
645
+ LANGUAGE plpgsql STABLE
646
+ AS $$
647
+ BEGIN
648
+ -- Use the step readiness function to get step data, then aggregate
649
+ -- The step readiness function handles the case where no steps exist
650
+ RETURN QUERY
651
+ WITH step_data AS (
652
+ SELECT * FROM get_step_readiness_status(input_task_id, NULL)
653
+ ),
654
+ task_info AS (
655
+ SELECT
656
+ t.task_id,
657
+ t.named_task_id,
658
+ COALESCE(task_state.to_state, 'pending')::TEXT as current_status
659
+ FROM tasker_tasks t
660
+ LEFT JOIN tasker_task_transitions task_state
661
+ ON task_state.task_id = t.task_id
662
+ AND task_state.most_recent = true
663
+ WHERE t.task_id = input_task_id
664
+ ),
665
+ aggregated_stats AS (
666
+ SELECT
667
+ COUNT(*) as total_steps,
668
+ COUNT(CASE WHEN sd.current_state = 'pending' THEN 1 END) as pending_steps,
669
+ COUNT(CASE WHEN sd.current_state = 'in_progress' THEN 1 END) as in_progress_steps,
670
+ COUNT(CASE WHEN sd.current_state IN ('complete', 'resolved_manually') THEN 1 END) as completed_steps,
671
+ COUNT(CASE WHEN sd.current_state = 'error' THEN 1 END) as failed_steps,
672
+ COUNT(CASE WHEN sd.ready_for_execution = true THEN 1 END) as ready_steps,
673
+ -- Count PERMANENTLY blocked failures (exhausted retries OR explicitly marked as not retryable)
674
+ COUNT(CASE WHEN sd.current_state = 'error'
675
+ AND (sd.attempts >= sd.retry_limit) THEN 1 END) as permanently_blocked_steps
676
+ FROM step_data sd
677
+ )
678
+ SELECT
679
+ ti.task_id,
680
+ ti.named_task_id,
681
+ ti.current_status as status,
682
+
683
+ -- Step Statistics
684
+ COALESCE(ast.total_steps, 0) as total_steps,
685
+ COALESCE(ast.pending_steps, 0) as pending_steps,
686
+ COALESCE(ast.in_progress_steps, 0) as in_progress_steps,
687
+ COALESCE(ast.completed_steps, 0) as completed_steps,
688
+ COALESCE(ast.failed_steps, 0) as failed_steps,
689
+ COALESCE(ast.ready_steps, 0) as ready_steps,
690
+
691
+ -- FIXED: Execution State Logic
692
+ CASE
693
+ WHEN COALESCE(ast.ready_steps, 0) > 0 THEN 'has_ready_steps'
694
+ WHEN COALESCE(ast.in_progress_steps, 0) > 0 THEN 'processing'
695
+ -- OLD BUG: WHEN COALESCE(ast.failed_steps, 0) > 0 AND COALESCE(ast.ready_steps, 0) = 0 THEN 'blocked_by_failures'
696
+ -- NEW FIX: Only blocked if failed steps are NOT retry-eligible
697
+ WHEN COALESCE(ast.permanently_blocked_steps, 0) > 0 AND COALESCE(ast.ready_steps, 0) = 0 THEN 'blocked_by_failures'
698
+ WHEN COALESCE(ast.completed_steps, 0) = COALESCE(ast.total_steps, 0) AND COALESCE(ast.total_steps, 0) > 0 THEN 'all_complete'
699
+ ELSE 'waiting_for_dependencies'
700
+ END as execution_status,
701
+
702
+ -- FIXED: Recommended Action Logic
703
+ CASE
704
+ WHEN COALESCE(ast.ready_steps, 0) > 0 THEN 'execute_ready_steps'
705
+ WHEN COALESCE(ast.in_progress_steps, 0) > 0 THEN 'wait_for_completion'
706
+ -- OLD BUG: WHEN COALESCE(ast.failed_steps, 0) > 0 AND COALESCE(ast.ready_steps, 0) = 0 THEN 'handle_failures'
707
+ -- NEW FIX: Only handle failures if they're truly blocked
708
+ WHEN COALESCE(ast.permanently_blocked_steps, 0) > 0 AND COALESCE(ast.ready_steps, 0) = 0 THEN 'handle_failures'
709
+ WHEN COALESCE(ast.completed_steps, 0) = COALESCE(ast.total_steps, 0) AND COALESCE(ast.total_steps, 0) > 0 THEN 'finalize_task'
710
+ ELSE 'wait_for_dependencies'
711
+ END as recommended_action,
712
+
713
+ -- Progress Metrics
714
+ CASE
715
+ WHEN COALESCE(ast.total_steps, 0) = 0 THEN 0.0
716
+ ELSE ROUND((COALESCE(ast.completed_steps, 0)::decimal / COALESCE(ast.total_steps, 1)::decimal) * 100, 2)
717
+ END as completion_percentage,
718
+
719
+ -- FIXED: Health Status Logic
720
+ CASE
721
+ WHEN COALESCE(ast.failed_steps, 0) = 0 THEN 'healthy'
722
+ WHEN COALESCE(ast.failed_steps, 0) > 0 AND COALESCE(ast.ready_steps, 0) > 0 THEN 'recovering'
723
+ -- NEW FIX: Only blocked if failures are truly not retry-eligible
724
+ WHEN COALESCE(ast.permanently_blocked_steps, 0) > 0 AND COALESCE(ast.ready_steps, 0) = 0 THEN 'blocked'
725
+ -- NEW: Waiting state for retry-eligible failures with backoff
726
+ WHEN COALESCE(ast.failed_steps, 0) > 0 AND COALESCE(ast.permanently_blocked_steps, 0) = 0 AND COALESCE(ast.ready_steps, 0) = 0 THEN 'recovering'
727
+ ELSE 'unknown'
728
+ END as health_status
729
+
730
+ FROM task_info ti
731
+ CROSS JOIN aggregated_stats ast;
732
+ END;
733
+ $$;
734
+
735
+
736
+ --
737
+ -- Name: get_task_execution_contexts_batch(bigint[]); Type: FUNCTION; Schema: public; Owner: -
738
+ --
739
+
740
+ CREATE FUNCTION public.get_task_execution_contexts_batch(input_task_ids bigint[]) RETURNS TABLE(task_id bigint, named_task_id integer, status text, total_steps bigint, pending_steps bigint, in_progress_steps bigint, completed_steps bigint, failed_steps bigint, ready_steps bigint, execution_status text, recommended_action text, completion_percentage numeric, health_status text)
741
+ LANGUAGE plpgsql STABLE
742
+ AS $$
743
+ BEGIN
744
+ RETURN QUERY
745
+ WITH step_data AS (
746
+ -- Get step readiness data for all tasks at once using batch function
747
+ SELECT * FROM get_step_readiness_status_batch(input_task_ids)
748
+ ),
749
+ task_info AS (
750
+ SELECT
751
+ t.task_id,
752
+ t.named_task_id,
753
+ COALESCE(task_state.to_state, 'pending')::TEXT as current_status
754
+ FROM unnest(input_task_ids) AS task_list(task_id)
755
+ JOIN tasker_tasks t ON t.task_id = task_list.task_id
756
+ LEFT JOIN tasker_task_transitions task_state
757
+ ON task_state.task_id = t.task_id
758
+ AND task_state.most_recent = true
759
+ ),
760
+ aggregated_stats AS (
761
+ SELECT
762
+ sd.task_id,
763
+ COUNT(*) as total_steps,
764
+ COUNT(CASE WHEN sd.current_state = 'pending' THEN 1 END) as pending_steps,
765
+ COUNT(CASE WHEN sd.current_state = 'in_progress' THEN 1 END) as in_progress_steps,
766
+ COUNT(CASE WHEN sd.current_state IN ('complete', 'resolved_manually') THEN 1 END) as completed_steps,
767
+ COUNT(CASE WHEN sd.current_state = 'error' THEN 1 END) as failed_steps,
768
+ COUNT(CASE WHEN sd.ready_for_execution = true THEN 1 END) as ready_steps,
769
+ -- Count PERMANENTLY blocked failures (exhausted retries)
770
+ COUNT(CASE WHEN sd.current_state = 'error'
771
+ AND (sd.attempts >= sd.retry_limit) THEN 1 END) as permanently_blocked_steps
772
+ FROM step_data sd
773
+ GROUP BY sd.task_id
774
+ )
775
+ SELECT
776
+ ti.task_id,
777
+ ti.named_task_id,
778
+ ti.current_status as status,
779
+
780
+ -- Step Statistics
781
+ COALESCE(ast.total_steps, 0) as total_steps,
782
+ COALESCE(ast.pending_steps, 0) as pending_steps,
783
+ COALESCE(ast.in_progress_steps, 0) as in_progress_steps,
784
+ COALESCE(ast.completed_steps, 0) as completed_steps,
785
+ COALESCE(ast.failed_steps, 0) as failed_steps,
786
+ COALESCE(ast.ready_steps, 0) as ready_steps,
787
+
788
+ -- Execution State Logic
789
+ CASE
790
+ WHEN COALESCE(ast.ready_steps, 0) > 0 THEN 'has_ready_steps'
791
+ WHEN COALESCE(ast.in_progress_steps, 0) > 0 THEN 'processing'
792
+ WHEN COALESCE(ast.permanently_blocked_steps, 0) > 0 AND COALESCE(ast.ready_steps, 0) = 0 THEN 'blocked_by_failures'
793
+ WHEN COALESCE(ast.completed_steps, 0) = COALESCE(ast.total_steps, 0) AND COALESCE(ast.total_steps, 0) > 0 THEN 'all_complete'
794
+ ELSE 'waiting_for_dependencies'
795
+ END as execution_status,
796
+
797
+ -- Recommended Action Logic
798
+ CASE
799
+ WHEN COALESCE(ast.ready_steps, 0) > 0 THEN 'execute_ready_steps'
800
+ WHEN COALESCE(ast.in_progress_steps, 0) > 0 THEN 'wait_for_completion'
801
+ WHEN COALESCE(ast.permanently_blocked_steps, 0) > 0 AND COALESCE(ast.ready_steps, 0) = 0 THEN 'handle_failures'
802
+ WHEN COALESCE(ast.completed_steps, 0) = COALESCE(ast.total_steps, 0) AND COALESCE(ast.total_steps, 0) > 0 THEN 'finalize_task'
803
+ ELSE 'wait_for_dependencies'
804
+ END as recommended_action,
805
+
806
+ -- Progress Metrics
807
+ CASE
808
+ WHEN COALESCE(ast.total_steps, 0) = 0 THEN 0.0
809
+ ELSE ROUND((COALESCE(ast.completed_steps, 0)::decimal / COALESCE(ast.total_steps, 1)::decimal) * 100, 2)
810
+ END as completion_percentage,
811
+
812
+ -- Health Status Logic
813
+ CASE
814
+ WHEN COALESCE(ast.failed_steps, 0) = 0 THEN 'healthy'
815
+ WHEN COALESCE(ast.failed_steps, 0) > 0 AND COALESCE(ast.ready_steps, 0) > 0 THEN 'recovering'
816
+ WHEN COALESCE(ast.permanently_blocked_steps, 0) > 0 AND COALESCE(ast.ready_steps, 0) = 0 THEN 'blocked'
817
+ WHEN COALESCE(ast.failed_steps, 0) > 0 AND COALESCE(ast.permanently_blocked_steps, 0) = 0 AND COALESCE(ast.ready_steps, 0) = 0 THEN 'recovering'
818
+ ELSE 'unknown'
819
+ END as health_status
820
+
821
+ FROM task_info ti
822
+ LEFT JOIN aggregated_stats ast ON ast.task_id = ti.task_id
823
+ ORDER BY ti.task_id;
824
+ END;
825
+ $$;
826
+
827
+ --
828
+ -- Name: tasker_annotation_types; Type: TABLE; Schema: public; Owner: -
829
+ --
830
+
831
+ CREATE TABLE public.tasker_annotation_types (
832
+ annotation_type_id integer NOT NULL,
833
+ name character varying(64) NOT NULL,
834
+ description character varying(255),
835
+ created_at timestamp(6) without time zone NOT NULL,
836
+ updated_at timestamp(6) without time zone NOT NULL
837
+ );
838
+
839
+
840
+ --
841
+ -- Name: tasker_annotation_types_annotation_type_id_seq; Type: SEQUENCE; Schema: public; Owner: -
842
+ --
843
+
844
+ CREATE SEQUENCE public.tasker_annotation_types_annotation_type_id_seq
845
+ AS integer
846
+ START WITH 1
847
+ INCREMENT BY 1
848
+ NO MINVALUE
849
+ NO MAXVALUE
850
+ CACHE 1;
851
+
852
+
853
+ --
854
+ -- Name: tasker_annotation_types_annotation_type_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
855
+ --
856
+
857
+ ALTER SEQUENCE public.tasker_annotation_types_annotation_type_id_seq OWNED BY public.tasker_annotation_types.annotation_type_id;
858
+
859
+
860
+ --
861
+ -- Name: tasker_dependent_system_object_maps; Type: TABLE; Schema: public; Owner: -
862
+ --
863
+
864
+ CREATE TABLE public.tasker_dependent_system_object_maps (
865
+ dependent_system_object_map_id bigint NOT NULL,
866
+ dependent_system_one_id integer NOT NULL,
867
+ dependent_system_two_id integer NOT NULL,
868
+ remote_id_one character varying(128) NOT NULL,
869
+ remote_id_two character varying(128) NOT NULL,
870
+ created_at timestamp(6) without time zone NOT NULL,
871
+ updated_at timestamp(6) without time zone NOT NULL
872
+ );
873
+
874
+
875
+ --
876
+ -- Name: tasker_dependent_system_objec_dependent_system_object_map_i_seq; Type: SEQUENCE; Schema: public; Owner: -
877
+ --
878
+
879
+ CREATE SEQUENCE public.tasker_dependent_system_objec_dependent_system_object_map_i_seq
880
+ START WITH 1
881
+ INCREMENT BY 1
882
+ NO MINVALUE
883
+ NO MAXVALUE
884
+ CACHE 1;
885
+
886
+
887
+ --
888
+ -- Name: tasker_dependent_system_objec_dependent_system_object_map_i_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
889
+ --
890
+
891
+ ALTER SEQUENCE public.tasker_dependent_system_objec_dependent_system_object_map_i_seq OWNED BY public.tasker_dependent_system_object_maps.dependent_system_object_map_id;
892
+
893
+
894
+ --
895
+ -- Name: tasker_dependent_systems; Type: TABLE; Schema: public; Owner: -
896
+ --
897
+
898
+ CREATE TABLE public.tasker_dependent_systems (
899
+ dependent_system_id integer NOT NULL,
900
+ name character varying(64) NOT NULL,
901
+ description character varying(255),
902
+ created_at timestamp(6) without time zone NOT NULL,
903
+ updated_at timestamp(6) without time zone NOT NULL
904
+ );
905
+
906
+
907
+ --
908
+ -- Name: tasker_dependent_systems_dependent_system_id_seq; Type: SEQUENCE; Schema: public; Owner: -
909
+ --
910
+
911
+ CREATE SEQUENCE public.tasker_dependent_systems_dependent_system_id_seq
912
+ AS integer
913
+ START WITH 1
914
+ INCREMENT BY 1
915
+ NO MINVALUE
916
+ NO MAXVALUE
917
+ CACHE 1;
918
+
919
+
920
+ --
921
+ -- Name: tasker_dependent_systems_dependent_system_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
922
+ --
923
+
924
+ ALTER SEQUENCE public.tasker_dependent_systems_dependent_system_id_seq OWNED BY public.tasker_dependent_systems.dependent_system_id;
925
+
926
+
927
+ --
928
+ -- Name: tasker_named_steps; Type: TABLE; Schema: public; Owner: -
929
+ --
930
+
931
+ CREATE TABLE public.tasker_named_steps (
932
+ named_step_id integer NOT NULL,
933
+ dependent_system_id integer NOT NULL,
934
+ name character varying(128) NOT NULL,
935
+ description character varying(255),
936
+ created_at timestamp(6) without time zone NOT NULL,
937
+ updated_at timestamp(6) without time zone NOT NULL
938
+ );
939
+
940
+
941
+ --
942
+ -- Name: tasker_named_steps_named_step_id_seq; Type: SEQUENCE; Schema: public; Owner: -
943
+ --
944
+
945
+ CREATE SEQUENCE public.tasker_named_steps_named_step_id_seq
946
+ AS integer
947
+ START WITH 1
948
+ INCREMENT BY 1
949
+ NO MINVALUE
950
+ NO MAXVALUE
951
+ CACHE 1;
952
+
953
+
954
+ --
955
+ -- Name: tasker_named_steps_named_step_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
956
+ --
957
+
958
+ ALTER SEQUENCE public.tasker_named_steps_named_step_id_seq OWNED BY public.tasker_named_steps.named_step_id;
959
+
960
+
961
+ --
962
+ -- Name: tasker_named_tasks; Type: TABLE; Schema: public; Owner: -
963
+ --
964
+
965
+ CREATE TABLE public.tasker_named_tasks (
966
+ named_task_id integer NOT NULL,
967
+ name character varying(64) NOT NULL,
968
+ description character varying(255),
969
+ created_at timestamp(6) without time zone NOT NULL,
970
+ updated_at timestamp(6) without time zone NOT NULL,
971
+ task_namespace_id bigint DEFAULT 1 NOT NULL,
972
+ version character varying(16) DEFAULT '0.1.0'::character varying NOT NULL,
973
+ configuration jsonb DEFAULT '"{}"'::jsonb
974
+ );
975
+
976
+
977
+ --
978
+ -- Name: tasker_named_tasks_named_steps; Type: TABLE; Schema: public; Owner: -
979
+ --
980
+
981
+ CREATE TABLE public.tasker_named_tasks_named_steps (
982
+ id integer NOT NULL,
983
+ named_task_id integer NOT NULL,
984
+ named_step_id integer NOT NULL,
985
+ skippable boolean DEFAULT false NOT NULL,
986
+ default_retryable boolean DEFAULT true NOT NULL,
987
+ default_retry_limit integer DEFAULT 3 NOT NULL,
988
+ created_at timestamp(6) without time zone NOT NULL,
989
+ updated_at timestamp(6) without time zone NOT NULL
990
+ );
991
+
992
+
993
+ --
994
+ -- Name: tasker_named_tasks_named_steps_id_seq; Type: SEQUENCE; Schema: public; Owner: -
995
+ --
996
+
997
+ CREATE SEQUENCE public.tasker_named_tasks_named_steps_id_seq
998
+ AS integer
999
+ START WITH 1
1000
+ INCREMENT BY 1
1001
+ NO MINVALUE
1002
+ NO MAXVALUE
1003
+ CACHE 1;
1004
+
1005
+
1006
+ --
1007
+ -- Name: tasker_named_tasks_named_steps_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
1008
+ --
1009
+
1010
+ ALTER SEQUENCE public.tasker_named_tasks_named_steps_id_seq OWNED BY public.tasker_named_tasks_named_steps.id;
1011
+
1012
+
1013
+ --
1014
+ -- Name: tasker_named_tasks_named_task_id_seq; Type: SEQUENCE; Schema: public; Owner: -
1015
+ --
1016
+
1017
+ CREATE SEQUENCE public.tasker_named_tasks_named_task_id_seq
1018
+ AS integer
1019
+ START WITH 1
1020
+ INCREMENT BY 1
1021
+ NO MINVALUE
1022
+ NO MAXVALUE
1023
+ CACHE 1;
1024
+
1025
+
1026
+ --
1027
+ -- Name: tasker_named_tasks_named_task_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
1028
+ --
1029
+
1030
+ ALTER SEQUENCE public.tasker_named_tasks_named_task_id_seq OWNED BY public.tasker_named_tasks.named_task_id;
1031
+
1032
+
1033
+ --
1034
+ -- Name: tasker_workflow_step_edges; Type: TABLE; Schema: public; Owner: -
1035
+ --
1036
+
1037
+ CREATE TABLE public.tasker_workflow_step_edges (
1038
+ id bigint NOT NULL,
1039
+ from_step_id bigint NOT NULL,
1040
+ to_step_id bigint NOT NULL,
1041
+ name character varying NOT NULL,
1042
+ created_at timestamp(6) without time zone NOT NULL,
1043
+ updated_at timestamp(6) without time zone NOT NULL
1044
+ );
1045
+
1046
+
1047
+ --
1048
+ -- Name: tasker_workflow_steps; Type: TABLE; Schema: public; Owner: -
1049
+ --
1050
+
1051
+ CREATE TABLE public.tasker_workflow_steps (
1052
+ workflow_step_id bigint NOT NULL,
1053
+ task_id bigint NOT NULL,
1054
+ named_step_id integer NOT NULL,
1055
+ retryable boolean DEFAULT true NOT NULL,
1056
+ retry_limit integer DEFAULT 3,
1057
+ in_process boolean DEFAULT false NOT NULL,
1058
+ processed boolean DEFAULT false NOT NULL,
1059
+ processed_at timestamp without time zone,
1060
+ attempts integer,
1061
+ last_attempted_at timestamp without time zone,
1062
+ backoff_request_seconds integer,
1063
+ inputs jsonb,
1064
+ results jsonb,
1065
+ created_at timestamp(6) without time zone NOT NULL,
1066
+ updated_at timestamp(6) without time zone NOT NULL,
1067
+ skippable boolean DEFAULT false NOT NULL
1068
+ );
1069
+
1070
+
1071
+ --
1072
+ -- Name: tasker_step_dag_relationships; Type: VIEW; Schema: public; Owner: -
1073
+ --
1074
+
1075
+ CREATE VIEW public.tasker_step_dag_relationships AS
1076
+ SELECT ws.workflow_step_id,
1077
+ ws.task_id,
1078
+ ws.named_step_id,
1079
+ COALESCE(parent_data.parent_ids, '[]'::jsonb) AS parent_step_ids,
1080
+ COALESCE(child_data.child_ids, '[]'::jsonb) AS child_step_ids,
1081
+ COALESCE(parent_data.parent_count, (0)::bigint) AS parent_count,
1082
+ COALESCE(child_data.child_count, (0)::bigint) AS child_count,
1083
+ CASE
1084
+ WHEN (COALESCE(parent_data.parent_count, (0)::bigint) = 0) THEN true
1085
+ ELSE false
1086
+ END AS is_root_step,
1087
+ CASE
1088
+ WHEN (COALESCE(child_data.child_count, (0)::bigint) = 0) THEN true
1089
+ ELSE false
1090
+ END AS is_leaf_step,
1091
+ depth_info.min_depth_from_root
1092
+ FROM (((public.tasker_workflow_steps ws
1093
+ LEFT JOIN ( SELECT tasker_workflow_step_edges.to_step_id,
1094
+ jsonb_agg(tasker_workflow_step_edges.from_step_id ORDER BY tasker_workflow_step_edges.from_step_id) AS parent_ids,
1095
+ count(*) AS parent_count
1096
+ FROM public.tasker_workflow_step_edges
1097
+ GROUP BY tasker_workflow_step_edges.to_step_id) parent_data ON ((parent_data.to_step_id = ws.workflow_step_id)))
1098
+ LEFT JOIN ( SELECT tasker_workflow_step_edges.from_step_id,
1099
+ jsonb_agg(tasker_workflow_step_edges.to_step_id ORDER BY tasker_workflow_step_edges.to_step_id) AS child_ids,
1100
+ count(*) AS child_count
1101
+ FROM public.tasker_workflow_step_edges
1102
+ GROUP BY tasker_workflow_step_edges.from_step_id) child_data ON ((child_data.from_step_id = ws.workflow_step_id)))
1103
+ LEFT JOIN ( WITH RECURSIVE step_depths AS (
1104
+ SELECT ws_inner.workflow_step_id,
1105
+ 0 AS depth_from_root,
1106
+ ws_inner.task_id
1107
+ FROM public.tasker_workflow_steps ws_inner
1108
+ WHERE (NOT (EXISTS ( SELECT 1
1109
+ FROM public.tasker_workflow_step_edges e
1110
+ WHERE (e.to_step_id = ws_inner.workflow_step_id))))
1111
+ UNION ALL
1112
+ SELECT e.to_step_id,
1113
+ (sd.depth_from_root + 1),
1114
+ sd.task_id
1115
+ FROM (step_depths sd
1116
+ JOIN public.tasker_workflow_step_edges e ON ((e.from_step_id = sd.workflow_step_id)))
1117
+ WHERE (sd.depth_from_root < 50)
1118
+ )
1119
+ SELECT step_depths.workflow_step_id,
1120
+ min(step_depths.depth_from_root) AS min_depth_from_root
1121
+ FROM step_depths
1122
+ GROUP BY step_depths.workflow_step_id) depth_info ON ((depth_info.workflow_step_id = ws.workflow_step_id)));
1123
+
1124
+
1125
+ --
1126
+ -- Name: tasker_task_annotations; Type: TABLE; Schema: public; Owner: -
1127
+ --
1128
+
1129
+ CREATE TABLE public.tasker_task_annotations (
1130
+ task_annotation_id bigint NOT NULL,
1131
+ task_id bigint NOT NULL,
1132
+ annotation_type_id integer NOT NULL,
1133
+ annotation jsonb,
1134
+ created_at timestamp(6) without time zone NOT NULL,
1135
+ updated_at timestamp(6) without time zone NOT NULL
1136
+ );
1137
+
1138
+
1139
+ --
1140
+ -- Name: tasker_task_annotations_task_annotation_id_seq; Type: SEQUENCE; Schema: public; Owner: -
1141
+ --
1142
+
1143
+ CREATE SEQUENCE public.tasker_task_annotations_task_annotation_id_seq
1144
+ START WITH 1
1145
+ INCREMENT BY 1
1146
+ NO MINVALUE
1147
+ NO MAXVALUE
1148
+ CACHE 1;
1149
+
1150
+
1151
+ --
1152
+ -- Name: tasker_task_annotations_task_annotation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
1153
+ --
1154
+
1155
+ ALTER SEQUENCE public.tasker_task_annotations_task_annotation_id_seq OWNED BY public.tasker_task_annotations.task_annotation_id;
1156
+
1157
+
1158
+ --
1159
+ -- Name: tasker_task_namespaces; Type: TABLE; Schema: public; Owner: -
1160
+ --
1161
+
1162
+ CREATE TABLE public.tasker_task_namespaces (
1163
+ task_namespace_id integer NOT NULL,
1164
+ name character varying(64) NOT NULL,
1165
+ description character varying(255),
1166
+ created_at timestamp(6) without time zone NOT NULL,
1167
+ updated_at timestamp(6) without time zone NOT NULL
1168
+ );
1169
+
1170
+
1171
+ --
1172
+ -- Name: tasker_task_namespaces_task_namespace_id_seq; Type: SEQUENCE; Schema: public; Owner: -
1173
+ --
1174
+
1175
+ CREATE SEQUENCE public.tasker_task_namespaces_task_namespace_id_seq
1176
+ AS integer
1177
+ START WITH 1
1178
+ INCREMENT BY 1
1179
+ NO MINVALUE
1180
+ NO MAXVALUE
1181
+ CACHE 1;
1182
+
1183
+
1184
+ --
1185
+ -- Name: tasker_task_namespaces_task_namespace_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
1186
+ --
1187
+
1188
+ ALTER SEQUENCE public.tasker_task_namespaces_task_namespace_id_seq OWNED BY public.tasker_task_namespaces.task_namespace_id;
1189
+
1190
+
1191
+ --
1192
+ -- Name: tasker_task_transitions; Type: TABLE; Schema: public; Owner: -
1193
+ --
1194
+
1195
+ CREATE TABLE public.tasker_task_transitions (
1196
+ id bigint NOT NULL,
1197
+ to_state character varying NOT NULL,
1198
+ from_state character varying,
1199
+ metadata jsonb DEFAULT '{}'::jsonb,
1200
+ sort_key integer NOT NULL,
1201
+ most_recent boolean DEFAULT true NOT NULL,
1202
+ task_id bigint NOT NULL,
1203
+ created_at timestamp(6) without time zone NOT NULL,
1204
+ updated_at timestamp(6) without time zone NOT NULL
1205
+ );
1206
+
1207
+
1208
+ --
1209
+ -- Name: tasker_task_transitions_id_seq; Type: SEQUENCE; Schema: public; Owner: -
1210
+ --
1211
+
1212
+ CREATE SEQUENCE public.tasker_task_transitions_id_seq
1213
+ START WITH 1
1214
+ INCREMENT BY 1
1215
+ NO MINVALUE
1216
+ NO MAXVALUE
1217
+ CACHE 1;
1218
+
1219
+
1220
+ --
1221
+ -- Name: tasker_task_transitions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
1222
+ --
1223
+
1224
+ ALTER SEQUENCE public.tasker_task_transitions_id_seq OWNED BY public.tasker_task_transitions.id;
1225
+
1226
+
1227
+ --
1228
+ -- Name: tasker_tasks; Type: TABLE; Schema: public; Owner: -
1229
+ --
1230
+
1231
+ CREATE TABLE public.tasker_tasks (
1232
+ task_id bigint NOT NULL,
1233
+ named_task_id integer NOT NULL,
1234
+ complete boolean DEFAULT false NOT NULL,
1235
+ requested_at timestamp without time zone NOT NULL,
1236
+ initiator character varying(128),
1237
+ source_system character varying(128),
1238
+ reason character varying(128),
1239
+ bypass_steps json,
1240
+ tags jsonb,
1241
+ context jsonb,
1242
+ identity_hash character varying(128) NOT NULL,
1243
+ created_at timestamp(6) without time zone NOT NULL,
1244
+ updated_at timestamp(6) without time zone NOT NULL
1245
+ );
1246
+
1247
+
1248
+ --
1249
+ -- Name: tasker_tasks_task_id_seq; Type: SEQUENCE; Schema: public; Owner: -
1250
+ --
1251
+
1252
+ CREATE SEQUENCE public.tasker_tasks_task_id_seq
1253
+ START WITH 1
1254
+ INCREMENT BY 1
1255
+ NO MINVALUE
1256
+ NO MAXVALUE
1257
+ CACHE 1;
1258
+
1259
+
1260
+ --
1261
+ -- Name: tasker_tasks_task_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
1262
+ --
1263
+
1264
+ ALTER SEQUENCE public.tasker_tasks_task_id_seq OWNED BY public.tasker_tasks.task_id;
1265
+
1266
+
1267
+ --
1268
+ -- Name: tasker_workflow_step_edges_id_seq; Type: SEQUENCE; Schema: public; Owner: -
1269
+ --
1270
+
1271
+ CREATE SEQUENCE public.tasker_workflow_step_edges_id_seq
1272
+ START WITH 1
1273
+ INCREMENT BY 1
1274
+ NO MINVALUE
1275
+ NO MAXVALUE
1276
+ CACHE 1;
1277
+
1278
+
1279
+ --
1280
+ -- Name: tasker_workflow_step_edges_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
1281
+ --
1282
+
1283
+ ALTER SEQUENCE public.tasker_workflow_step_edges_id_seq OWNED BY public.tasker_workflow_step_edges.id;
1284
+
1285
+
1286
+ --
1287
+ -- Name: tasker_workflow_step_transitions; Type: TABLE; Schema: public; Owner: -
1288
+ --
1289
+
1290
+ CREATE TABLE public.tasker_workflow_step_transitions (
1291
+ id bigint NOT NULL,
1292
+ to_state character varying NOT NULL,
1293
+ from_state character varying,
1294
+ metadata jsonb DEFAULT '{}'::jsonb,
1295
+ sort_key integer NOT NULL,
1296
+ most_recent boolean DEFAULT true NOT NULL,
1297
+ workflow_step_id bigint NOT NULL,
1298
+ created_at timestamp(6) without time zone NOT NULL,
1299
+ updated_at timestamp(6) without time zone NOT NULL
1300
+ );
1301
+
1302
+
1303
+ --
1304
+ -- Name: tasker_workflow_step_transitions_id_seq; Type: SEQUENCE; Schema: public; Owner: -
1305
+ --
1306
+
1307
+ CREATE SEQUENCE public.tasker_workflow_step_transitions_id_seq
1308
+ START WITH 1
1309
+ INCREMENT BY 1
1310
+ NO MINVALUE
1311
+ NO MAXVALUE
1312
+ CACHE 1;
1313
+
1314
+
1315
+ --
1316
+ -- Name: tasker_workflow_step_transitions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
1317
+ --
1318
+
1319
+ ALTER SEQUENCE public.tasker_workflow_step_transitions_id_seq OWNED BY public.tasker_workflow_step_transitions.id;
1320
+
1321
+
1322
+ --
1323
+ -- Name: tasker_workflow_steps_workflow_step_id_seq; Type: SEQUENCE; Schema: public; Owner: -
1324
+ --
1325
+
1326
+ CREATE SEQUENCE public.tasker_workflow_steps_workflow_step_id_seq
1327
+ START WITH 1
1328
+ INCREMENT BY 1
1329
+ NO MINVALUE
1330
+ NO MAXVALUE
1331
+ CACHE 1;
1332
+
1333
+
1334
+ --
1335
+ -- Name: tasker_workflow_steps_workflow_step_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
1336
+ --
1337
+
1338
+ ALTER SEQUENCE public.tasker_workflow_steps_workflow_step_id_seq OWNED BY public.tasker_workflow_steps.workflow_step_id;
1339
+
1340
+
1341
+ --
1342
+ -- Name: tasker_annotation_types annotation_type_id; Type: DEFAULT; Schema: public; Owner: -
1343
+ --
1344
+
1345
+ ALTER TABLE ONLY public.tasker_annotation_types ALTER COLUMN annotation_type_id SET DEFAULT nextval('public.tasker_annotation_types_annotation_type_id_seq'::regclass);
1346
+
1347
+
1348
+ --
1349
+ -- Name: tasker_dependent_system_object_maps dependent_system_object_map_id; Type: DEFAULT; Schema: public; Owner: -
1350
+ --
1351
+
1352
+ ALTER TABLE ONLY public.tasker_dependent_system_object_maps ALTER COLUMN dependent_system_object_map_id SET DEFAULT nextval('public.tasker_dependent_system_objec_dependent_system_object_map_i_seq'::regclass);
1353
+
1354
+
1355
+ --
1356
+ -- Name: tasker_dependent_systems dependent_system_id; Type: DEFAULT; Schema: public; Owner: -
1357
+ --
1358
+
1359
+ ALTER TABLE ONLY public.tasker_dependent_systems ALTER COLUMN dependent_system_id SET DEFAULT nextval('public.tasker_dependent_systems_dependent_system_id_seq'::regclass);
1360
+
1361
+
1362
+ --
1363
+ -- Name: tasker_named_steps named_step_id; Type: DEFAULT; Schema: public; Owner: -
1364
+ --
1365
+
1366
+ ALTER TABLE ONLY public.tasker_named_steps ALTER COLUMN named_step_id SET DEFAULT nextval('public.tasker_named_steps_named_step_id_seq'::regclass);
1367
+
1368
+
1369
+ --
1370
+ -- Name: tasker_named_tasks named_task_id; Type: DEFAULT; Schema: public; Owner: -
1371
+ --
1372
+
1373
+ ALTER TABLE ONLY public.tasker_named_tasks ALTER COLUMN named_task_id SET DEFAULT nextval('public.tasker_named_tasks_named_task_id_seq'::regclass);
1374
+
1375
+
1376
+ --
1377
+ -- Name: tasker_named_tasks_named_steps id; Type: DEFAULT; Schema: public; Owner: -
1378
+ --
1379
+
1380
+ ALTER TABLE ONLY public.tasker_named_tasks_named_steps ALTER COLUMN id SET DEFAULT nextval('public.tasker_named_tasks_named_steps_id_seq'::regclass);
1381
+
1382
+
1383
+ --
1384
+ -- Name: tasker_task_annotations task_annotation_id; Type: DEFAULT; Schema: public; Owner: -
1385
+ --
1386
+
1387
+ ALTER TABLE ONLY public.tasker_task_annotations ALTER COLUMN task_annotation_id SET DEFAULT nextval('public.tasker_task_annotations_task_annotation_id_seq'::regclass);
1388
+
1389
+
1390
+ --
1391
+ -- Name: tasker_task_namespaces task_namespace_id; Type: DEFAULT; Schema: public; Owner: -
1392
+ --
1393
+
1394
+ ALTER TABLE ONLY public.tasker_task_namespaces ALTER COLUMN task_namespace_id SET DEFAULT nextval('public.tasker_task_namespaces_task_namespace_id_seq'::regclass);
1395
+
1396
+
1397
+ --
1398
+ -- Name: tasker_task_transitions id; Type: DEFAULT; Schema: public; Owner: -
1399
+ --
1400
+
1401
+ ALTER TABLE ONLY public.tasker_task_transitions ALTER COLUMN id SET DEFAULT nextval('public.tasker_task_transitions_id_seq'::regclass);
1402
+
1403
+
1404
+ --
1405
+ -- Name: tasker_tasks task_id; Type: DEFAULT; Schema: public; Owner: -
1406
+ --
1407
+
1408
+ ALTER TABLE ONLY public.tasker_tasks ALTER COLUMN task_id SET DEFAULT nextval('public.tasker_tasks_task_id_seq'::regclass);
1409
+
1410
+
1411
+ --
1412
+ -- Name: tasker_workflow_step_edges id; Type: DEFAULT; Schema: public; Owner: -
1413
+ --
1414
+
1415
+ ALTER TABLE ONLY public.tasker_workflow_step_edges ALTER COLUMN id SET DEFAULT nextval('public.tasker_workflow_step_edges_id_seq'::regclass);
1416
+
1417
+
1418
+ --
1419
+ -- Name: tasker_workflow_step_transitions id; Type: DEFAULT; Schema: public; Owner: -
1420
+ --
1421
+
1422
+ ALTER TABLE ONLY public.tasker_workflow_step_transitions ALTER COLUMN id SET DEFAULT nextval('public.tasker_workflow_step_transitions_id_seq'::regclass);
1423
+
1424
+
1425
+ --
1426
+ -- Name: tasker_workflow_steps workflow_step_id; Type: DEFAULT; Schema: public; Owner: -
1427
+ --
1428
+
1429
+ ALTER TABLE ONLY public.tasker_workflow_steps ALTER COLUMN workflow_step_id SET DEFAULT nextval('public.tasker_workflow_steps_workflow_step_id_seq'::regclass);
1430
+
1431
+ --
1432
+ -- Name: tasker_annotation_types tasker_annotation_types_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1433
+ --
1434
+
1435
+ ALTER TABLE ONLY public.tasker_annotation_types
1436
+ ADD CONSTRAINT tasker_annotation_types_pkey PRIMARY KEY (annotation_type_id);
1437
+
1438
+
1439
+ --
1440
+ -- Name: tasker_dependent_system_object_maps tasker_dependent_system_object_maps_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1441
+ --
1442
+
1443
+ ALTER TABLE ONLY public.tasker_dependent_system_object_maps
1444
+ ADD CONSTRAINT tasker_dependent_system_object_maps_pkey PRIMARY KEY (dependent_system_object_map_id);
1445
+
1446
+
1447
+ --
1448
+ -- Name: tasker_dependent_systems tasker_dependent_systems_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1449
+ --
1450
+
1451
+ ALTER TABLE ONLY public.tasker_dependent_systems
1452
+ ADD CONSTRAINT tasker_dependent_systems_pkey PRIMARY KEY (dependent_system_id);
1453
+
1454
+
1455
+ --
1456
+ -- Name: tasker_named_steps tasker_named_steps_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1457
+ --
1458
+
1459
+ ALTER TABLE ONLY public.tasker_named_steps
1460
+ ADD CONSTRAINT tasker_named_steps_pkey PRIMARY KEY (named_step_id);
1461
+
1462
+
1463
+ --
1464
+ -- Name: tasker_named_tasks_named_steps tasker_named_tasks_named_steps_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1465
+ --
1466
+
1467
+ ALTER TABLE ONLY public.tasker_named_tasks_named_steps
1468
+ ADD CONSTRAINT tasker_named_tasks_named_steps_pkey PRIMARY KEY (id);
1469
+
1470
+
1471
+ --
1472
+ -- Name: tasker_named_tasks tasker_named_tasks_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1473
+ --
1474
+
1475
+ ALTER TABLE ONLY public.tasker_named_tasks
1476
+ ADD CONSTRAINT tasker_named_tasks_pkey PRIMARY KEY (named_task_id);
1477
+
1478
+
1479
+ --
1480
+ -- Name: tasker_task_annotations tasker_task_annotations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1481
+ --
1482
+
1483
+ ALTER TABLE ONLY public.tasker_task_annotations
1484
+ ADD CONSTRAINT tasker_task_annotations_pkey PRIMARY KEY (task_annotation_id);
1485
+
1486
+
1487
+ --
1488
+ -- Name: tasker_task_namespaces tasker_task_namespaces_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1489
+ --
1490
+
1491
+ ALTER TABLE ONLY public.tasker_task_namespaces
1492
+ ADD CONSTRAINT tasker_task_namespaces_pkey PRIMARY KEY (task_namespace_id);
1493
+
1494
+
1495
+ --
1496
+ -- Name: tasker_task_transitions tasker_task_transitions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1497
+ --
1498
+
1499
+ ALTER TABLE ONLY public.tasker_task_transitions
1500
+ ADD CONSTRAINT tasker_task_transitions_pkey PRIMARY KEY (id);
1501
+
1502
+
1503
+ --
1504
+ -- Name: tasker_tasks tasker_tasks_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1505
+ --
1506
+
1507
+ ALTER TABLE ONLY public.tasker_tasks
1508
+ ADD CONSTRAINT tasker_tasks_pkey PRIMARY KEY (task_id);
1509
+
1510
+
1511
+ --
1512
+ -- Name: tasker_workflow_step_edges tasker_workflow_step_edges_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1513
+ --
1514
+
1515
+ ALTER TABLE ONLY public.tasker_workflow_step_edges
1516
+ ADD CONSTRAINT tasker_workflow_step_edges_pkey PRIMARY KEY (id);
1517
+
1518
+
1519
+ --
1520
+ -- Name: tasker_workflow_step_transitions tasker_workflow_step_transitions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1521
+ --
1522
+
1523
+ ALTER TABLE ONLY public.tasker_workflow_step_transitions
1524
+ ADD CONSTRAINT tasker_workflow_step_transitions_pkey PRIMARY KEY (id);
1525
+
1526
+
1527
+ --
1528
+ -- Name: tasker_workflow_steps tasker_workflow_steps_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1529
+ --
1530
+
1531
+ ALTER TABLE ONLY public.tasker_workflow_steps
1532
+ ADD CONSTRAINT tasker_workflow_steps_pkey PRIMARY KEY (workflow_step_id);
1533
+
1534
+
1535
+ --
1536
+ -- Name: annotation_types_name_index; Type: INDEX; Schema: public; Owner: -
1537
+ --
1538
+
1539
+ CREATE INDEX annotation_types_name_index ON public.tasker_annotation_types USING btree (name);
1540
+
1541
+
1542
+ --
1543
+ -- Name: annotation_types_name_unique; Type: INDEX; Schema: public; Owner: -
1544
+ --
1545
+
1546
+ CREATE UNIQUE INDEX annotation_types_name_unique ON public.tasker_annotation_types USING btree (name);
1547
+
1548
+
1549
+ --
1550
+ -- Name: dependent_system_object_maps_dependent_system_one_id_dependent_; Type: INDEX; Schema: public; Owner: -
1551
+ --
1552
+
1553
+ CREATE UNIQUE INDEX dependent_system_object_maps_dependent_system_one_id_dependent_ ON public.tasker_dependent_system_object_maps USING btree (dependent_system_one_id, dependent_system_two_id, remote_id_one, remote_id_two);
1554
+
1555
+
1556
+ --
1557
+ -- Name: dependent_system_object_maps_dependent_system_one_id_index; Type: INDEX; Schema: public; Owner: -
1558
+ --
1559
+
1560
+ CREATE INDEX dependent_system_object_maps_dependent_system_one_id_index ON public.tasker_dependent_system_object_maps USING btree (dependent_system_one_id);
1561
+
1562
+
1563
+ --
1564
+ -- Name: dependent_system_object_maps_dependent_system_two_id_index; Type: INDEX; Schema: public; Owner: -
1565
+ --
1566
+
1567
+ CREATE INDEX dependent_system_object_maps_dependent_system_two_id_index ON public.tasker_dependent_system_object_maps USING btree (dependent_system_two_id);
1568
+
1569
+
1570
+ --
1571
+ -- Name: dependent_system_object_maps_remote_id_one_index; Type: INDEX; Schema: public; Owner: -
1572
+ --
1573
+
1574
+ CREATE INDEX dependent_system_object_maps_remote_id_one_index ON public.tasker_dependent_system_object_maps USING btree (remote_id_one);
1575
+
1576
+
1577
+ --
1578
+ -- Name: dependent_system_object_maps_remote_id_two_index; Type: INDEX; Schema: public; Owner: -
1579
+ --
1580
+
1581
+ CREATE INDEX dependent_system_object_maps_remote_id_two_index ON public.tasker_dependent_system_object_maps USING btree (remote_id_two);
1582
+
1583
+
1584
+ --
1585
+ -- Name: dependent_systems_name_index; Type: INDEX; Schema: public; Owner: -
1586
+ --
1587
+
1588
+ CREATE INDEX dependent_systems_name_index ON public.tasker_dependent_systems USING btree (name);
1589
+
1590
+
1591
+ --
1592
+ -- Name: dependent_systems_name_unique; Type: INDEX; Schema: public; Owner: -
1593
+ --
1594
+
1595
+ CREATE UNIQUE INDEX dependent_systems_name_unique ON public.tasker_dependent_systems USING btree (name);
1596
+
1597
+
1598
+ --
1599
+ -- Name: idx_on_workflow_step_id_most_recent_97d5374ad6; Type: INDEX; Schema: public; Owner: -
1600
+ --
1601
+
1602
+ CREATE UNIQUE INDEX idx_on_workflow_step_id_most_recent_97d5374ad6 ON public.tasker_workflow_step_transitions USING btree (workflow_step_id, most_recent) WHERE (most_recent = true);
1603
+
1604
+
1605
+ --
1606
+ -- Name: idx_on_workflow_step_id_sort_key_4d476d7adb; Type: INDEX; Schema: public; Owner: -
1607
+ --
1608
+
1609
+ CREATE UNIQUE INDEX idx_on_workflow_step_id_sort_key_4d476d7adb ON public.tasker_workflow_step_transitions USING btree (workflow_step_id, sort_key);
1610
+
1611
+
1612
+ --
1613
+ -- Name: idx_step_edges_from_to; Type: INDEX; Schema: public; Owner: -
1614
+ --
1615
+
1616
+ CREATE INDEX idx_step_edges_from_to ON public.tasker_workflow_step_edges USING btree (from_step_id, to_step_id);
1617
+
1618
+
1619
+ --
1620
+ -- Name: idx_step_edges_to_from; Type: INDEX; Schema: public; Owner: -
1621
+ --
1622
+
1623
+ CREATE INDEX idx_step_edges_to_from ON public.tasker_workflow_step_edges USING btree (to_step_id, from_step_id);
1624
+
1625
+
1626
+ --
1627
+ -- Name: idx_step_transitions_current_state; Type: INDEX; Schema: public; Owner: -
1628
+ --
1629
+
1630
+ CREATE INDEX idx_step_transitions_current_state ON public.tasker_workflow_step_transitions USING btree (workflow_step_id, most_recent, to_state) WHERE (most_recent = true);
1631
+
1632
+
1633
+ --
1634
+ -- Name: idx_step_transitions_most_recent; Type: INDEX; Schema: public; Owner: -
1635
+ --
1636
+
1637
+ CREATE INDEX idx_step_transitions_most_recent ON public.tasker_workflow_step_transitions USING btree (workflow_step_id, most_recent) WHERE (most_recent = true);
1638
+
1639
+
1640
+ --
1641
+ -- Name: idx_steps_active_operations; Type: INDEX; Schema: public; Owner: -
1642
+ --
1643
+
1644
+ CREATE INDEX idx_steps_active_operations ON public.tasker_workflow_steps USING btree (workflow_step_id, task_id) WHERE ((processed = false) OR (processed IS NULL));
1645
+
1646
+
1647
+ --
1648
+ -- Name: idx_task_transitions_most_recent; Type: INDEX; Schema: public; Owner: -
1649
+ --
1650
+
1651
+ CREATE INDEX idx_task_transitions_most_recent ON public.tasker_task_transitions USING btree (task_id, most_recent) WHERE (most_recent = true);
1652
+
1653
+
1654
+ --
1655
+ -- Name: idx_tasks_active_operations; Type: INDEX; Schema: public; Owner: -
1656
+ --
1657
+
1658
+ CREATE INDEX idx_tasks_active_operations ON public.tasker_tasks USING btree (task_id) WHERE ((complete = false) OR (complete IS NULL));
1659
+
1660
+
1661
+ --
1662
+ -- Name: idx_tasks_active_workflow_summary; Type: INDEX; Schema: public; Owner: -
1663
+ --
1664
+
1665
+ CREATE INDEX idx_tasks_active_workflow_summary ON public.tasker_tasks USING btree (task_id, complete) WHERE ((complete = false) OR (complete IS NULL));
1666
+
1667
+
1668
+ --
1669
+ -- Name: idx_tasks_completion_status_created; Type: INDEX; Schema: public; Owner: -
1670
+ --
1671
+
1672
+ CREATE INDEX idx_tasks_completion_status_created ON public.tasker_tasks USING btree (complete, created_at, task_id);
1673
+
1674
+
1675
+ --
1676
+ -- Name: idx_workflow_step_edges_dependency_lookup; Type: INDEX; Schema: public; Owner: -
1677
+ --
1678
+
1679
+ CREATE INDEX idx_workflow_step_edges_dependency_lookup ON public.tasker_workflow_step_edges USING btree (to_step_id, from_step_id);
1680
+
1681
+
1682
+ --
1683
+ -- Name: idx_workflow_steps_task_grouping_active; Type: INDEX; Schema: public; Owner: -
1684
+ --
1685
+
1686
+ CREATE INDEX idx_workflow_steps_task_grouping_active ON public.tasker_workflow_steps USING btree (task_id, workflow_step_id) WHERE ((processed = false) OR (processed IS NULL));
1687
+
1688
+
1689
+ --
1690
+ -- Name: idx_workflow_steps_task_readiness; Type: INDEX; Schema: public; Owner: -
1691
+ --
1692
+
1693
+ CREATE INDEX idx_workflow_steps_task_readiness ON public.tasker_workflow_steps USING btree (task_id, processed, workflow_step_id) WHERE (processed = false);
1694
+
1695
+
1696
+ --
1697
+ -- Name: index_step_edges_child_lookup; Type: INDEX; Schema: public; Owner: -
1698
+ --
1699
+
1700
+ CREATE INDEX index_step_edges_child_lookup ON public.tasker_workflow_step_edges USING btree (to_step_id);
1701
+
1702
+
1703
+ --
1704
+ -- Name: index_step_edges_dependency_pair; Type: INDEX; Schema: public; Owner: -
1705
+ --
1706
+
1707
+ CREATE INDEX index_step_edges_dependency_pair ON public.tasker_workflow_step_edges USING btree (to_step_id, from_step_id);
1708
+
1709
+
1710
+ --
1711
+ -- Name: index_step_edges_from_step_for_children; Type: INDEX; Schema: public; Owner: -
1712
+ --
1713
+
1714
+ CREATE INDEX index_step_edges_from_step_for_children ON public.tasker_workflow_step_edges USING btree (from_step_id);
1715
+
1716
+
1717
+ --
1718
+ -- Name: index_step_edges_from_to_composite; Type: INDEX; Schema: public; Owner: -
1719
+ --
1720
+
1721
+ CREATE INDEX index_step_edges_from_to_composite ON public.tasker_workflow_step_edges USING btree (from_step_id, to_step_id);
1722
+
1723
+
1724
+ --
1725
+ -- Name: index_step_edges_parent_lookup; Type: INDEX; Schema: public; Owner: -
1726
+ --
1727
+
1728
+ CREATE INDEX index_step_edges_parent_lookup ON public.tasker_workflow_step_edges USING btree (from_step_id);
1729
+
1730
+
1731
+ --
1732
+ -- Name: index_step_edges_to_from_composite; Type: INDEX; Schema: public; Owner: -
1733
+ --
1734
+
1735
+ CREATE INDEX index_step_edges_to_from_composite ON public.tasker_workflow_step_edges USING btree (to_step_id, from_step_id);
1736
+
1737
+
1738
+ --
1739
+ -- Name: index_step_edges_to_step_for_parents; Type: INDEX; Schema: public; Owner: -
1740
+ --
1741
+
1742
+ CREATE INDEX index_step_edges_to_step_for_parents ON public.tasker_workflow_step_edges USING btree (to_step_id);
1743
+
1744
+
1745
+ --
1746
+ -- Name: index_step_transitions_completed; Type: INDEX; Schema: public; Owner: -
1747
+ --
1748
+
1749
+ CREATE INDEX index_step_transitions_completed ON public.tasker_workflow_step_transitions USING btree (workflow_step_id, to_state) WHERE ((to_state)::text = 'complete'::text);
1750
+
1751
+
1752
+ --
1753
+ -- Name: index_step_transitions_completed_parents; Type: INDEX; Schema: public; Owner: -
1754
+ --
1755
+
1756
+ CREATE INDEX index_step_transitions_completed_parents ON public.tasker_workflow_step_transitions USING btree (workflow_step_id, most_recent) WHERE (((to_state)::text = ANY ((ARRAY['complete'::character varying, 'resolved_manually'::character varying])::text[])) AND (most_recent = true));
1757
+
1758
+
1759
+ --
1760
+ -- Name: index_step_transitions_current_errors; Type: INDEX; Schema: public; Owner: -
1761
+ --
1762
+
1763
+ CREATE INDEX index_step_transitions_current_errors ON public.tasker_workflow_step_transitions USING btree (workflow_step_id, most_recent, created_at) WHERE (((to_state)::text = 'error'::text) AND (most_recent = true));
1764
+
1765
+
1766
+ --
1767
+ -- Name: index_step_transitions_current_state_optimized; Type: INDEX; Schema: public; Owner: -
1768
+ --
1769
+
1770
+ CREATE INDEX index_step_transitions_current_state_optimized ON public.tasker_workflow_step_transitions USING btree (workflow_step_id, most_recent) WHERE (most_recent = true);
1771
+
1772
+
1773
+ --
1774
+ -- Name: index_step_transitions_failures_with_timing; Type: INDEX; Schema: public; Owner: -
1775
+ --
1776
+
1777
+ CREATE INDEX index_step_transitions_failures_with_timing ON public.tasker_workflow_step_transitions USING btree (workflow_step_id, to_state, created_at) WHERE ((to_state)::text = 'failed'::text);
1778
+
1779
+
1780
+ --
1781
+ -- Name: index_step_transitions_for_current_state; Type: INDEX; Schema: public; Owner: -
1782
+ --
1783
+
1784
+ CREATE INDEX index_step_transitions_for_current_state ON public.tasker_workflow_step_transitions USING btree (workflow_step_id, created_at);
1785
+
1786
+
1787
+ --
1788
+ -- Name: index_task_transitions_current_state; Type: INDEX; Schema: public; Owner: -
1789
+ --
1790
+
1791
+ CREATE INDEX index_task_transitions_current_state ON public.tasker_task_transitions USING btree (task_id, created_at);
1792
+
1793
+
1794
+ --
1795
+ -- Name: index_task_transitions_current_state_optimized; Type: INDEX; Schema: public; Owner: -
1796
+ --
1797
+
1798
+ CREATE INDEX index_task_transitions_current_state_optimized ON public.tasker_task_transitions USING btree (task_id, most_recent) WHERE (most_recent = true);
1799
+
1800
+
1801
+ --
1802
+ -- Name: index_tasker_task_transitions_on_sort_key; Type: INDEX; Schema: public; Owner: -
1803
+ --
1804
+
1805
+ CREATE INDEX index_tasker_task_transitions_on_sort_key ON public.tasker_task_transitions USING btree (sort_key);
1806
+
1807
+
1808
+ --
1809
+ -- Name: index_tasker_task_transitions_on_task_id; Type: INDEX; Schema: public; Owner: -
1810
+ --
1811
+
1812
+ CREATE INDEX index_tasker_task_transitions_on_task_id ON public.tasker_task_transitions USING btree (task_id);
1813
+
1814
+
1815
+ --
1816
+ -- Name: index_tasker_task_transitions_on_task_id_and_most_recent; Type: INDEX; Schema: public; Owner: -
1817
+ --
1818
+
1819
+ CREATE UNIQUE INDEX index_tasker_task_transitions_on_task_id_and_most_recent ON public.tasker_task_transitions USING btree (task_id, most_recent) WHERE (most_recent = true);
1820
+
1821
+
1822
+ --
1823
+ -- Name: index_tasker_task_transitions_on_task_id_and_sort_key; Type: INDEX; Schema: public; Owner: -
1824
+ --
1825
+
1826
+ CREATE UNIQUE INDEX index_tasker_task_transitions_on_task_id_and_sort_key ON public.tasker_task_transitions USING btree (task_id, sort_key);
1827
+
1828
+
1829
+ --
1830
+ -- Name: index_tasker_workflow_step_edges_on_from_step_id; Type: INDEX; Schema: public; Owner: -
1831
+ --
1832
+
1833
+ CREATE INDEX index_tasker_workflow_step_edges_on_from_step_id ON public.tasker_workflow_step_edges USING btree (from_step_id);
1834
+
1835
+
1836
+ --
1837
+ -- Name: index_tasker_workflow_step_edges_on_to_step_id; Type: INDEX; Schema: public; Owner: -
1838
+ --
1839
+
1840
+ CREATE INDEX index_tasker_workflow_step_edges_on_to_step_id ON public.tasker_workflow_step_edges USING btree (to_step_id);
1841
+
1842
+
1843
+ --
1844
+ -- Name: index_tasker_workflow_step_transitions_on_sort_key; Type: INDEX; Schema: public; Owner: -
1845
+ --
1846
+
1847
+ CREATE INDEX index_tasker_workflow_step_transitions_on_sort_key ON public.tasker_workflow_step_transitions USING btree (sort_key);
1848
+
1849
+
1850
+ --
1851
+ -- Name: index_tasker_workflow_step_transitions_on_workflow_step_id; Type: INDEX; Schema: public; Owner: -
1852
+ --
1853
+
1854
+ CREATE INDEX index_tasker_workflow_step_transitions_on_workflow_step_id ON public.tasker_workflow_step_transitions USING btree (workflow_step_id);
1855
+
1856
+
1857
+ --
1858
+ -- Name: index_tasks_on_identity_hash; Type: INDEX; Schema: public; Owner: -
1859
+ --
1860
+
1861
+ CREATE UNIQUE INDEX index_tasks_on_identity_hash ON public.tasker_tasks USING btree (identity_hash);
1862
+
1863
+
1864
+ --
1865
+ -- Name: index_workflow_step_edges_dependency_lookup; Type: INDEX; Schema: public; Owner: -
1866
+ --
1867
+
1868
+ CREATE INDEX index_workflow_step_edges_dependency_lookup ON public.tasker_workflow_step_edges USING btree (to_step_id, from_step_id);
1869
+
1870
+
1871
+ --
1872
+ -- Name: index_workflow_steps_backoff_timing; Type: INDEX; Schema: public; Owner: -
1873
+ --
1874
+
1875
+ CREATE INDEX index_workflow_steps_backoff_timing ON public.tasker_workflow_steps USING btree (last_attempted_at, backoff_request_seconds) WHERE (backoff_request_seconds IS NOT NULL);
1876
+
1877
+
1878
+ --
1879
+ -- Name: index_workflow_steps_by_task; Type: INDEX; Schema: public; Owner: -
1880
+ --
1881
+
1882
+ CREATE INDEX index_workflow_steps_by_task ON public.tasker_workflow_steps USING btree (task_id);
1883
+
1884
+
1885
+ --
1886
+ -- Name: index_workflow_steps_processing_status; Type: INDEX; Schema: public; Owner: -
1887
+ --
1888
+
1889
+ CREATE INDEX index_workflow_steps_processing_status ON public.tasker_workflow_steps USING btree (task_id, processed, in_process);
1890
+
1891
+
1892
+ --
1893
+ -- Name: index_workflow_steps_retry_logic; Type: INDEX; Schema: public; Owner: -
1894
+ --
1895
+
1896
+ CREATE INDEX index_workflow_steps_retry_logic ON public.tasker_workflow_steps USING btree (attempts, retry_limit, retryable);
1897
+
1898
+
1899
+ --
1900
+ -- Name: index_workflow_steps_retry_status; Type: INDEX; Schema: public; Owner: -
1901
+ --
1902
+
1903
+ CREATE INDEX index_workflow_steps_retry_status ON public.tasker_workflow_steps USING btree (attempts, retry_limit);
1904
+
1905
+
1906
+ --
1907
+ -- Name: index_workflow_steps_task_and_id; Type: INDEX; Schema: public; Owner: -
1908
+ --
1909
+
1910
+ CREATE INDEX index_workflow_steps_task_and_id ON public.tasker_workflow_steps USING btree (task_id, workflow_step_id);
1911
+
1912
+
1913
+ --
1914
+ -- Name: index_workflow_steps_task_and_step_id; Type: INDEX; Schema: public; Owner: -
1915
+ --
1916
+
1917
+ CREATE INDEX index_workflow_steps_task_and_step_id ON public.tasker_workflow_steps USING btree (task_id, workflow_step_id);
1918
+
1919
+
1920
+ --
1921
+ -- Name: index_workflow_steps_task_and_step_optimized; Type: INDEX; Schema: public; Owner: -
1922
+ --
1923
+
1924
+ CREATE INDEX index_workflow_steps_task_and_step_optimized ON public.tasker_workflow_steps USING btree (task_id, workflow_step_id);
1925
+
1926
+
1927
+ --
1928
+ -- Name: index_workflow_steps_task_covering; Type: INDEX; Schema: public; Owner: -
1929
+ --
1930
+
1931
+ CREATE INDEX index_workflow_steps_task_covering ON public.tasker_workflow_steps USING btree (task_id) INCLUDE (workflow_step_id, processed, in_process, attempts, retry_limit);
1932
+
1933
+
1934
+ --
1935
+ -- Name: named_step_by_system_uniq; Type: INDEX; Schema: public; Owner: -
1936
+ --
1937
+
1938
+ CREATE UNIQUE INDEX named_step_by_system_uniq ON public.tasker_named_steps USING btree (dependent_system_id, name);
1939
+
1940
+
1941
+ --
1942
+ -- Name: named_steps_dependent_system_id_index; Type: INDEX; Schema: public; Owner: -
1943
+ --
1944
+
1945
+ CREATE INDEX named_steps_dependent_system_id_index ON public.tasker_named_steps USING btree (dependent_system_id);
1946
+
1947
+
1948
+ --
1949
+ -- Name: named_steps_name_index; Type: INDEX; Schema: public; Owner: -
1950
+ --
1951
+
1952
+ CREATE INDEX named_steps_name_index ON public.tasker_named_steps USING btree (name);
1953
+
1954
+
1955
+ --
1956
+ -- Name: named_tasks_configuration_gin_index; Type: INDEX; Schema: public; Owner: -
1957
+ --
1958
+
1959
+ CREATE INDEX named_tasks_configuration_gin_index ON public.tasker_named_tasks USING gin (configuration);
1960
+
1961
+
1962
+ --
1963
+ -- Name: named_tasks_name_index; Type: INDEX; Schema: public; Owner: -
1964
+ --
1965
+
1966
+ CREATE INDEX named_tasks_name_index ON public.tasker_named_tasks USING btree (name);
1967
+
1968
+
1969
+ --
1970
+ -- Name: named_tasks_named_steps_named_step_id_index; Type: INDEX; Schema: public; Owner: -
1971
+ --
1972
+
1973
+ CREATE INDEX named_tasks_named_steps_named_step_id_index ON public.tasker_named_tasks_named_steps USING btree (named_step_id);
1974
+
1975
+
1976
+ --
1977
+ -- Name: named_tasks_named_steps_named_task_id_index; Type: INDEX; Schema: public; Owner: -
1978
+ --
1979
+
1980
+ CREATE INDEX named_tasks_named_steps_named_task_id_index ON public.tasker_named_tasks_named_steps USING btree (named_task_id);
1981
+
1982
+
1983
+ --
1984
+ -- Name: named_tasks_namespace_name_version_unique; Type: INDEX; Schema: public; Owner: -
1985
+ --
1986
+
1987
+ CREATE UNIQUE INDEX named_tasks_namespace_name_version_unique ON public.tasker_named_tasks USING btree (task_namespace_id, name, version);
1988
+
1989
+
1990
+ --
1991
+ -- Name: named_tasks_steps_ids_unique; Type: INDEX; Schema: public; Owner: -
1992
+ --
1993
+
1994
+ CREATE UNIQUE INDEX named_tasks_steps_ids_unique ON public.tasker_named_tasks_named_steps USING btree (named_task_id, named_step_id);
1995
+
1996
+
1997
+ --
1998
+ -- Name: named_tasks_task_namespace_id_index; Type: INDEX; Schema: public; Owner: -
1999
+ --
2000
+
2001
+ CREATE INDEX named_tasks_task_namespace_id_index ON public.tasker_named_tasks USING btree (task_namespace_id);
2002
+
2003
+
2004
+ --
2005
+ -- Name: named_tasks_version_index; Type: INDEX; Schema: public; Owner: -
2006
+ --
2007
+
2008
+ CREATE INDEX named_tasks_version_index ON public.tasker_named_tasks USING btree (version);
2009
+
2010
+
2011
+ --
2012
+ -- Name: task_annotations_annotation_idx; Type: INDEX; Schema: public; Owner: -
2013
+ --
2014
+
2015
+ CREATE INDEX task_annotations_annotation_idx ON public.tasker_task_annotations USING gin (annotation);
2016
+
2017
+
2018
+ --
2019
+ -- Name: task_annotations_annotation_idx1; Type: INDEX; Schema: public; Owner: -
2020
+ --
2021
+
2022
+ CREATE INDEX task_annotations_annotation_idx1 ON public.tasker_task_annotations USING gin (annotation jsonb_path_ops);
2023
+
2024
+
2025
+ --
2026
+ -- Name: task_annotations_annotation_type_id_index; Type: INDEX; Schema: public; Owner: -
2027
+ --
2028
+
2029
+ CREATE INDEX task_annotations_annotation_type_id_index ON public.tasker_task_annotations USING btree (annotation_type_id);
2030
+
2031
+
2032
+ --
2033
+ -- Name: task_annotations_task_id_index; Type: INDEX; Schema: public; Owner: -
2034
+ --
2035
+
2036
+ CREATE INDEX task_annotations_task_id_index ON public.tasker_task_annotations USING btree (task_id);
2037
+
2038
+
2039
+ --
2040
+ -- Name: task_namespaces_name_index; Type: INDEX; Schema: public; Owner: -
2041
+ --
2042
+
2043
+ CREATE INDEX task_namespaces_name_index ON public.tasker_task_namespaces USING btree (name);
2044
+
2045
+
2046
+ --
2047
+ -- Name: task_namespaces_name_unique; Type: INDEX; Schema: public; Owner: -
2048
+ --
2049
+
2050
+ CREATE UNIQUE INDEX task_namespaces_name_unique ON public.tasker_task_namespaces USING btree (name);
2051
+
2052
+
2053
+ --
2054
+ -- Name: tasks_context_idx; Type: INDEX; Schema: public; Owner: -
2055
+ --
2056
+
2057
+ CREATE INDEX tasks_context_idx ON public.tasker_tasks USING gin (context);
2058
+
2059
+
2060
+ --
2061
+ -- Name: tasks_context_idx1; Type: INDEX; Schema: public; Owner: -
2062
+ --
2063
+
2064
+ CREATE INDEX tasks_context_idx1 ON public.tasker_tasks USING gin (context jsonb_path_ops);
2065
+
2066
+
2067
+ --
2068
+ -- Name: tasks_identity_hash_index; Type: INDEX; Schema: public; Owner: -
2069
+ --
2070
+
2071
+ CREATE INDEX tasks_identity_hash_index ON public.tasker_tasks USING btree (identity_hash);
2072
+
2073
+
2074
+ --
2075
+ -- Name: tasks_named_task_id_index; Type: INDEX; Schema: public; Owner: -
2076
+ --
2077
+
2078
+ CREATE INDEX tasks_named_task_id_index ON public.tasker_tasks USING btree (named_task_id);
2079
+
2080
+
2081
+ --
2082
+ -- Name: tasks_requested_at_index; Type: INDEX; Schema: public; Owner: -
2083
+ --
2084
+
2085
+ CREATE INDEX tasks_requested_at_index ON public.tasker_tasks USING btree (requested_at);
2086
+
2087
+
2088
+ --
2089
+ -- Name: tasks_source_system_index; Type: INDEX; Schema: public; Owner: -
2090
+ --
2091
+
2092
+ CREATE INDEX tasks_source_system_index ON public.tasker_tasks USING btree (source_system);
2093
+
2094
+
2095
+ --
2096
+ -- Name: tasks_tags_idx; Type: INDEX; Schema: public; Owner: -
2097
+ --
2098
+
2099
+ CREATE INDEX tasks_tags_idx ON public.tasker_tasks USING gin (tags);
2100
+
2101
+
2102
+ --
2103
+ -- Name: tasks_tags_idx1; Type: INDEX; Schema: public; Owner: -
2104
+ --
2105
+
2106
+ CREATE INDEX tasks_tags_idx1 ON public.tasker_tasks USING gin (tags jsonb_path_ops);
2107
+
2108
+
2109
+ --
2110
+ -- Name: workflow_steps_last_attempted_at_index; Type: INDEX; Schema: public; Owner: -
2111
+ --
2112
+
2113
+ CREATE INDEX workflow_steps_last_attempted_at_index ON public.tasker_workflow_steps USING btree (last_attempted_at);
2114
+
2115
+
2116
+ --
2117
+ -- Name: workflow_steps_named_step_id_index; Type: INDEX; Schema: public; Owner: -
2118
+ --
2119
+
2120
+ CREATE INDEX workflow_steps_named_step_id_index ON public.tasker_workflow_steps USING btree (named_step_id);
2121
+
2122
+
2123
+ --
2124
+ -- Name: workflow_steps_processed_at_index; Type: INDEX; Schema: public; Owner: -
2125
+ --
2126
+
2127
+ CREATE INDEX workflow_steps_processed_at_index ON public.tasker_workflow_steps USING btree (processed_at);
2128
+
2129
+
2130
+ --
2131
+ -- Name: workflow_steps_task_id_index; Type: INDEX; Schema: public; Owner: -
2132
+ --
2133
+
2134
+ CREATE INDEX workflow_steps_task_id_index ON public.tasker_workflow_steps USING btree (task_id);
2135
+
2136
+
2137
+ --
2138
+ -- Name: tasker_dependent_system_object_maps dependent_system_object_maps_dependent_system_one_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
2139
+ --
2140
+
2141
+ ALTER TABLE ONLY public.tasker_dependent_system_object_maps
2142
+ ADD CONSTRAINT dependent_system_object_maps_dependent_system_one_id_foreign FOREIGN KEY (dependent_system_one_id) REFERENCES public.tasker_dependent_systems(dependent_system_id);
2143
+
2144
+
2145
+ --
2146
+ -- Name: tasker_dependent_system_object_maps dependent_system_object_maps_dependent_system_two_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
2147
+ --
2148
+
2149
+ ALTER TABLE ONLY public.tasker_dependent_system_object_maps
2150
+ ADD CONSTRAINT dependent_system_object_maps_dependent_system_two_id_foreign FOREIGN KEY (dependent_system_two_id) REFERENCES public.tasker_dependent_systems(dependent_system_id);
2151
+
2152
+
2153
+ --
2154
+ -- Name: tasker_named_tasks fk_rails_16a0297759; Type: FK CONSTRAINT; Schema: public; Owner: -
2155
+ --
2156
+
2157
+ ALTER TABLE ONLY public.tasker_named_tasks
2158
+ ADD CONSTRAINT fk_rails_16a0297759 FOREIGN KEY (task_namespace_id) REFERENCES public.tasker_task_namespaces(task_namespace_id);
2159
+
2160
+
2161
+ --
2162
+ -- Name: tasker_workflow_step_transitions fk_rails_6e0f6eb833; Type: FK CONSTRAINT; Schema: public; Owner: -
2163
+ --
2164
+
2165
+ ALTER TABLE ONLY public.tasker_workflow_step_transitions
2166
+ ADD CONSTRAINT fk_rails_6e0f6eb833 FOREIGN KEY (workflow_step_id) REFERENCES public.tasker_workflow_steps(workflow_step_id);
2167
+
2168
+
2169
+ --
2170
+ -- Name: tasker_workflow_step_edges fk_rails_7b4652ccf2; Type: FK CONSTRAINT; Schema: public; Owner: -
2171
+ --
2172
+
2173
+ ALTER TABLE ONLY public.tasker_workflow_step_edges
2174
+ ADD CONSTRAINT fk_rails_7b4652ccf2 FOREIGN KEY (from_step_id) REFERENCES public.tasker_workflow_steps(workflow_step_id);
2175
+
2176
+
2177
+ --
2178
+ -- Name: tasker_workflow_step_edges fk_rails_93ec0bf6eb; Type: FK CONSTRAINT; Schema: public; Owner: -
2179
+ --
2180
+
2181
+ ALTER TABLE ONLY public.tasker_workflow_step_edges
2182
+ ADD CONSTRAINT fk_rails_93ec0bf6eb FOREIGN KEY (to_step_id) REFERENCES public.tasker_workflow_steps(workflow_step_id);
2183
+
2184
+
2185
+ --
2186
+ -- Name: tasker_task_transitions fk_rails_e8caec803c; Type: FK CONSTRAINT; Schema: public; Owner: -
2187
+ --
2188
+
2189
+ ALTER TABLE ONLY public.tasker_task_transitions
2190
+ ADD CONSTRAINT fk_rails_e8caec803c FOREIGN KEY (task_id) REFERENCES public.tasker_tasks(task_id);
2191
+
2192
+
2193
+ --
2194
+ -- Name: tasker_named_steps named_steps_dependent_system_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
2195
+ --
2196
+
2197
+ ALTER TABLE ONLY public.tasker_named_steps
2198
+ ADD CONSTRAINT named_steps_dependent_system_id_foreign FOREIGN KEY (dependent_system_id) REFERENCES public.tasker_dependent_systems(dependent_system_id);
2199
+
2200
+
2201
+ --
2202
+ -- Name: tasker_named_tasks_named_steps named_tasks_named_steps_named_step_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
2203
+ --
2204
+
2205
+ ALTER TABLE ONLY public.tasker_named_tasks_named_steps
2206
+ ADD CONSTRAINT named_tasks_named_steps_named_step_id_foreign FOREIGN KEY (named_step_id) REFERENCES public.tasker_named_steps(named_step_id);
2207
+
2208
+
2209
+ --
2210
+ -- Name: tasker_named_tasks_named_steps named_tasks_named_steps_named_task_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
2211
+ --
2212
+
2213
+ ALTER TABLE ONLY public.tasker_named_tasks_named_steps
2214
+ ADD CONSTRAINT named_tasks_named_steps_named_task_id_foreign FOREIGN KEY (named_task_id) REFERENCES public.tasker_named_tasks(named_task_id);
2215
+
2216
+
2217
+ --
2218
+ -- Name: tasker_task_annotations task_annotations_annotation_type_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
2219
+ --
2220
+
2221
+ ALTER TABLE ONLY public.tasker_task_annotations
2222
+ ADD CONSTRAINT task_annotations_annotation_type_id_foreign FOREIGN KEY (annotation_type_id) REFERENCES public.tasker_annotation_types(annotation_type_id);
2223
+
2224
+
2225
+ --
2226
+ -- Name: tasker_task_annotations task_annotations_task_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
2227
+ --
2228
+
2229
+ ALTER TABLE ONLY public.tasker_task_annotations
2230
+ ADD CONSTRAINT task_annotations_task_id_foreign FOREIGN KEY (task_id) REFERENCES public.tasker_tasks(task_id);
2231
+
2232
+
2233
+ --
2234
+ -- Name: tasker_tasks tasks_named_task_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
2235
+ --
2236
+
2237
+ ALTER TABLE ONLY public.tasker_tasks
2238
+ ADD CONSTRAINT tasks_named_task_id_foreign FOREIGN KEY (named_task_id) REFERENCES public.tasker_named_tasks(named_task_id);
2239
+
2240
+
2241
+ --
2242
+ -- Name: tasker_workflow_steps workflow_steps_named_step_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
2243
+ --
2244
+
2245
+ ALTER TABLE ONLY public.tasker_workflow_steps
2246
+ ADD CONSTRAINT workflow_steps_named_step_id_foreign FOREIGN KEY (named_step_id) REFERENCES public.tasker_named_steps(named_step_id);
2247
+
2248
+
2249
+ --
2250
+ -- Name: tasker_workflow_steps workflow_steps_task_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
2251
+ --
2252
+
2253
+ ALTER TABLE ONLY public.tasker_workflow_steps
2254
+ ADD CONSTRAINT workflow_steps_task_id_foreign FOREIGN KEY (task_id) REFERENCES public.tasker_tasks(task_id);