{-# OPTIONS_HADDOCK not-home #-}

-- | Internal to the arbiter packages. Not covered by the PVP.
--
-- Table-name lists for an arbiter schema.
module Arbiter.Core.SchemaTables
  ( allSchemaTables
  , sharedArbiterTables
  ) where

import Arbiter.Core.Concurrency.Schema (arbiterConcurrencyPoliciesTableName, arbiterConcurrencyTableName)
import Arbiter.Core.CronSchedule (cronSchedulesTableName)
import Arbiter.Core.Gates (arbiterGatesTableName)
import Arbiter.Core.Job.Schema (TableName, queueTableNames)
import Arbiter.Core.Queues (arbiterQueuesTableName)
import Arbiter.Core.RateLimit.Schema (arbiterRateLimitPoliciesTableName, arbiterRateLimitsTableName)
import Arbiter.Core.Worker (arbiterWorkersTableName)

-- | Every schema-wide arbiter table except the migration history table, unqualified and unquoted.
sharedArbiterTables :: [TableName]
sharedArbiterTables :: [TableName]
sharedArbiterTables =
  [ TableName
arbiterGatesTableName
  , TableName
arbiterWorkersTableName
  , TableName
arbiterQueuesTableName
  , TableName
arbiterConcurrencyTableName
  , TableName
arbiterConcurrencyPoliciesTableName
  , TableName
arbiterRateLimitsTableName
  , TableName
arbiterRateLimitPoliciesTableName
  , TableName
cronSchedulesTableName
  ]

-- | Every table an arbiter schema holds for the given queues, except the migration
-- history table.
allSchemaTables :: [TableName] -> [TableName]
allSchemaTables :: [TableName] -> [TableName]
allSchemaTables [TableName]
queueTables = (TableName -> [TableName]) -> [TableName] -> [TableName]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap TableName -> [TableName]
queueTableNames [TableName]
queueTables [TableName] -> [TableName] -> [TableName]
forall a. Semigroup a => a -> a -> a
<> [TableName]
sharedArbiterTables