Skip to content

Commit

Permalink
adjust query for jsonb and change warning message
Browse files Browse the repository at this point in the history
  • Loading branch information
Cmdv committed Jun 7, 2024
1 parent b572f32 commit ffde4af
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
6 changes: 4 additions & 2 deletions cardano-db-sync/src/Cardano/DbSync.hs
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,13 @@ runSyncNode metricsSetters trce iomgr dbConnString ranMigrations runMigrationFnc

-- if the database has jsonb datatypes and the configuration does not have add_jsonb_to_schema enabled, then warn the user
when (resJsonbInSchema && not isJsonBInSchemaConfig) $ do
liftIO $ logWarning trce "The database has jsonb datatypes, but the configuration does not have add_jsonb_to_schema enabled. The all jsonb datatypes will be put back which can take time."
liftIO $ logWarning trce "Removing jsonb datatypes from the database. This can take time."
liftIO $ runDisableJsonbInSchema syncEnv

-- if the database doesn't have jsonb datatypes and the configuration does have add_jsonb_to_schema enabled, then add jsonb datatypes to the database
when (not resJsonbInSchema && isJsonBInSchemaConfig) $ liftIO $ runEnableJsonbInSchema syncEnv
when (not resJsonbInSchema && isJsonBInSchemaConfig) $ do
liftIO $ logWarning trce "Adding jsonb datatypes to the database. This can take time."
liftIO $ runEnableJsonbInSchema syncEnv
liftIO $ runExtraMigrationsMaybe syncEnv
unless useLedger $ liftIO $ do
logInfo trce "Migrating to a no ledger schema"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,35 +63,35 @@ disableJsonbInSchema ::
disableJsonbInSchema = do
handle exceptHandler $
rawExecute
"ALTER TABLE 'tx_metadata' ALTER COLUMN 'json' TYPE VARCHAR"
"ALTER TABLE tx_metadata ALTER COLUMN json TYPE VARCHAR"
[]
handle exceptHandler $
rawExecute
"ALTER TABLE 'script' ALTER COLUMN 'json' TYPE VARCHAR"
"ALTER TABLE script ALTER COLUMN json TYPE VARCHAR"
[]
handle exceptHandler $
rawExecute
"ALTER TABLE 'datum' ALTER COLUMN 'value' TYPE VARCHAR"
"ALTER TABLE datum ALTER COLUMN value TYPE VARCHAR"
[]
handle exceptHandler $
rawExecute
"ALTER TABLE 'redeemer_data' ALTER COLUMN 'value' TYPE VARCHAR"
"ALTER TABLE redeemer_data ALTER COLUMN value TYPE VARCHAR"
[]
handle exceptHandler $
rawExecute
"ALTER TABLE 'cost_model' ALTER COLUMN 'costs' TYPE VARCHAR"
"ALTER TABLE cost_model ALTER COLUMN costs TYPE VARCHAR"
[]
handle exceptHandler $
rawExecute
"ALTER TABLE 'gov_action_proposal' ALTER COLUMN 'description' TYPE VARCHAR"
"ALTER TABLE gov_action_proposal ALTER COLUMN description TYPE VARCHAR"
[]
handle exceptHandler $
rawExecute
"ALTER TABLE 'off_chain_pool_data' ALTER COLUMN 'json' TYPE VARCHAR"
"ALTER TABLE off_chain_pool_data ALTER COLUMN json TYPE VARCHAR"
[]
handle exceptHandler $
rawExecute
"ALTER TABLE 'off_chain_vote_data' ALTER COLUMN 'json' TYPE VARCHAR"
"ALTER TABLE off_chain_vote_data ALTER COLUMN json TYPE VARCHAR"
[]

queryJsonbInSchemaExists ::
Expand Down

0 comments on commit ffde4af

Please sign in to comment.