feature(server): add Logical Models support for CockroachDB

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8500
GitOrigin-RevId: 0205bd207843f50ad4fa12ad6e6c07d1f2740912
This commit is contained in:
Daniel Harvey 2023-03-27 14:57:36 +01:00 committed by hasura-bot
parent 26bb2b4030
commit 305eebb3ab
9 changed files with 35 additions and 4 deletions

View File

@ -81,7 +81,7 @@ services:
healthcheck: healthcheck:
test: test:
- CMD-SHELL - CMD-SHELL
- cockroach sql --insecure < /dev/null - cockroach sql --insecure --execute "select 1;"
start_period: 5s start_period: 5s
interval: 5s interval: 5s
timeout: 10s timeout: 10s

View File

@ -38,7 +38,7 @@ services:
ports: ports:
- "65008:26257" - "65008:26257"
environment: environment:
COCKROACH_USER: "root" COCKROACH_USER: "hasura"
COCKROACH_DATABASE: "hasura" COCKROACH_DATABASE: "hasura"
volumes: volumes:
- cockroach-data:/cockroach/cockroach-data - cockroach-data:/cockroach/cockroach-data

View File

@ -2,6 +2,7 @@ module Test.API.Metadata.LogicalModels.ValidationSpec where
import Data.List.NonEmpty qualified as NE import Data.List.NonEmpty qualified as NE
import Harness.Backend.Citus qualified as Citus import Harness.Backend.Citus qualified as Citus
import Harness.Backend.Cockroach qualified as Cockroach
import Harness.Backend.Postgres qualified as Postgres import Harness.Backend.Postgres qualified as Postgres
import Harness.GraphqlEngine qualified as GraphqlEngine import Harness.GraphqlEngine qualified as GraphqlEngine
import Harness.Quoter.Yaml (yaml) import Harness.Quoter.Yaml (yaml)
@ -30,6 +31,11 @@ spec = do
{ Fixture.setupTeardown = \(testEnv, _) -> { Fixture.setupTeardown = \(testEnv, _) ->
[ Citus.setupTablesAction schema testEnv [ Citus.setupTablesAction schema testEnv
] ]
},
(Fixture.fixture $ Fixture.Backend Cockroach.backendTypeMetadata)
{ Fixture.setupTeardown = \(testEnv, _) ->
[ Cockroach.setupTablesAction schema testEnv
]
} }
] ]
) )

View File

@ -6,6 +6,7 @@ module Test.API.Metadata.LogicalModelsSpec (spec) where
import Data.List.NonEmpty qualified as NE import Data.List.NonEmpty qualified as NE
import Harness.Backend.BigQuery qualified as BigQuery import Harness.Backend.BigQuery qualified as BigQuery
import Harness.Backend.Citus qualified as Citus import Harness.Backend.Citus qualified as Citus
import Harness.Backend.Cockroach qualified as Cockroach
import Harness.Backend.Postgres qualified as Postgres import Harness.Backend.Postgres qualified as Postgres
import Harness.Backend.Sqlserver qualified as Sqlserver import Harness.Backend.Sqlserver qualified as Sqlserver
import Harness.GraphqlEngine qualified as GraphqlEngine import Harness.GraphqlEngine qualified as GraphqlEngine
@ -46,6 +47,11 @@ spec = do
[ Citus.setupTablesAction schema testEnv [ Citus.setupTablesAction schema testEnv
] ]
}, },
(Fixture.fixture $ Fixture.Backend Cockroach.backendTypeMetadata)
{ Fixture.setupTeardown = \(testEnv, _) ->
[ Cockroach.setupTablesAction schema testEnv
]
},
(Fixture.fixture $ Fixture.Backend Sqlserver.backendTypeMetadata) (Fixture.fixture $ Fixture.Backend Sqlserver.backendTypeMetadata)
{ Fixture.setupTeardown = \(testEnv, _) -> { Fixture.setupTeardown = \(testEnv, _) ->
[ Sqlserver.setupTablesAction schema testEnv [ Sqlserver.setupTablesAction schema testEnv

View File

@ -9,6 +9,7 @@ import Data.Time.Calendar.OrdinalDate
import Data.Time.Clock import Data.Time.Clock
import Database.PG.Query qualified as PG import Database.PG.Query qualified as PG
import Harness.Backend.Citus qualified as Citus import Harness.Backend.Citus qualified as Citus
import Harness.Backend.Cockroach qualified as Cockroach
import Harness.Backend.Postgres qualified as Postgres import Harness.Backend.Postgres qualified as Postgres
import Harness.GraphqlEngine qualified as GraphqlEngine import Harness.GraphqlEngine qualified as GraphqlEngine
import Harness.Quoter.Graphql import Harness.Quoter.Graphql
@ -37,6 +38,11 @@ spec =
[ Postgres.setupTablesAction schema testEnvironment [ Postgres.setupTablesAction schema testEnvironment
] ]
}, },
(Fixture.fixture $ Fixture.Backend Cockroach.backendTypeMetadata)
{ Fixture.setupTeardown = \(testEnvironment, _) ->
[ Cockroach.setupTablesAction schema testEnvironment
]
},
(Fixture.fixture $ Fixture.Backend Citus.backendTypeMetadata) (Fixture.fixture $ Fixture.Backend Citus.backendTypeMetadata)
{ Fixture.setupTeardown = \(testEnvironment, _) -> { Fixture.setupTeardown = \(testEnvironment, _) ->
[ Citus.setupTablesAction schema testEnvironment [ Citus.setupTablesAction schema testEnvironment

View File

@ -6,6 +6,7 @@ module Test.Queries.LogicalModels.LogicalModelsQueriesSpec (spec) where
import Data.Aeson (Value) import Data.Aeson (Value)
import Data.List.NonEmpty qualified as NE import Data.List.NonEmpty qualified as NE
import Harness.Backend.Citus qualified as Citus import Harness.Backend.Citus qualified as Citus
import Harness.Backend.Cockroach qualified as Cockroach
import Harness.Backend.Postgres qualified as Postgres import Harness.Backend.Postgres qualified as Postgres
import Harness.GraphqlEngine qualified as GraphqlEngine import Harness.GraphqlEngine qualified as GraphqlEngine
import Harness.Quoter.Graphql import Harness.Quoter.Graphql
@ -34,6 +35,11 @@ spec =
[ Postgres.setupTablesAction schema testEnvironment [ Postgres.setupTablesAction schema testEnvironment
] ]
}, },
(Fixture.fixture $ Fixture.Backend Cockroach.backendTypeMetadata)
{ Fixture.setupTeardown = \(testEnvironment, _) ->
[ Cockroach.setupTablesAction schema testEnvironment
]
},
(Fixture.fixture $ Fixture.Backend Citus.backendTypeMetadata) (Fixture.fixture $ Fixture.Backend Citus.backendTypeMetadata)
{ Fixture.setupTeardown = \(testEnvironment, _) -> { Fixture.setupTeardown = \(testEnvironment, _) ->
[ Citus.setupTablesAction schema testEnvironment [ Citus.setupTablesAction schema testEnvironment

View File

@ -9,6 +9,7 @@ import Data.Time.Calendar.OrdinalDate
import Data.Time.Clock import Data.Time.Clock
import Database.PG.Query qualified as PG import Database.PG.Query qualified as PG
import Harness.Backend.Citus qualified as Citus import Harness.Backend.Citus qualified as Citus
import Harness.Backend.Cockroach qualified as Cockroach
import Harness.Backend.Postgres qualified as Postgres import Harness.Backend.Postgres qualified as Postgres
import Harness.GraphqlEngine qualified as GraphqlEngine import Harness.GraphqlEngine qualified as GraphqlEngine
import Harness.Quoter.Graphql import Harness.Quoter.Graphql
@ -38,6 +39,11 @@ spec =
[ Postgres.setupTablesAction schema testEnvironment [ Postgres.setupTablesAction schema testEnvironment
] ]
}, },
(Fixture.fixture $ Fixture.Backend Cockroach.backendTypeMetadata)
{ Fixture.setupTeardown = \(testEnvironment, _) ->
[ Cockroach.setupTablesAction schema testEnvironment
]
},
(Fixture.fixture $ Fixture.Backend Citus.backendTypeMetadata) (Fixture.fixture $ Fixture.Backend Citus.backendTypeMetadata)
{ Fixture.setupTeardown = \(testEnvironment, _) -> { Fixture.setupTeardown = \(testEnvironment, _) ->
[ Citus.setupTablesAction schema testEnvironment [ Citus.setupTablesAction schema testEnvironment

View File

@ -169,7 +169,7 @@ defaultCitusConnectionString =
-- * Cockroach -- * Cockroach
cockroachUser :: Text cockroachUser :: Text
cockroachUser = "root" cockroachUser = "hasura"
cockroachDb :: Text cockroachDb :: Text
cockroachDb = "hasura" cockroachDb = "hasura"

View File

@ -61,5 +61,6 @@ instance BackendAPI ('Postgres 'Cockroach) where
. mkAnyBackend @('Postgres 'Cockroach) . mkAnyBackend @('Postgres 'Cockroach)
) )
], ],
connectionTemplateCommands @('Postgres 'Cockroach) connectionTemplateCommands @('Postgres 'Cockroach),
logicalModelsCommands @('Postgres 'Cockroach)
] ]