sqitch-plan: Parse and render sqitch.plan files

[ database, library, mit ] [ Propose Tags ] [ Report a vulnerability ]

A parser and renderer for the plan files of sqitch, the database change manager. It reads the whole format (pragmas, changes with dependencies, tags, notes, comments and reworks), keeps each entry's line number, and writes a parsed plan back byte for byte.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0
Change log CHANGELOG.md
Dependencies base (>=4.20 && <5), containers (>=0.6 && <0.9), text (>=2.0 && <2.2), time (>=1.12 && <1.16) [details]
Tested with ghc ==9.10.3 || ==9.12.4 || ==9.14.1
License MIT
Copyright 2026 Kronor
Author José Lorenzo Rodríguez
Maintainer lorenzo@kronor.io
Uploaded by lorenzo at 2026-11-24T11:14:38Z
Category Database
Home page https://github.com/kronor-io/sqitch-plan
Bug tracker https://github.com/kronor-io/sqitch-plan/issues
Source repo head: git clone https://github.com/kronor-io/sqitch-plan
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 2 total (2 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for sqitch-plan-0.1.0.0

[back to package description]

sqitch-plan

Parse, query and render sqitch's sqitch.plan files.

import Data.Text qualified as Text
import Data.Text.IO qualified as Text.IO
import Sqitch.Plan qualified as Plan

main :: IO ()
main = do
    src <- Text.IO.readFile "sqitch.plan"
    plan <- either (fail . Text.unpack . Plan.renderParseError) pure (Plan.parsePlan src)
    mapM_ (\c -> print (c.line, c.value.name, Plan.reworkTag c.value)) (Plan.changes plan)
  • The whole format, following sqitch's own reader (App::Sqitch::Plan): %pragma=value lines, blank and # comment lines, change lines with [dependencies] (requires, !conflicts, change@tag, @tag, project:change, change IDs), planner timestamp, name and <email>, # notes, tag lines, and the legacy +/- operators. Sqitch's name rules are enforced, including the reserved HEAD / ROOT and the stricter rules for declaring tags. Notes built with newChange / newTag are escaped as sqitch escapes them; noteText undoes it.
  • Line numbers: every entry is a Located value carrying its 1-based line.
  • Round trip: whitespace is kept in each entry's layout, so render <$> parsePlan src == Right src for every plan the parser accepts. newChange / newTag build entries laid out the way sqitch add and sqitch tag write them, and appendItems adds them to a plan.
  • Queries: changes, tags, steps (both, in order), occurrences, lastOccurrence, changesAfter, isTagged, isReworked, reworkTag, reworks, pragmaValue / projectName / uri.
  • Light: depends on base, text, containers and time only.

Install

sqitch-plan is not on Hackage yet. Pin a commit from a cabal.project:

source-repository-package
  type:     git
  location: https://github.com/kronor-io/sqitch-plan
  tag:      <commit>

Tests

cabal test round-trips a synthetic plan (test/fixtures/shop.plan) that uses every construct of the format, with odd whitespace, and checks its changes, tags, pragmas, dependencies, notes and reworks against expected values written by hand. Small hand-written plans cover each grammar feature and each error.

When run inside a git checkout, the tests also round-trip every *sqitch*.plan file tracked there, so a project that vendors this package gets its own plans checked. The package has been tested against large real-world plans this way.