mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-18 04:51:35 +03:00
342391f39d
This upgrades the version of Ormolu required by the HGE repository to v0.5.0.1, and reformats all code accordingly. Ormolu v0.5 reformats code that uses infix operators. This is mostly useful, adding newlines and indentation to make it clear which operators are applied first, but in some cases, it's unpleasant. To make this easier on the eyes, I had to do the following: * Add a few fixity declarations (search for `infix`) * Add parentheses to make precedence clear, allowing Ormolu to keep everything on one line * Rename `relevantEq` to `(==~)` in #6651 and set it to `infix 4` * Add a few _.ormolu_ files (thanks to @hallettj for helping me get started), mostly for Autodocodec operators that don't have explicit fixity declarations In general, I think these changes are quite reasonable. They mostly affect indentation. PR-URL: https://github.com/hasura/graphql-engine-mono/pull/6675 GitOrigin-RevId: cd47d87f1d089fb0bc9dcbbe7798dbceedcd7d83
58 lines
1.9 KiB
Haskell
58 lines
1.9 KiB
Haskell
{-# LANGUAGE TemplateHaskell #-}
|
|
|
|
-- | The Downgrade Command Parser
|
|
module Hasura.Server.Init.Arg.Command.Downgrade
|
|
( downgradeCommandParser,
|
|
)
|
|
where
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
import Data.FileEmbed qualified as Embed
|
|
import Data.String qualified as String
|
|
import Hasura.Prelude
|
|
import Hasura.Server.Init.Config qualified as Config
|
|
import Language.Haskell.TH.Syntax qualified as TH
|
|
import Options.Applicative qualified as Opt
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
-- | This implements the mapping between application versions
|
|
-- and catalog schema versions.
|
|
downgradeShortcuts :: [(String, String)]
|
|
downgradeShortcuts =
|
|
$( do
|
|
let s = $(Embed.makeRelativeToProject "src-rsr/catalog_versions.txt" >>= Embed.embedStringFile)
|
|
|
|
parseVersions = map (parseVersion . words) . lines
|
|
|
|
parseVersion [tag, version] = (tag, version)
|
|
parseVersion other = error ("unrecognized tag/catalog mapping " ++ show other)
|
|
TH.lift (parseVersions s)
|
|
)
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
downgradeCommandParser :: Opt.Parser Config.DowngradeOptions
|
|
downgradeCommandParser =
|
|
Config.DowngradeOptions
|
|
<$> choice
|
|
( Opt.strOption
|
|
( Opt.long "to-catalog-version"
|
|
<> Opt.metavar "<VERSION>"
|
|
<> Opt.help "The target catalog schema version (e.g. 31)"
|
|
)
|
|
: map (uncurry shortcut) downgradeShortcuts
|
|
)
|
|
<*> Opt.switch
|
|
( Opt.long "dryRun"
|
|
<> Opt.help "Don't run any migrations, just print out the SQL."
|
|
)
|
|
where
|
|
shortcut v catalogVersion =
|
|
Opt.flag'
|
|
(String.fromString catalogVersion)
|
|
( Opt.long ("to-" <> v)
|
|
<> Opt.help ("Downgrade to graphql-engine version " <> v <> " (equivalent to --to-catalog-version " <> catalogVersion <> ")")
|
|
)
|