2022-03-16 03:39:21 +03:00
|
|
|
|
{-# LANGUAGE QuasiQuotes #-}
|
|
|
|
|
{-# LANGUAGE TemplateHaskell #-}
|
|
|
|
|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
-- | Funtions related to @hdb_catalog@ schema prior to metadata separation (catalog version < 43).
|
|
|
|
|
module Hasura.RQL.DDL.Schema.LegacyCatalog
|
|
|
|
|
( saveMetadataToHdbTables,
|
|
|
|
|
fetchMetadataFromHdbTables,
|
|
|
|
|
recreateSystemMetadata,
|
2021-08-17 10:01:14 +03:00
|
|
|
|
addCronTriggerForeignKeyConstraint,
|
2022-04-22 14:33:36 +03:00
|
|
|
|
|
|
|
|
|
-- * export for testing
|
|
|
|
|
parseLegacyRemoteRelationshipDefinition,
|
2020-12-08 17:22:31 +03:00
|
|
|
|
)
|
|
|
|
|
where
|
2021-09-24 01:56:37 +03:00
|
|
|
|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
import Control.Lens hiding ((.=))
|
|
|
|
|
import Data.Aeson
|
2021-03-16 20:35:35 +03:00
|
|
|
|
import Data.FileEmbed (makeRelativeToProject)
|
2020-12-08 17:22:31 +03:00
|
|
|
|
import Data.HashMap.Strict qualified as HM
|
|
|
|
|
import Data.HashMap.Strict.InsOrd qualified as OMap
|
2022-02-08 19:53:30 +03:00
|
|
|
|
import Data.Text.Extended ((<<>))
|
2020-12-08 17:22:31 +03:00
|
|
|
|
import Data.Text.NonEmpty
|
|
|
|
|
import Data.Time.Clock qualified as C
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
import Database.PG.Query qualified as PG
|
2020-12-08 17:22:31 +03:00
|
|
|
|
import Hasura.Backends.Postgres.Connection
|
2022-10-07 14:55:42 +03:00
|
|
|
|
import Hasura.Backends.Postgres.SQL.Types as Postgres
|
2021-05-11 18:18:31 +03:00
|
|
|
|
import Hasura.Base.Error
|
2020-12-08 17:22:31 +03:00
|
|
|
|
import Hasura.Eventing.ScheduledTrigger
|
2023-04-03 13:18:54 +03:00
|
|
|
|
import Hasura.Function.Cache
|
|
|
|
|
import Hasura.Function.Metadata (FunctionMetadata (..))
|
2020-12-08 17:22:31 +03:00
|
|
|
|
import Hasura.Prelude
|
Clean metadata arguments
## Description
Thanks to #1664, the Metadata API types no longer require a `ToJSON` instance. This PR follows up with a cleanup of the types of the arguments to the metadata API:
- whenever possible, it moves those argument types to where they're used (RQL.DDL.*)
- it removes all unrequired instances (mostly `ToJSON`)
This PR does not attempt to do it for _all_ such argument types. For some of the metadata operations, the type used to describe the argument to the API and used to represent the value in the metadata are one and the same (like for `CreateEndpoint`). Sometimes, the two types are intertwined in complex ways (`RemoteRelationship` and `RemoteRelationshipDef`). In the spirit of only doing uncontroversial cleaning work, this PR only moves types that are not used outside of RQL.DDL.
Furthermore, this is a small step towards separating the different types all jumbled together in RQL.Types.
## Notes
This PR also improves several `FromJSON` instances to make use of `withObject`, and to use a human readable string instead of a type name in error messages whenever possible. For instance:
- before: `expected Object for Object, but encountered X`
after: `expected Object for add computed field, but encountered X`
- before: `Expecting an object for update query`
after: `expected Object for update query, but encountered X`
This PR also renames `CreateFunctionPermission` to `FunctionPermissionArgument`, to remove the quite surprising `type DropFunctionPermission = CreateFunctionPermission`.
This PR also deletes some dead code, mostly in RQL.DML.
This PR also moves a PG-specific source resolving function from DDL.Schema.Source to the only place where it is used: App.hs.
https://github.com/hasura/graphql-engine-mono/pull/1844
GitOrigin-RevId: a594521194bb7fe6a111b02a9e099896f9fed59c
2021-07-27 13:41:42 +03:00
|
|
|
|
import Hasura.RQL.DDL.Action
|
2020-12-08 17:22:31 +03:00
|
|
|
|
import Hasura.RQL.DDL.ComputedField
|
|
|
|
|
import Hasura.RQL.DDL.Permission
|
2021-12-01 07:53:34 +03:00
|
|
|
|
import Hasura.RQL.DDL.RemoteRelationship
|
2022-04-27 16:57:28 +03:00
|
|
|
|
import Hasura.RQL.Types.Action
|
|
|
|
|
import Hasura.RQL.Types.Allowlist
|
|
|
|
|
import Hasura.RQL.Types.Backend
|
2023-04-24 21:35:48 +03:00
|
|
|
|
import Hasura.RQL.Types.BackendType
|
2022-04-27 16:57:28 +03:00
|
|
|
|
import Hasura.RQL.Types.Common
|
|
|
|
|
import Hasura.RQL.Types.CustomTypes
|
|
|
|
|
import Hasura.RQL.Types.EventTrigger
|
|
|
|
|
import Hasura.RQL.Types.Metadata
|
|
|
|
|
import Hasura.RQL.Types.Permission
|
|
|
|
|
import Hasura.RQL.Types.QueryCollection
|
|
|
|
|
import Hasura.RQL.Types.Relationships.Local
|
|
|
|
|
import Hasura.RQL.Types.Relationships.Remote
|
|
|
|
|
import Hasura.RQL.Types.ScheduledTrigger
|
|
|
|
|
import Hasura.RQL.Types.SchemaCache
|
scaffolding for remote-schemas module
The main aim of the PR is:
1. To set up a module structure for 'remote-schemas' package.
2. Move parts by the remote schema codebase into the new module structure to validate it.
## Notes to the reviewer
Why a PR with large-ish diff?
1. We've been making progress on the MM project but we don't yet know long it is going to take us to get to the first milestone. To understand this better, we need to figure out the unknowns as soon as possible. Hence I've taken a stab at the first two items in the [end-state](https://gist.github.com/0x777/ca2bdc4284d21c3eec153b51dea255c9) document to figure out the unknowns. Unsurprisingly, there are a bunch of issues that we haven't discussed earlier. These are documented in the 'open questions' section.
1. The diff is large but that is only code moved around and I've added a section that documents how things are moved. In addition, there are fair number of PR comments to help with the review process.
## Changes in the PR
### Module structure
Sets up the module structure as follows:
```
Hasura/
RemoteSchema/
Metadata/
Types.hs
SchemaCache/
Types.hs
Permission.hs
RemoteRelationship.hs
Build.hs
MetadataAPI/
Types.hs
Execute.hs
```
### 1. Types representing metadata are moved
Types that capture metadata information (currently scattered across several RQL modules) are moved into `Hasura.RemoteSchema.Metadata.Types`.
- This new module only depends on very 'core' modules such as
`Hasura.Session` for the notion of roles and `Hasura.Incremental` for `Cacheable` typeclass.
- The requirement on database modules is avoided by generalizing the remote schemas metadata to accept an arbitrary 'r' for a remote relationship
definition.
### 2. SchemaCache related types and build logic have been moved
Types that represent remote schemas information in SchemaCache are moved into `Hasura.RemoteSchema.SchemaCache.Types`.
Similar to `H.RS.Metadata.Types`, this module depends on 'core' modules except for `Hasura.GraphQL.Parser.Variable`. It has something to do with remote relationships but I haven't spent time looking into it. The validation of 'remote relationships to remote schema' is also something that needs to be looked at.
Rips out the logic that builds remote schema's SchemaCache information from the monolithic `buildSchemaCacheRule` and moves it into `Hasura.RemoteSchema.SchemaCache.Build`. Further, the `.SchemaCache.Permission` and `.SchemaCache.RemoteRelationship` have been created from existing modules that capture schema cache building logic for those two components.
This was a fair amount of work. On main, currently remote schema's SchemaCache information is built in two phases - in the first phase, 'permissions' and 'remote relationships' are ignored and in the second phase they are filled in.
While remote relationships can only be resolved after partially resolving sources and other remote schemas, the same isn't true for permissions. Further, most of the work that is done to resolve remote relationships can be moved to the first phase so that the second phase can be a very simple traversal.
This is the approach that was taken - resolve permissions and as much as remote relationships information in the first phase.
### 3. Metadata APIs related types and build logic have been moved
The types that represent remote schema related metadata APIs and the execution logic have been moved to `Hasura.RemoteSchema.MetadataAPI.Types` and `.Execute` modules respectively.
## Open questions:
1. `Hasura.RemoteSchema.Metadata.Types` is so called because I was hoping that all of the metadata related APIs of remote schema can be brought in at `Hasura.RemoteSchema.Metadata.API`. However, as metadata APIs depended on functions from `SchemaCache` module (see [1](https://github.com/hasura/graphql-engine-mono/blob/ceba6d62264603ee5d279814677b29bcc43ecaea/server/src-lib/Hasura/RQL/DDL/RemoteSchema.hs#L55) and [2](https://github.com/hasura/graphql-engine-mono/blob/ceba6d62264603ee5d279814677b29bcc43ecaea/server/src-lib/Hasura/RQL/DDL/RemoteSchema.hs#L91), it made more sense to create a separate top-level module for `MetadataAPI`s.
Maybe we can just have `Hasura.RemoteSchema.Metadata` and get rid of the extra nesting or have `Hasura.RemoteSchema.Metadata.{Core,Permission,RemoteRelationship}` if we want to break them down further.
1. `buildRemoteSchemas` in `H.RS.SchemaCache.Build` has the following type:
```haskell
buildRemoteSchemas ::
( ArrowChoice arr,
Inc.ArrowDistribute arr,
ArrowWriter (Seq CollectedInfo) arr,
Inc.ArrowCache m arr,
MonadIO m,
HasHttpManagerM m,
Inc.Cacheable remoteRelationshipDefinition,
ToJSON remoteRelationshipDefinition,
MonadError QErr m
) =>
Env.Environment ->
( (Inc.Dependency (HashMap RemoteSchemaName Inc.InvalidationKey), OrderedRoles),
[RemoteSchemaMetadataG remoteRelationshipDefinition]
)
`arr` HashMap RemoteSchemaName (PartiallyResolvedRemoteSchemaCtxG remoteRelationshipDefinition, MetadataObject)
```
Note the dependence on `CollectedInfo` which is defined as
```haskell
data CollectedInfo
= CIInconsistency InconsistentMetadata
| CIDependency
MetadataObject
-- ^ for error reporting on missing dependencies
SchemaObjId
SchemaDependency
deriving (Eq)
```
this pretty much means that remote schemas is dependent on types from databases, actions, ....
How do we fix this? Maybe introduce a typeclass such as `ArrowCollectRemoteSchemaDependencies` which is defined in `Hasura.RemoteSchema` and then implemented in graphql-engine?
1. The dependency on `buildSchemaCacheFor` in `.MetadataAPI.Execute` which has the following signature:
```haskell
buildSchemaCacheFor ::
(QErrM m, CacheRWM m, MetadataM m) =>
MetadataObjId ->
MetadataModifier ->
```
This can be easily resolved if we restrict what the metadata APIs are allowed to do. Currently, they operate in an unfettered access to modify SchemaCache (the `CacheRWM` constraint):
```haskell
runAddRemoteSchema ::
( QErrM m,
CacheRWM m,
MonadIO m,
HasHttpManagerM m,
MetadataM m,
Tracing.MonadTrace m
) =>
Env.Environment ->
AddRemoteSchemaQuery ->
m EncJSON
```
This should instead be changed to restrict remote schema APIs to only modify remote schema metadata (but has access to the remote schemas part of the schema cache), this dependency is completely removed.
```haskell
runAddRemoteSchema ::
( QErrM m,
MonadIO m,
HasHttpManagerM m,
MonadReader RemoteSchemasSchemaCache m,
MonadState RemoteSchemaMetadata m,
Tracing.MonadTrace m
) =>
Env.Environment ->
AddRemoteSchemaQuery ->
m RemoteSchemeMetadataObjId
```
The idea is that the core graphql-engine would call these functions and then call
`buildSchemaCacheFor`.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/6291
GitOrigin-RevId: 51357148c6404afe70219afa71bd1d59bdf4ffc6
2022-10-21 06:13:07 +03:00
|
|
|
|
import Hasura.RemoteSchema.Metadata
|
2021-09-24 01:56:37 +03:00
|
|
|
|
|
2020-12-28 15:56:00 +03:00
|
|
|
|
saveMetadataToHdbTables ::
|
2022-04-22 19:01:07 +03:00
|
|
|
|
(MonadTx m, MonadReader SystemDefined m) => MetadataNoSources -> m ()
|
2020-12-28 15:56:00 +03:00
|
|
|
|
saveMetadataToHdbTables
|
|
|
|
|
( MetadataNoSources
|
|
|
|
|
tables
|
|
|
|
|
functions
|
|
|
|
|
schemas
|
|
|
|
|
collections
|
2020-12-08 17:22:31 +03:00
|
|
|
|
allowlist
|
|
|
|
|
customTypes
|
|
|
|
|
actions
|
|
|
|
|
cronTriggers
|
|
|
|
|
) = do
|
|
|
|
|
withPathK "tables" $ do
|
|
|
|
|
indexedForM_ tables $ \TableMetadata {..} -> do
|
|
|
|
|
-- Save table
|
|
|
|
|
saveTableToCatalog _tmTable _tmIsEnum _tmConfiguration
|
2021-09-24 01:56:37 +03:00
|
|
|
|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
-- Relationships
|
|
|
|
|
withPathK "object_relationships" $
|
|
|
|
|
indexedForM_ _tmObjectRelationships $ \objRel ->
|
|
|
|
|
insertRelationshipToCatalog _tmTable ObjRel objRel
|
|
|
|
|
withPathK "array_relationships" $
|
|
|
|
|
indexedForM_ _tmArrayRelationships $ \arrRel ->
|
|
|
|
|
insertRelationshipToCatalog _tmTable ArrRel arrRel
|
2021-09-24 01:56:37 +03:00
|
|
|
|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
-- Computed Fields
|
|
|
|
|
withPathK "computed_fields" $
|
|
|
|
|
indexedForM_ _tmComputedFields $
|
|
|
|
|
\(ComputedFieldMetadata name definition comment) ->
|
|
|
|
|
addComputedFieldToCatalog $
|
2020-12-28 15:56:00 +03:00
|
|
|
|
AddComputedField defaultSource _tmTable name definition comment
|
2021-09-24 01:56:37 +03:00
|
|
|
|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
-- Remote Relationships
|
|
|
|
|
withPathK "remote_relationships" $
|
|
|
|
|
indexedForM_ _tmRemoteRelationships $
|
2021-12-14 09:45:13 +03:00
|
|
|
|
\RemoteRelationship {..} -> do
|
2021-07-23 02:06:10 +03:00
|
|
|
|
addRemoteRelationshipToCatalog $
|
2021-12-14 09:45:13 +03:00
|
|
|
|
CreateFromSourceRelationship defaultSource _tmTable _rrName _rrDefinition
|
2021-09-24 01:56:37 +03:00
|
|
|
|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
-- Permissions
|
|
|
|
|
withPathK "insert_permissions" $ processPerms _tmTable _tmInsertPermissions
|
|
|
|
|
withPathK "select_permissions" $ processPerms _tmTable _tmSelectPermissions
|
|
|
|
|
withPathK "update_permissions" $ processPerms _tmTable _tmUpdatePermissions
|
|
|
|
|
withPathK "delete_permissions" $ processPerms _tmTable _tmDeletePermissions
|
2021-09-24 01:56:37 +03:00
|
|
|
|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
-- Event triggers
|
|
|
|
|
withPathK "event_triggers" $
|
|
|
|
|
indexedForM_ _tmEventTriggers $
|
|
|
|
|
\etc -> addEventTriggerToCatalog _tmTable etc
|
2021-09-24 01:56:37 +03:00
|
|
|
|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
-- sql functions
|
|
|
|
|
withPathK "functions" $
|
|
|
|
|
indexedForM_ functions $
|
2021-09-24 12:18:40 +03:00
|
|
|
|
\(FunctionMetadata function config _ _) -> addFunctionToCatalog function config
|
2021-09-24 01:56:37 +03:00
|
|
|
|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
-- query collections
|
2022-04-22 19:01:07 +03:00
|
|
|
|
systemDefined <- ask
|
2020-12-08 17:22:31 +03:00
|
|
|
|
withPathK "query_collections" $
|
|
|
|
|
indexedForM_ collections $
|
|
|
|
|
\c -> liftTx $ addCollectionToCatalog c systemDefined
|
2021-09-24 01:56:37 +03:00
|
|
|
|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
-- allow list
|
|
|
|
|
withPathK "allowlist" $ do
|
2022-02-08 19:53:30 +03:00
|
|
|
|
indexedForM_ allowlist $ \(AllowlistEntry collectionName scope) -> do
|
|
|
|
|
unless (scope == AllowlistScopeGlobal) $
|
|
|
|
|
throw400 NotSupported $
|
|
|
|
|
"cannot downgrade to v1 because the "
|
|
|
|
|
<> collectionName
|
|
|
|
|
<<> " added to the allowlist is a role based allowlist"
|
|
|
|
|
liftTx $ addCollectionToAllowlistCatalog collectionName
|
2021-09-24 01:56:37 +03:00
|
|
|
|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
-- remote schemas
|
|
|
|
|
withPathK "remote_schemas" $
|
|
|
|
|
indexedMapM_ (liftTx . addRemoteSchemaToCatalog) schemas
|
2021-09-24 01:56:37 +03:00
|
|
|
|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
-- custom types
|
|
|
|
|
withPathK "custom_types" $ setCustomTypesInCatalog customTypes
|
2021-09-24 01:56:37 +03:00
|
|
|
|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
-- cron triggers
|
|
|
|
|
withPathK "cron_triggers" $
|
|
|
|
|
indexedForM_ cronTriggers $ \ct -> liftTx $ do
|
|
|
|
|
addCronTriggerToCatalog ct
|
2021-09-24 01:56:37 +03:00
|
|
|
|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
-- actions
|
|
|
|
|
withPathK "actions" $
|
|
|
|
|
indexedForM_ actions $ \action -> do
|
|
|
|
|
let createAction =
|
2021-10-29 07:12:27 +03:00
|
|
|
|
CreateAction (_amName action) (_amDefinition action) (_amComment action)
|
2020-12-08 17:22:31 +03:00
|
|
|
|
addActionToCatalog createAction
|
|
|
|
|
withPathK "permissions" $
|
|
|
|
|
indexedForM_ (_amPermissions action) $ \permission -> do
|
|
|
|
|
let createActionPermission =
|
|
|
|
|
CreateActionPermission
|
|
|
|
|
(_amName action)
|
|
|
|
|
(_apmRole permission)
|
|
|
|
|
Nothing
|
|
|
|
|
(_apmComment permission)
|
|
|
|
|
addActionPermissionToCatalog createActionPermission
|
|
|
|
|
where
|
|
|
|
|
processPerms tableName perms = indexedForM_ perms $ \perm -> do
|
2022-04-22 19:01:07 +03:00
|
|
|
|
systemDefined <- ask
|
2022-04-06 15:47:35 +03:00
|
|
|
|
liftTx $ addPermissionToCatalog tableName perm systemDefined
|
2021-09-24 01:56:37 +03:00
|
|
|
|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
saveTableToCatalog ::
|
2022-04-22 19:01:07 +03:00
|
|
|
|
(MonadTx m, MonadReader SystemDefined m) => QualifiedTable -> Bool -> TableConfig ('Postgres 'Vanilla) -> m ()
|
2020-12-08 17:22:31 +03:00
|
|
|
|
saveTableToCatalog (QualifiedObject sn tn) isEnum config = do
|
2022-04-22 19:01:07 +03:00
|
|
|
|
systemDefined <- ask
|
2020-12-08 17:22:31 +03:00
|
|
|
|
liftTx $
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
PG.unitQE
|
2020-12-08 17:22:31 +03:00
|
|
|
|
defaultTxErrorHandler
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
[PG.sql|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
INSERT INTO "hdb_catalog"."hdb_table"
|
|
|
|
|
(table_schema, table_name, is_system_defined, is_enum, configuration)
|
|
|
|
|
VALUES ($1, $2, $3, $4, $5)
|
|
|
|
|
|]
|
|
|
|
|
(sn, tn, systemDefined, isEnum, configVal)
|
|
|
|
|
False
|
|
|
|
|
where
|
2022-09-21 21:40:41 +03:00
|
|
|
|
configVal = PG.ViaJSON $ toJSON config
|
2020-12-08 17:22:31 +03:00
|
|
|
|
|
|
|
|
|
insertRelationshipToCatalog ::
|
2022-04-22 19:01:07 +03:00
|
|
|
|
(MonadTx m, MonadReader SystemDefined m, ToJSON a) =>
|
2020-12-08 17:22:31 +03:00
|
|
|
|
QualifiedTable ->
|
|
|
|
|
RelType ->
|
|
|
|
|
RelDef a ->
|
|
|
|
|
m ()
|
|
|
|
|
insertRelationshipToCatalog (QualifiedObject schema table) relType (RelDef name using comment) = do
|
2022-04-22 19:01:07 +03:00
|
|
|
|
systemDefined <- ask
|
2022-09-21 21:40:41 +03:00
|
|
|
|
let args = (schema, table, name, relTypeToTxt relType, PG.ViaJSON using, comment, systemDefined)
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
liftTx $ PG.unitQE defaultTxErrorHandler query args True
|
2020-12-08 17:22:31 +03:00
|
|
|
|
where
|
|
|
|
|
query =
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
[PG.sql|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
INSERT INTO
|
|
|
|
|
hdb_catalog.hdb_relationship
|
|
|
|
|
(table_schema, table_name, rel_name, rel_type, rel_def, comment, is_system_defined)
|
|
|
|
|
VALUES ($1, $2, $3, $4, $5 :: jsonb, $6, $7) |]
|
|
|
|
|
|
|
|
|
|
addEventTriggerToCatalog ::
|
2021-09-06 14:15:36 +03:00
|
|
|
|
(MonadTx m, Backend ('Postgres pgKind)) =>
|
2020-12-08 17:22:31 +03:00
|
|
|
|
QualifiedTable ->
|
2021-09-06 14:15:36 +03:00
|
|
|
|
EventTriggerConf ('Postgres pgKind) ->
|
2020-12-08 17:22:31 +03:00
|
|
|
|
m ()
|
|
|
|
|
addEventTriggerToCatalog qt etc = liftTx do
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
PG.unitQE
|
2020-12-08 17:22:31 +03:00
|
|
|
|
defaultTxErrorHandler
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
[PG.sql|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
INSERT into hdb_catalog.event_triggers
|
|
|
|
|
(name, type, schema_name, table_name, configuration)
|
|
|
|
|
VALUES ($1, 'table', $2, $3, $4)
|
|
|
|
|
|]
|
2022-09-21 21:40:41 +03:00
|
|
|
|
(name, sn, tn, PG.ViaJSON $ toJSON etc)
|
2020-12-08 17:22:31 +03:00
|
|
|
|
False
|
|
|
|
|
where
|
|
|
|
|
QualifiedObject sn tn = qt
|
2022-11-29 20:41:41 +03:00
|
|
|
|
(EventTriggerConf name _ _ _ _ _ _ _ _ _) = etc
|
2020-12-08 17:22:31 +03:00
|
|
|
|
|
|
|
|
|
addComputedFieldToCatalog ::
|
|
|
|
|
MonadTx m =>
|
2021-04-22 00:44:37 +03:00
|
|
|
|
AddComputedField ('Postgres 'Vanilla) ->
|
|
|
|
|
m ()
|
2020-12-08 17:22:31 +03:00
|
|
|
|
addComputedFieldToCatalog q =
|
|
|
|
|
liftTx $
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
PG.withQE
|
2020-12-08 17:22:31 +03:00
|
|
|
|
defaultTxErrorHandler
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
[PG.sql|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
INSERT INTO hdb_catalog.hdb_computed_field
|
2022-02-16 02:16:34 +03:00
|
|
|
|
(table_schema, table_name, computed_field_name, definition, commentText)
|
2020-12-08 17:22:31 +03:00
|
|
|
|
VALUES ($1, $2, $3, $4, $5)
|
|
|
|
|
|]
|
2022-09-21 21:40:41 +03:00
|
|
|
|
(schemaName, tableName, computedField, PG.ViaJSON definition, commentText)
|
2020-12-08 17:22:31 +03:00
|
|
|
|
True
|
|
|
|
|
where
|
2022-02-16 02:16:34 +03:00
|
|
|
|
commentText = commentToMaybeText comment
|
2020-12-08 17:22:31 +03:00
|
|
|
|
QualifiedObject schemaName tableName = table
|
2020-12-28 15:56:00 +03:00
|
|
|
|
AddComputedField _ table computedField definition comment = q
|
2020-12-08 17:22:31 +03:00
|
|
|
|
|
2021-12-01 07:53:34 +03:00
|
|
|
|
addRemoteRelationshipToCatalog :: MonadTx m => CreateFromSourceRelationship ('Postgres 'Vanilla) -> m ()
|
2021-12-14 09:45:13 +03:00
|
|
|
|
addRemoteRelationshipToCatalog CreateFromSourceRelationship {..} =
|
2020-12-08 17:22:31 +03:00
|
|
|
|
liftTx $
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
PG.unitQE
|
2020-12-08 17:22:31 +03:00
|
|
|
|
defaultTxErrorHandler
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
[PG.sql|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
INSERT INTO hdb_catalog.hdb_remote_relationship
|
|
|
|
|
(remote_relationship_name, table_schema, table_name, definition)
|
|
|
|
|
VALUES ($1, $2, $3, $4::jsonb)
|
2021-07-23 02:06:10 +03:00
|
|
|
|
|]
|
2022-09-21 21:40:41 +03:00
|
|
|
|
(_crrName, schemaName, tableName, PG.ViaJSON _crrDefinition)
|
2021-07-23 02:06:10 +03:00
|
|
|
|
True
|
2020-12-08 17:22:31 +03:00
|
|
|
|
where
|
2021-12-14 09:45:13 +03:00
|
|
|
|
QualifiedObject schemaName tableName = _crrTable
|
2020-12-08 17:22:31 +03:00
|
|
|
|
|
|
|
|
|
addFunctionToCatalog ::
|
2022-04-22 19:01:07 +03:00
|
|
|
|
(MonadTx m, MonadReader SystemDefined m) =>
|
2020-12-08 17:22:31 +03:00
|
|
|
|
QualifiedFunction ->
|
|
|
|
|
FunctionConfig ->
|
|
|
|
|
m ()
|
|
|
|
|
addFunctionToCatalog (QualifiedObject sn fn) config = do
|
2022-04-22 19:01:07 +03:00
|
|
|
|
systemDefined <- ask
|
2020-12-08 17:22:31 +03:00
|
|
|
|
liftTx $
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
PG.unitQE
|
2020-12-08 17:22:31 +03:00
|
|
|
|
defaultTxErrorHandler
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
[PG.sql|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
INSERT INTO "hdb_catalog"."hdb_function"
|
|
|
|
|
(function_schema, function_name, configuration, is_system_defined)
|
|
|
|
|
VALUES ($1, $2, $3, $4)
|
|
|
|
|
|]
|
2022-09-21 21:40:41 +03:00
|
|
|
|
(sn, fn, PG.ViaJSON config, systemDefined)
|
2020-12-08 17:22:31 +03:00
|
|
|
|
False
|
|
|
|
|
|
|
|
|
|
addRemoteSchemaToCatalog ::
|
2020-12-21 12:11:37 +03:00
|
|
|
|
RemoteSchemaMetadata ->
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
PG.TxE QErr ()
|
2021-12-01 07:53:34 +03:00
|
|
|
|
addRemoteSchemaToCatalog (RemoteSchemaMetadata name def comment _ _) =
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
PG.unitQE
|
2020-12-08 17:22:31 +03:00
|
|
|
|
defaultTxErrorHandler
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
[PG.sql|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
INSERT into hdb_catalog.remote_schemas
|
|
|
|
|
(name, definition, comment)
|
|
|
|
|
VALUES ($1, $2, $3)
|
|
|
|
|
|]
|
2022-09-21 21:40:41 +03:00
|
|
|
|
(name, PG.ViaJSON $ toJSON def, comment)
|
2020-12-08 17:22:31 +03:00
|
|
|
|
True
|
|
|
|
|
|
|
|
|
|
addCollectionToCatalog ::
|
|
|
|
|
MonadTx m => CreateCollection -> SystemDefined -> m ()
|
|
|
|
|
addCollectionToCatalog (CreateCollection name defn mComment) systemDefined =
|
|
|
|
|
liftTx $
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
PG.unitQE
|
2020-12-08 17:22:31 +03:00
|
|
|
|
defaultTxErrorHandler
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
[PG.sql|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
INSERT INTO hdb_catalog.hdb_query_collection
|
|
|
|
|
(collection_name, collection_defn, comment, is_system_defined)
|
|
|
|
|
VALUES ($1, $2, $3, $4)
|
|
|
|
|
|]
|
2022-09-21 21:40:41 +03:00
|
|
|
|
(name, PG.ViaJSON defn, mComment, systemDefined)
|
2020-12-08 17:22:31 +03:00
|
|
|
|
True
|
|
|
|
|
|
|
|
|
|
addCollectionToAllowlistCatalog :: MonadTx m => CollectionName -> m ()
|
|
|
|
|
addCollectionToAllowlistCatalog collName =
|
|
|
|
|
liftTx $
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
PG.unitQE
|
2020-12-08 17:22:31 +03:00
|
|
|
|
defaultTxErrorHandler
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
[PG.sql|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
INSERT INTO hdb_catalog.hdb_allowlist
|
|
|
|
|
(collection_name)
|
|
|
|
|
VALUES ($1)
|
|
|
|
|
|]
|
|
|
|
|
(Identity collName)
|
|
|
|
|
True
|
|
|
|
|
|
|
|
|
|
setCustomTypesInCatalog :: MonadTx m => CustomTypes -> m ()
|
|
|
|
|
setCustomTypesInCatalog customTypes = liftTx do
|
|
|
|
|
clearCustomTypes
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
PG.unitQE
|
2020-12-08 17:22:31 +03:00
|
|
|
|
defaultTxErrorHandler
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
[PG.sql|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
INSERT into hdb_catalog.hdb_custom_types
|
|
|
|
|
(custom_types)
|
|
|
|
|
VALUES ($1)
|
|
|
|
|
|]
|
2022-09-21 21:40:41 +03:00
|
|
|
|
(Identity $ PG.ViaJSON customTypes)
|
2020-12-08 17:22:31 +03:00
|
|
|
|
False
|
|
|
|
|
where
|
|
|
|
|
clearCustomTypes = do
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
PG.unitQE
|
2020-12-08 17:22:31 +03:00
|
|
|
|
defaultTxErrorHandler
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
[PG.sql|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
DELETE FROM hdb_catalog.hdb_custom_types
|
|
|
|
|
|]
|
|
|
|
|
()
|
|
|
|
|
False
|
|
|
|
|
|
|
|
|
|
addActionToCatalog :: (MonadTx m) => CreateAction -> m ()
|
2021-10-29 07:12:27 +03:00
|
|
|
|
addActionToCatalog (CreateAction actionName actionDefinition comment) = do
|
2020-12-08 17:22:31 +03:00
|
|
|
|
liftTx $
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
PG.unitQE
|
2020-12-08 17:22:31 +03:00
|
|
|
|
defaultTxErrorHandler
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
[PG.sql|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
INSERT into hdb_catalog.hdb_action
|
|
|
|
|
(action_name, action_defn, comment)
|
|
|
|
|
VALUES ($1, $2, $3)
|
|
|
|
|
|]
|
2022-09-21 21:40:41 +03:00
|
|
|
|
(actionName, PG.ViaJSON actionDefinition, comment)
|
2020-12-08 17:22:31 +03:00
|
|
|
|
True
|
|
|
|
|
|
|
|
|
|
addActionPermissionToCatalog :: (MonadTx m) => CreateActionPermission -> m ()
|
|
|
|
|
addActionPermissionToCatalog CreateActionPermission {..} = do
|
|
|
|
|
liftTx $
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
PG.unitQE
|
2020-12-08 17:22:31 +03:00
|
|
|
|
defaultTxErrorHandler
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
[PG.sql|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
INSERT into hdb_catalog.hdb_action_permission
|
|
|
|
|
(action_name, role_name, comment)
|
|
|
|
|
VALUES ($1, $2, $3)
|
|
|
|
|
|]
|
|
|
|
|
(_capAction, _capRole, _capComment)
|
|
|
|
|
True
|
2021-09-24 01:56:37 +03:00
|
|
|
|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
addPermissionToCatalog ::
|
2022-04-06 15:47:35 +03:00
|
|
|
|
(MonadTx m, Backend b) =>
|
2020-12-08 17:22:31 +03:00
|
|
|
|
QualifiedTable ->
|
2022-04-06 15:47:35 +03:00
|
|
|
|
PermDef b a ->
|
2020-12-08 17:22:31 +03:00
|
|
|
|
SystemDefined ->
|
|
|
|
|
m ()
|
2022-04-06 15:47:35 +03:00
|
|
|
|
addPermissionToCatalog (QualifiedObject sn tn) (PermDef rn qdef mComment) systemDefined =
|
2020-12-08 17:22:31 +03:00
|
|
|
|
liftTx $
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
PG.unitQE
|
2020-12-08 17:22:31 +03:00
|
|
|
|
defaultTxErrorHandler
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
[PG.sql|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
INSERT INTO
|
|
|
|
|
hdb_catalog.hdb_permission
|
|
|
|
|
(table_schema, table_name, role_name, perm_type, perm_def, comment, is_system_defined)
|
|
|
|
|
VALUES ($1, $2, $3, $4, $5 :: jsonb, $6, $7)
|
|
|
|
|
|]
|
2022-09-21 21:40:41 +03:00
|
|
|
|
(sn, tn, rn, permTypeToCode (reflectPermDefPermission qdef), PG.ViaJSON qdef, mComment, systemDefined)
|
2020-12-08 17:22:31 +03:00
|
|
|
|
True
|
|
|
|
|
|
|
|
|
|
addCronTriggerToCatalog :: (MonadTx m) => CronTriggerMetadata -> m ()
|
|
|
|
|
addCronTriggerToCatalog CronTriggerMetadata {..} = liftTx $ do
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
PG.unitQE
|
2020-12-08 17:22:31 +03:00
|
|
|
|
defaultTxErrorHandler
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
[PG.sql|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
INSERT into hdb_catalog.hdb_cron_triggers
|
|
|
|
|
(name, webhook_conf, cron_schedule, payload, retry_conf, header_conf, include_in_metadata, comment)
|
|
|
|
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
|
|
|
|
|]
|
|
|
|
|
( ctName,
|
2022-09-21 21:40:41 +03:00
|
|
|
|
PG.ViaJSON ctWebhook,
|
2020-12-08 17:22:31 +03:00
|
|
|
|
ctSchedule,
|
2022-09-21 21:40:41 +03:00
|
|
|
|
PG.ViaJSON <$> ctPayload,
|
|
|
|
|
PG.ViaJSON ctRetryConf,
|
|
|
|
|
PG.ViaJSON ctHeaders,
|
2020-12-08 17:22:31 +03:00
|
|
|
|
ctIncludeInMetadata,
|
|
|
|
|
ctComment
|
|
|
|
|
)
|
|
|
|
|
False
|
|
|
|
|
currentTime <- liftIO C.getCurrentTime
|
|
|
|
|
let scheduleTimes = generateScheduleTimes currentTime 100 ctSchedule -- generate next 100 events
|
2021-09-13 21:00:53 +03:00
|
|
|
|
insertCronEventsTx $ map (CronEventSeed ctName) scheduleTimes
|
2020-12-08 17:22:31 +03:00
|
|
|
|
|
2022-04-22 14:33:36 +03:00
|
|
|
|
parseLegacyRemoteRelationshipDefinition ::
|
|
|
|
|
(MonadError QErr m) =>
|
|
|
|
|
Value ->
|
|
|
|
|
m RemoteRelationshipDefinition
|
|
|
|
|
parseLegacyRemoteRelationshipDefinition =
|
|
|
|
|
runAesonParser (parseRemoteRelationshipDefinition RRPLegacy)
|
|
|
|
|
|
2020-12-28 15:56:00 +03:00
|
|
|
|
fetchMetadataFromHdbTables :: MonadTx m => m MetadataNoSources
|
2020-12-08 17:22:31 +03:00
|
|
|
|
fetchMetadataFromHdbTables = liftTx do
|
2023-03-14 20:46:13 +03:00
|
|
|
|
tables <- fetchTables
|
2020-12-08 17:22:31 +03:00
|
|
|
|
let tableMetaMap = OMap.fromList . flip map tables $
|
|
|
|
|
\(schema, name, isEnum, maybeConfig) ->
|
|
|
|
|
let qualifiedName = QualifiedObject schema name
|
2022-09-21 21:40:41 +03:00
|
|
|
|
configuration = maybe emptyTableConfig PG.getViaJSON maybeConfig
|
2020-12-08 17:22:31 +03:00
|
|
|
|
in (qualifiedName, mkTableMeta qualifiedName isEnum configuration)
|
|
|
|
|
|
|
|
|
|
-- Fetch all the relationships
|
2023-03-14 20:46:13 +03:00
|
|
|
|
relationships <- fetchRelationships
|
2020-12-08 17:22:31 +03:00
|
|
|
|
|
|
|
|
|
objRelDefs <- mkRelDefs ObjRel relationships
|
|
|
|
|
arrRelDefs <- mkRelDefs ArrRel relationships
|
|
|
|
|
|
|
|
|
|
-- Fetch all the permissions
|
2023-03-14 20:46:13 +03:00
|
|
|
|
permissions <- fetchPermissions
|
2020-12-08 17:22:31 +03:00
|
|
|
|
|
|
|
|
|
-- Parse all the permissions
|
|
|
|
|
insPermDefs <- mkPermDefs PTInsert permissions
|
|
|
|
|
selPermDefs <- mkPermDefs PTSelect permissions
|
|
|
|
|
updPermDefs <- mkPermDefs PTUpdate permissions
|
|
|
|
|
delPermDefs <- mkPermDefs PTDelete permissions
|
|
|
|
|
|
|
|
|
|
-- Fetch all event triggers
|
2023-03-14 20:46:13 +03:00
|
|
|
|
eventTriggers :: [(SchemaName, Postgres.TableName, PG.ViaJSON Value)] <- fetchEventTriggers
|
2020-12-08 17:22:31 +03:00
|
|
|
|
triggerMetaDefs <- mkTriggerMetaDefs eventTriggers
|
|
|
|
|
|
|
|
|
|
-- Fetch all computed fields
|
|
|
|
|
computedFields <- fetchComputedFields
|
|
|
|
|
|
|
|
|
|
-- Fetch all remote relationships
|
2023-03-14 20:46:13 +03:00
|
|
|
|
remoteRelationshipsRaw <- fetchRemoteRelationships
|
2022-04-13 19:07:12 +03:00
|
|
|
|
remoteRelationships <- for remoteRelationshipsRaw $ \(table, relationshipName, definitionValue) -> do
|
2022-04-22 14:33:36 +03:00
|
|
|
|
definition <- parseLegacyRemoteRelationshipDefinition definitionValue
|
2022-04-13 19:07:12 +03:00
|
|
|
|
pure $ (table, RemoteRelationship relationshipName definition)
|
2020-12-08 17:22:31 +03:00
|
|
|
|
|
|
|
|
|
let (_, fullTableMetaMap) = flip runState tableMetaMap $ do
|
|
|
|
|
modMetaMap tmObjectRelationships _rdName objRelDefs
|
|
|
|
|
modMetaMap tmArrayRelationships _rdName arrRelDefs
|
|
|
|
|
modMetaMap tmInsertPermissions _pdRole insPermDefs
|
|
|
|
|
modMetaMap tmSelectPermissions _pdRole selPermDefs
|
|
|
|
|
modMetaMap tmUpdatePermissions _pdRole updPermDefs
|
|
|
|
|
modMetaMap tmDeletePermissions _pdRole delPermDefs
|
|
|
|
|
modMetaMap tmEventTriggers etcName triggerMetaDefs
|
|
|
|
|
modMetaMap tmComputedFields _cfmName computedFields
|
2021-12-01 07:53:34 +03:00
|
|
|
|
modMetaMap tmRemoteRelationships _rrName remoteRelationships
|
2020-12-08 17:22:31 +03:00
|
|
|
|
|
2023-03-14 20:46:13 +03:00
|
|
|
|
functions <- fetchFunctions
|
2020-12-21 12:11:37 +03:00
|
|
|
|
remoteSchemas <- oMapFromL _rsmName <$> fetchRemoteSchemas
|
2020-12-08 17:22:31 +03:00
|
|
|
|
collections <- oMapFromL _ccName <$> fetchCollections
|
2022-02-08 19:53:30 +03:00
|
|
|
|
allowlist <- oMapFromL aeCollection <$> fetchAllowlist
|
2020-12-08 17:22:31 +03:00
|
|
|
|
customTypes <- fetchCustomTypes
|
|
|
|
|
actions <- oMapFromL _amName <$> fetchActions
|
2022-02-08 19:53:30 +03:00
|
|
|
|
cronTriggers <- fetchCronTriggers
|
2020-12-08 17:22:31 +03:00
|
|
|
|
|
2022-02-08 19:53:30 +03:00
|
|
|
|
pure $
|
|
|
|
|
MetadataNoSources
|
|
|
|
|
fullTableMetaMap
|
|
|
|
|
functions
|
|
|
|
|
remoteSchemas
|
|
|
|
|
collections
|
|
|
|
|
allowlist
|
|
|
|
|
customTypes
|
|
|
|
|
actions
|
|
|
|
|
cronTriggers
|
2020-12-08 17:22:31 +03:00
|
|
|
|
where
|
|
|
|
|
modMetaMap l f xs = do
|
|
|
|
|
st <- get
|
|
|
|
|
put $ foldl' (\b (qt, dfn) -> b & at qt . _Just . l %~ OMap.insert (f dfn) dfn) st xs
|
|
|
|
|
|
|
|
|
|
mkPermDefs pt = mapM permRowToDef . filter (\pr -> pr ^. _4 == pt)
|
|
|
|
|
|
2022-09-21 21:40:41 +03:00
|
|
|
|
permRowToDef (sn, tn, rn, _, PG.ViaJSON pDef, mComment) = do
|
2020-12-08 17:22:31 +03:00
|
|
|
|
perm <- decodeValue pDef
|
|
|
|
|
return (QualifiedObject sn tn, PermDef rn perm mComment)
|
|
|
|
|
|
|
|
|
|
mkRelDefs rt = mapM relRowToDef . filter (\rr -> rr ^. _4 == rt)
|
|
|
|
|
|
2022-09-21 21:40:41 +03:00
|
|
|
|
relRowToDef (sn, tn, rn, _, PG.ViaJSON rDef, mComment) = do
|
2020-12-08 17:22:31 +03:00
|
|
|
|
using <- decodeValue rDef
|
|
|
|
|
return (QualifiedObject sn tn, RelDef rn using mComment)
|
|
|
|
|
|
|
|
|
|
mkTriggerMetaDefs = mapM trigRowToDef
|
|
|
|
|
|
2022-09-21 21:40:41 +03:00
|
|
|
|
trigRowToDef (sn, tn, PG.ViaJSON configuration) = do
|
2021-09-06 14:15:36 +03:00
|
|
|
|
conf :: EventTriggerConf ('Postgres pgKind) <- decodeValue configuration
|
|
|
|
|
return (QualifiedObject sn tn, conf)
|
2020-12-08 17:22:31 +03:00
|
|
|
|
|
|
|
|
|
fetchTables =
|
2023-03-14 20:46:13 +03:00
|
|
|
|
PG.withQE
|
|
|
|
|
defaultTxErrorHandler
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
[PG.sql|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
SELECT table_schema, table_name, is_enum, configuration::json
|
|
|
|
|
FROM hdb_catalog.hdb_table
|
|
|
|
|
WHERE is_system_defined = 'false'
|
|
|
|
|
ORDER BY table_schema ASC, table_name ASC
|
|
|
|
|
|]
|
|
|
|
|
()
|
|
|
|
|
False
|
|
|
|
|
|
|
|
|
|
fetchRelationships =
|
2023-03-14 20:46:13 +03:00
|
|
|
|
PG.withQE
|
|
|
|
|
defaultTxErrorHandler
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
[PG.sql|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
SELECT table_schema, table_name, rel_name, rel_type, rel_def::json, comment
|
|
|
|
|
FROM hdb_catalog.hdb_relationship
|
|
|
|
|
WHERE is_system_defined = 'false'
|
|
|
|
|
ORDER BY table_schema ASC, table_name ASC, rel_name ASC
|
|
|
|
|
|]
|
|
|
|
|
()
|
|
|
|
|
False
|
|
|
|
|
|
|
|
|
|
fetchPermissions =
|
2023-03-14 20:46:13 +03:00
|
|
|
|
PG.withQE
|
|
|
|
|
defaultTxErrorHandler
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
[PG.sql|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
SELECT table_schema, table_name, role_name, perm_type, perm_def::json, comment
|
|
|
|
|
FROM hdb_catalog.hdb_permission
|
|
|
|
|
WHERE is_system_defined = 'false'
|
|
|
|
|
ORDER BY table_schema ASC, table_name ASC, role_name ASC, perm_type ASC
|
|
|
|
|
|]
|
|
|
|
|
()
|
|
|
|
|
False
|
|
|
|
|
|
|
|
|
|
fetchEventTriggers =
|
2023-03-14 20:46:13 +03:00
|
|
|
|
PG.withQE
|
|
|
|
|
defaultTxErrorHandler
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
[PG.sql|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
SELECT e.schema_name, e.table_name, e.configuration::json
|
|
|
|
|
FROM hdb_catalog.event_triggers e
|
|
|
|
|
ORDER BY e.schema_name ASC, e.table_name ASC, e.name ASC
|
|
|
|
|
|]
|
|
|
|
|
()
|
|
|
|
|
False
|
|
|
|
|
|
|
|
|
|
fetchFunctions = do
|
|
|
|
|
l <-
|
2023-03-14 20:46:13 +03:00
|
|
|
|
PG.withQE
|
|
|
|
|
defaultTxErrorHandler
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
[PG.sql|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
SELECT function_schema, function_name, configuration::json
|
|
|
|
|
FROM hdb_catalog.hdb_function
|
|
|
|
|
WHERE is_system_defined = 'false'
|
|
|
|
|
ORDER BY function_schema ASC, function_name ASC
|
|
|
|
|
|]
|
|
|
|
|
()
|
|
|
|
|
False
|
|
|
|
|
pure $
|
|
|
|
|
oMapFromL _fmFunction $
|
2022-09-21 21:40:41 +03:00
|
|
|
|
flip map l $ \(sn, fn, PG.ViaJSON config) ->
|
2021-01-29 08:48:17 +03:00
|
|
|
|
-- function permissions were only introduced post 43rd
|
|
|
|
|
-- migration, so it's impossible we get any permissions
|
|
|
|
|
-- here
|
2021-09-24 12:18:40 +03:00
|
|
|
|
FunctionMetadata (QualifiedObject sn fn) config [] Nothing
|
2020-12-08 17:22:31 +03:00
|
|
|
|
|
|
|
|
|
fetchRemoteSchemas =
|
|
|
|
|
map fromRow
|
2022-10-07 14:55:42 +03:00
|
|
|
|
<$> PG.withQE
|
2020-12-08 17:22:31 +03:00
|
|
|
|
defaultTxErrorHandler
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
[PG.sql|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
SELECT name, definition, comment
|
|
|
|
|
FROM hdb_catalog.remote_schemas
|
|
|
|
|
ORDER BY name ASC
|
|
|
|
|
|]
|
|
|
|
|
()
|
|
|
|
|
True
|
|
|
|
|
where
|
2022-09-21 21:40:41 +03:00
|
|
|
|
fromRow (name, PG.ViaJSON def, comment) =
|
2021-12-01 07:53:34 +03:00
|
|
|
|
RemoteSchemaMetadata name def comment mempty mempty
|
2020-12-08 17:22:31 +03:00
|
|
|
|
|
|
|
|
|
fetchCollections =
|
|
|
|
|
map fromRow
|
2022-10-07 14:55:42 +03:00
|
|
|
|
<$> PG.withQE
|
2020-12-08 17:22:31 +03:00
|
|
|
|
defaultTxErrorHandler
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
[PG.sql|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
SELECT collection_name, collection_defn::json, comment
|
|
|
|
|
FROM hdb_catalog.hdb_query_collection
|
|
|
|
|
WHERE is_system_defined = 'false'
|
|
|
|
|
ORDER BY collection_name ASC
|
|
|
|
|
|]
|
|
|
|
|
()
|
|
|
|
|
False
|
|
|
|
|
where
|
2022-09-21 21:40:41 +03:00
|
|
|
|
fromRow (name, PG.ViaJSON defn, mComment) =
|
2020-12-08 17:22:31 +03:00
|
|
|
|
CreateCollection name defn mComment
|
|
|
|
|
|
2022-02-08 19:53:30 +03:00
|
|
|
|
fetchAllowlist =
|
|
|
|
|
map fromRow
|
2022-10-07 14:55:42 +03:00
|
|
|
|
<$> PG.withQE
|
2020-12-08 17:22:31 +03:00
|
|
|
|
defaultTxErrorHandler
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
[PG.sql|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
SELECT collection_name
|
|
|
|
|
FROM hdb_catalog.hdb_allowlist
|
|
|
|
|
ORDER BY collection_name ASC
|
|
|
|
|
|]
|
|
|
|
|
()
|
|
|
|
|
False
|
2022-02-08 19:53:30 +03:00
|
|
|
|
where
|
|
|
|
|
fromRow (Identity name) = AllowlistEntry name AllowlistScopeGlobal
|
2020-12-08 17:22:31 +03:00
|
|
|
|
|
|
|
|
|
fetchComputedFields = do
|
|
|
|
|
r <-
|
2022-10-07 14:55:42 +03:00
|
|
|
|
PG.withQE
|
2020-12-08 17:22:31 +03:00
|
|
|
|
defaultTxErrorHandler
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
[PG.sql|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
SELECT table_schema, table_name, computed_field_name,
|
|
|
|
|
definition::json, comment
|
|
|
|
|
FROM hdb_catalog.hdb_computed_field
|
|
|
|
|
|]
|
|
|
|
|
()
|
|
|
|
|
False
|
|
|
|
|
pure $
|
2022-09-21 21:40:41 +03:00
|
|
|
|
flip map r $ \(schema, table, name, PG.ViaJSON definition, comment) ->
|
2020-12-08 17:22:31 +03:00
|
|
|
|
( QualifiedObject schema table,
|
2022-02-16 02:16:34 +03:00
|
|
|
|
ComputedFieldMetadata name definition (commentFromMaybeText comment)
|
2020-12-08 17:22:31 +03:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
fetchCronTriggers =
|
2021-05-21 05:46:58 +03:00
|
|
|
|
oMapFromL ctName . map uncurryCronTrigger
|
2022-10-07 14:55:42 +03:00
|
|
|
|
<$> PG.withQE
|
2020-12-08 17:22:31 +03:00
|
|
|
|
defaultTxErrorHandler
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
[PG.sql|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
SELECT ct.name, ct.webhook_conf, ct.cron_schedule, ct.payload,
|
|
|
|
|
ct.retry_conf, ct.header_conf, ct.include_in_metadata, ct.comment
|
|
|
|
|
FROM hdb_catalog.hdb_cron_triggers ct
|
|
|
|
|
WHERE include_in_metadata
|
|
|
|
|
|]
|
|
|
|
|
()
|
|
|
|
|
False
|
|
|
|
|
where
|
|
|
|
|
uncurryCronTrigger
|
|
|
|
|
(name, webhook, schedule, payload, retryConfig, headerConfig, includeMetadata, comment) =
|
|
|
|
|
CronTriggerMetadata
|
|
|
|
|
{ ctName = name,
|
2022-09-21 21:40:41 +03:00
|
|
|
|
ctWebhook = PG.getViaJSON webhook,
|
2020-12-08 17:22:31 +03:00
|
|
|
|
ctSchedule = schedule,
|
2022-09-21 21:40:41 +03:00
|
|
|
|
ctPayload = PG.getViaJSON <$> payload,
|
|
|
|
|
ctRetryConf = PG.getViaJSON retryConfig,
|
|
|
|
|
ctHeaders = PG.getViaJSON headerConfig,
|
2020-12-08 17:22:31 +03:00
|
|
|
|
ctIncludeInMetadata = includeMetadata,
|
2022-01-19 07:46:42 +03:00
|
|
|
|
ctComment = comment,
|
|
|
|
|
ctRequestTransform = Nothing,
|
|
|
|
|
ctResponseTransform = Nothing
|
2020-12-08 17:22:31 +03:00
|
|
|
|
}
|
|
|
|
|
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
fetchCustomTypes :: PG.TxE QErr CustomTypes
|
2020-12-08 17:22:31 +03:00
|
|
|
|
fetchCustomTypes =
|
2022-09-21 21:40:41 +03:00
|
|
|
|
PG.getViaJSON . runIdentity . PG.getRow
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
<$> PG.rawQE
|
2020-12-08 17:22:31 +03:00
|
|
|
|
defaultTxErrorHandler
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
[PG.sql|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
select coalesce((select custom_types::json from hdb_catalog.hdb_custom_types), '{}'::json)
|
|
|
|
|
|]
|
|
|
|
|
[]
|
|
|
|
|
False
|
|
|
|
|
|
|
|
|
|
fetchActions =
|
2022-09-21 21:40:41 +03:00
|
|
|
|
PG.getViaJSON . runIdentity . PG.getRow
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
<$> PG.rawQE
|
2020-12-08 17:22:31 +03:00
|
|
|
|
defaultTxErrorHandler
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
[PG.sql|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
select
|
|
|
|
|
coalesce(
|
|
|
|
|
json_agg(
|
|
|
|
|
json_build_object(
|
|
|
|
|
'name', a.action_name,
|
|
|
|
|
'definition', a.action_defn,
|
|
|
|
|
'comment', a.comment,
|
|
|
|
|
'permissions', ap.permissions
|
|
|
|
|
) order by a.action_name asc
|
|
|
|
|
),
|
|
|
|
|
'[]'
|
|
|
|
|
)
|
|
|
|
|
from
|
|
|
|
|
hdb_catalog.hdb_action as a
|
|
|
|
|
left outer join lateral (
|
|
|
|
|
select
|
|
|
|
|
coalesce(
|
|
|
|
|
json_agg(
|
|
|
|
|
json_build_object(
|
|
|
|
|
'role', ap.role_name,
|
|
|
|
|
'comment', ap.comment
|
|
|
|
|
) order by ap.role_name asc
|
|
|
|
|
),
|
|
|
|
|
'[]'
|
|
|
|
|
) as permissions
|
|
|
|
|
from
|
|
|
|
|
hdb_catalog.hdb_action_permission ap
|
|
|
|
|
where
|
|
|
|
|
ap.action_name = a.action_name
|
|
|
|
|
) ap on true;
|
|
|
|
|
|]
|
|
|
|
|
[]
|
|
|
|
|
False
|
|
|
|
|
|
|
|
|
|
fetchRemoteRelationships = do
|
|
|
|
|
r <-
|
2023-03-14 20:46:13 +03:00
|
|
|
|
PG.withQE
|
|
|
|
|
defaultTxErrorHandler
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
[PG.sql|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
SELECT table_schema, table_name,
|
|
|
|
|
remote_relationship_name, definition::json
|
|
|
|
|
FROM hdb_catalog.hdb_remote_relationship
|
|
|
|
|
|]
|
|
|
|
|
()
|
|
|
|
|
False
|
|
|
|
|
pure $
|
2022-09-21 21:40:41 +03:00
|
|
|
|
flip map r $ \(schema, table, name, PG.ViaJSON definition) ->
|
2020-12-08 17:22:31 +03:00
|
|
|
|
( QualifiedObject schema table,
|
2022-04-13 19:07:12 +03:00
|
|
|
|
name,
|
|
|
|
|
definition
|
2020-12-08 17:22:31 +03:00
|
|
|
|
)
|
|
|
|
|
|
2021-08-17 10:01:14 +03:00
|
|
|
|
addCronTriggerForeignKeyConstraint :: MonadTx m => m ()
|
|
|
|
|
addCronTriggerForeignKeyConstraint =
|
|
|
|
|
liftTx $
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
PG.unitQE
|
2021-08-17 10:01:14 +03:00
|
|
|
|
defaultTxErrorHandler
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
[PG.sql|
|
2021-08-17 10:01:14 +03:00
|
|
|
|
ALTER TABLE hdb_catalog.hdb_cron_events ADD CONSTRAINT
|
|
|
|
|
hdb_cron_events_trigger_name_fkey FOREIGN KEY (trigger_name)
|
|
|
|
|
REFERENCES hdb_catalog.hdb_cron_triggers(name)
|
|
|
|
|
ON UPDATE CASCADE ON DELETE CASCADE;
|
|
|
|
|
|]
|
|
|
|
|
()
|
|
|
|
|
False
|
|
|
|
|
|
2020-12-08 17:22:31 +03:00
|
|
|
|
-- | Drops and recreates all “system-defined” metadata, aka metadata for tables and views in the
|
|
|
|
|
-- @information_schema@ and @hdb_catalog@ schemas. These tables and views are tracked to expose them
|
|
|
|
|
-- to the console, which allows us to reuse the same functionality we use to implement user-defined
|
|
|
|
|
-- APIs to expose the catalog.
|
|
|
|
|
--
|
|
|
|
|
-- This process has a long and storied history.
|
|
|
|
|
--
|
|
|
|
|
-- In the past, we reused the same machinery we use for CLI migrations to define our own internal
|
|
|
|
|
-- metadata migrations. This caused trouble, however, as we’d have to run those migrations in
|
|
|
|
|
-- lockstep with our SQL migrations to ensure the two didn’t get out of sync. This in turn caused
|
|
|
|
|
-- trouble because those migrations would hit code paths inside @graphql-engine@ to add or remove
|
|
|
|
|
-- things from the @pg_catalog@ tables, and /that/ in turn would fail because we hadn’t finished
|
|
|
|
|
-- running the SQL migrations, so we were running a new version of the code against an old version
|
|
|
|
|
-- of the schema! That caused #2826.
|
|
|
|
|
--
|
|
|
|
|
-- To fix that, #2379 switched to the approach of just dropping and recreating all system metadata
|
|
|
|
|
-- every time we run any SQL migrations. But /that/ in turn caused trouble due to the way we were
|
|
|
|
|
-- constantly rebuilding the schema cache (#3354), causing us to switch to incremental schema cache
|
|
|
|
|
-- construction (#3394). However, although that mostly resolved the problem, we still weren’t
|
|
|
|
|
-- totally out of the woods, as the incremental construction was still too slow on slow Postgres
|
|
|
|
|
-- instances (#3654).
|
|
|
|
|
--
|
|
|
|
|
-- To sidestep the whole issue, as of #3686 we now just create all the system metadata in code here,
|
|
|
|
|
-- and we only rebuild the schema cache once, at the very end. This is a little unsatisfying, since
|
|
|
|
|
-- it means our internal migrations are “blessed” compared to user-defined CLI migrations. If we
|
|
|
|
|
-- improve CLI migrations further in the future, maybe we can switch back to using that approach,
|
|
|
|
|
-- instead.
|
|
|
|
|
recreateSystemMetadata :: (MonadTx m) => m ()
|
|
|
|
|
recreateSystemMetadata = do
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
|
() <- liftTx $ PG.multiQE defaultTxErrorHandler $(makeRelativeToProject "src-rsr/clear_system_metadata.sql" >>= PG.sqlFromFile)
|
2022-04-22 19:01:07 +03:00
|
|
|
|
flip runReaderT (SystemDefined True) $ for_ systemMetadata \(tableName, tableRels) -> do
|
2020-12-08 17:22:31 +03:00
|
|
|
|
saveTableToCatalog tableName False emptyTableConfig
|
|
|
|
|
for_ tableRels \case
|
|
|
|
|
Left relDef -> insertRelationshipToCatalog tableName ObjRel relDef
|
|
|
|
|
Right relDef -> insertRelationshipToCatalog tableName ArrRel relDef
|
|
|
|
|
where
|
2021-04-22 00:44:37 +03:00
|
|
|
|
systemMetadata :: [(QualifiedTable, [Either (ObjRelDef ('Postgres 'Vanilla)) (ArrRelDef ('Postgres 'Vanilla))])]
|
2020-12-08 17:22:31 +03:00
|
|
|
|
systemMetadata =
|
|
|
|
|
[ table "information_schema" "tables" [],
|
|
|
|
|
table "information_schema" "schemata" [],
|
|
|
|
|
table "information_schema" "views" [],
|
|
|
|
|
table "information_schema" "columns" [],
|
|
|
|
|
table
|
|
|
|
|
"hdb_catalog"
|
|
|
|
|
"hdb_table"
|
|
|
|
|
[ objectRel $$(nonEmptyText "detail") $
|
|
|
|
|
manualConfig "information_schema" "tables" tableNameMapping,
|
|
|
|
|
objectRel $$(nonEmptyText "primary_key") $
|
|
|
|
|
manualConfig "hdb_catalog" "hdb_primary_key" tableNameMapping,
|
|
|
|
|
arrayRel $$(nonEmptyText "columns") $
|
|
|
|
|
manualConfig "information_schema" "columns" tableNameMapping,
|
|
|
|
|
arrayRel $$(nonEmptyText "foreign_key_constraints") $
|
|
|
|
|
manualConfig "hdb_catalog" "hdb_foreign_key_constraint" tableNameMapping,
|
|
|
|
|
arrayRel $$(nonEmptyText "relationships") $
|
|
|
|
|
manualConfig "hdb_catalog" "hdb_relationship" tableNameMapping,
|
|
|
|
|
arrayRel $$(nonEmptyText "permissions") $
|
|
|
|
|
manualConfig "hdb_catalog" "hdb_permission_agg" tableNameMapping,
|
|
|
|
|
arrayRel $$(nonEmptyText "computed_fields") $
|
|
|
|
|
manualConfig "hdb_catalog" "hdb_computed_field" tableNameMapping,
|
|
|
|
|
arrayRel $$(nonEmptyText "check_constraints") $
|
|
|
|
|
manualConfig "hdb_catalog" "hdb_check_constraint" tableNameMapping,
|
|
|
|
|
arrayRel $$(nonEmptyText "unique_constraints") $
|
|
|
|
|
manualConfig "hdb_catalog" "hdb_unique_constraint" tableNameMapping
|
|
|
|
|
],
|
|
|
|
|
table "hdb_catalog" "hdb_primary_key" [],
|
|
|
|
|
table "hdb_catalog" "hdb_foreign_key_constraint" [],
|
|
|
|
|
table "hdb_catalog" "hdb_relationship" [],
|
|
|
|
|
table "hdb_catalog" "hdb_permission_agg" [],
|
|
|
|
|
table "hdb_catalog" "hdb_computed_field" [],
|
|
|
|
|
table "hdb_catalog" "hdb_check_constraint" [],
|
|
|
|
|
table "hdb_catalog" "hdb_unique_constraint" [],
|
|
|
|
|
table "hdb_catalog" "hdb_remote_relationship" [],
|
|
|
|
|
table
|
|
|
|
|
"hdb_catalog"
|
|
|
|
|
"event_triggers"
|
|
|
|
|
[ arrayRel $$(nonEmptyText "events") $
|
|
|
|
|
manualConfig "hdb_catalog" "event_log" [("name", "trigger_name")]
|
|
|
|
|
],
|
|
|
|
|
table
|
|
|
|
|
"hdb_catalog"
|
|
|
|
|
"event_log"
|
|
|
|
|
[ objectRel $$(nonEmptyText "trigger") $
|
|
|
|
|
manualConfig "hdb_catalog" "event_triggers" [("trigger_name", "name")],
|
|
|
|
|
arrayRel $$(nonEmptyText "logs") $
|
|
|
|
|
RUFKeyOn $
|
2021-05-21 05:46:58 +03:00
|
|
|
|
ArrRelUsingFKeyOn (QualifiedObject "hdb_catalog" "event_invocation_logs") (pure "event_id")
|
|
|
|
|
],
|
2020-12-08 17:22:31 +03:00
|
|
|
|
table
|
|
|
|
|
"hdb_catalog"
|
|
|
|
|
"event_invocation_logs"
|
2021-05-21 05:46:58 +03:00
|
|
|
|
[objectRel $$(nonEmptyText "event") $ RUFKeyOn $ SameTable (pure "event_id")],
|
2020-12-08 17:22:31 +03:00
|
|
|
|
table "hdb_catalog" "hdb_function" [],
|
|
|
|
|
table
|
|
|
|
|
"hdb_catalog"
|
|
|
|
|
"hdb_function_agg"
|
|
|
|
|
[ objectRel $$(nonEmptyText "return_table_info") $
|
|
|
|
|
manualConfig
|
|
|
|
|
"hdb_catalog"
|
|
|
|
|
"hdb_table"
|
|
|
|
|
[ ("return_type_schema", "table_schema"),
|
|
|
|
|
("return_type_name", "table_name")
|
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
table "hdb_catalog" "remote_schemas" [],
|
|
|
|
|
table "hdb_catalog" "hdb_version" [],
|
|
|
|
|
table "hdb_catalog" "hdb_query_collection" [],
|
|
|
|
|
table "hdb_catalog" "hdb_allowlist" [],
|
|
|
|
|
table "hdb_catalog" "hdb_custom_types" [],
|
|
|
|
|
table "hdb_catalog" "hdb_action_permission" [],
|
|
|
|
|
table
|
|
|
|
|
"hdb_catalog"
|
|
|
|
|
"hdb_action"
|
|
|
|
|
[ arrayRel $$(nonEmptyText "permissions") $
|
|
|
|
|
manualConfig
|
|
|
|
|
"hdb_catalog"
|
|
|
|
|
"hdb_action_permission"
|
|
|
|
|
[("action_name", "action_name")]
|
|
|
|
|
],
|
|
|
|
|
table "hdb_catalog" "hdb_action_log" [],
|
|
|
|
|
table
|
|
|
|
|
"hdb_catalog"
|
|
|
|
|
"hdb_role"
|
|
|
|
|
[ arrayRel $$(nonEmptyText "action_permissions") $
|
|
|
|
|
manualConfig
|
|
|
|
|
"hdb_catalog"
|
|
|
|
|
"hdb_action_permission"
|
|
|
|
|
[("role_name", "role_name")],
|
|
|
|
|
arrayRel $$(nonEmptyText "permissions") $
|
|
|
|
|
manualConfig
|
|
|
|
|
"hdb_catalog"
|
|
|
|
|
"hdb_permission_agg"
|
|
|
|
|
[("role_name", "role_name")]
|
|
|
|
|
],
|
|
|
|
|
table
|
|
|
|
|
"hdb_catalog"
|
|
|
|
|
"hdb_cron_triggers"
|
|
|
|
|
[ arrayRel $$(nonEmptyText "cron_events") $
|
|
|
|
|
RUFKeyOn $
|
2021-05-21 05:46:58 +03:00
|
|
|
|
ArrRelUsingFKeyOn (QualifiedObject "hdb_catalog" "hdb_cron_events") (pure "trigger_name")
|
2020-12-08 17:22:31 +03:00
|
|
|
|
],
|
|
|
|
|
table
|
|
|
|
|
"hdb_catalog"
|
|
|
|
|
"hdb_cron_events"
|
2021-05-21 05:46:58 +03:00
|
|
|
|
[ objectRel $$(nonEmptyText "cron_trigger") $ RUFKeyOn $ SameTable (pure "trigger_name"),
|
2020-12-08 17:22:31 +03:00
|
|
|
|
arrayRel $$(nonEmptyText "cron_event_logs") $
|
|
|
|
|
RUFKeyOn $
|
2021-05-21 05:46:58 +03:00
|
|
|
|
ArrRelUsingFKeyOn (QualifiedObject "hdb_catalog" "hdb_cron_event_invocation_logs") (pure "event_id")
|
2020-12-08 17:22:31 +03:00
|
|
|
|
],
|
|
|
|
|
table
|
|
|
|
|
"hdb_catalog"
|
|
|
|
|
"hdb_cron_event_invocation_logs"
|
2021-05-21 05:46:58 +03:00
|
|
|
|
[ objectRel $$(nonEmptyText "cron_event") $ RUFKeyOn $ SameTable (pure "event_id")
|
2020-12-08 17:22:31 +03:00
|
|
|
|
],
|
|
|
|
|
table
|
|
|
|
|
"hdb_catalog"
|
|
|
|
|
"hdb_scheduled_events"
|
|
|
|
|
[ arrayRel $$(nonEmptyText "scheduled_event_logs") $
|
|
|
|
|
RUFKeyOn $
|
2021-05-21 05:46:58 +03:00
|
|
|
|
ArrRelUsingFKeyOn (QualifiedObject "hdb_catalog" "hdb_scheduled_event_invocation_logs") (pure "event_id")
|
2020-12-08 17:22:31 +03:00
|
|
|
|
],
|
|
|
|
|
table
|
|
|
|
|
"hdb_catalog"
|
|
|
|
|
"hdb_scheduled_event_invocation_logs"
|
2021-05-21 05:46:58 +03:00
|
|
|
|
[ objectRel $$(nonEmptyText "scheduled_event") $ RUFKeyOn $ SameTable (pure "event_id")
|
2020-12-08 17:22:31 +03:00
|
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
tableNameMapping =
|
|
|
|
|
[ ("table_schema", "table_schema"),
|
|
|
|
|
("table_name", "table_name")
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
table schemaName tableName relationships = (QualifiedObject schemaName tableName, relationships)
|
|
|
|
|
objectRel name using = Left $ RelDef (RelName name) using Nothing
|
|
|
|
|
arrayRel name using = Right $ RelDef (RelName name) using Nothing
|
|
|
|
|
manualConfig schemaName tableName columns =
|
2021-03-03 16:02:00 +03:00
|
|
|
|
RUManual $ RelManualConfig (QualifiedObject schemaName tableName) (HM.fromList columns) Nothing
|