| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Arbiter.Migrations
Description
Versioned, tracked migrations for job queue schemas.
Uses the postgresql-migration library to:
- Track which migrations have been run in a database table
- Run migrations in order
- Prevent re-running completed migrations
- Support incremental schema changes
Migration history is stored in a schema_migrations table inside the
target schema (e.g., arbiter.schema_migrations).
Synopsis
- data MigrationConfig = MigrationConfig {}
- defaultMigrationConfig :: MigrationConfig
- runMigrationsForRegistry :: forall (registry :: JobPayloadRegistry). RegistryTables registry => Proxy registry -> ByteString -> SchemaName -> MigrationConfig -> IO (MigrationResult String)
- runMigrationsTrackedForTables :: ByteString -> SchemaName -> [TableName] -> MigrationConfig -> IO (MigrationResult String)
- jobQueueMigrationsForTable :: SchemaName -> TableName -> MigrationConfig -> [MigrationCommand]
- data MigrationResult a
Configuration
data MigrationConfig Source #
Configuration for job queue migrations
Controls which optional features are enabled when creating job queue tables.
Constructors
| MigrationConfig | |
Fields
| |
Instances
| Show MigrationConfig Source # | |
Defined in Arbiter.Migrations Methods showsPrec :: Int -> MigrationConfig -> ShowS # show :: MigrationConfig -> String # showList :: [MigrationConfig] -> ShowS # | |
| Eq MigrationConfig Source # | |
Defined in Arbiter.Migrations Methods (==) :: MigrationConfig -> MigrationConfig -> Bool # (/=) :: MigrationConfig -> MigrationConfig -> Bool # | |
defaultMigrationConfig :: MigrationConfig Source #
Default migration configuration
Tracked Migrations
runMigrationsForRegistry Source #
Arguments
| :: forall (registry :: JobPayloadRegistry). RegistryTables registry | |
| => Proxy registry | Proxy for the job payload registry |
| -> ByteString | Database connection string |
| -> SchemaName | Schema name |
| -> MigrationConfig | Migration configuration |
| -> IO (MigrationResult String) | Migration results |
Run migrations for all tables in a queue registry.
Creates tables for each payload type in the registry (main + DLQ) within a single PostgreSQL schema. The schema itself is created first, outside of migration tracking. PostgreSQL notices are suppressed during migration.
Example:
type AppRegistry =
'[ '("email_jobs", EmailPayload)
, '("order_jobs", OrderPayload)
]
main :: IO ()
main = do
result <- runMigrationsForRegistry
(Proxy @AppRegistry)
"host=localhost dbname=mydb"
"arbiter"
defaultMigrationConfig
runMigrationsTrackedForTables Source #
Arguments
| :: ByteString | Database connection string |
| -> SchemaName | Schema name |
| -> [TableName] | Table names to create |
| -> MigrationConfig | Migration configuration |
| -> IO (MigrationResult String) |
Run migrations for multiple tables within a single schema.
jobQueueMigrationsForTable Source #
Arguments
| :: SchemaName | Schema name |
| -> TableName | Table name |
| -> MigrationConfig | Migration configuration |
| -> [MigrationCommand] | List of migration commands |
All job queue migrations for a single table
This creates migrations for one table and its DLQ within a schema. Each table gets its own set of migrations with unique version identifiers.
Re-exports
data MigrationResult a #
Constructors
| MigrationError a | |
| MigrationSuccess |