Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds a flag for specifying the db name for migrations #185

Merged
merged 2 commits into from
Nov 3, 2023

Conversation

ChrisSG
Copy link
Contributor

@ChrisSG ChrisSG commented Nov 1, 2023

Problem

Currently, it seems that the name of the target database for migrations is fixed to "default." This produces the following error when there is no database named "default":

problem applying Hasura metadata: problem adding metadata for the buckets table: status_code: 400\nresponse: {"error":"source with name \"default\" does not exist","path":"$.args","code":"not-exists"}

(see #184 (comment))

Solution

To address this issue and provide more flexibility in configuring the target database for migrations, we propose the following solution:

  • Environment Variable: Introduce a new environment variable named HASURA_DB_NAME to allow users to specify the target database name for migrations.

  • Configuration Update: Modify the code in hasura-storage/migrations/hasura.go to use the value of HASURA_DB_NAME as the target database name. This ensures that users can configure the target database dynamically.

  • Fallback to "default": If HASURA_DB_NAME is not set, the code should default to "default" to maintain backward compatibility.

Notes

  • Users can set the HASURA_DB_NAME environment variable to configure the target database for migrations to their desired database name.

  • This change enhances the flexibility of the migration process, especially in cases where the database name is not "default."

  • Reviewers are encouraged to verify that the documentation has been updated to reflect the new configuration option.

With this solution, users can customize the target database for migrations by setting the HASURA_DB_NAME environment variable, which eliminates the error associated with the fixed "default" database name.

cmd/serve.go Outdated
@@ -294,6 +298,7 @@ var serveCmd = &cobra.Command{
viper.GetBool(hasuraMetadataFlag),
viper.GetString(hasuraEndpointFlag),
viper.GetString(hasuraAdminSecretFlag),
viper.getString(hasuraDbNameFlag),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

@dbarrosop
Copy link
Member

Thanks for the PR, there is a minor typo but other than that it looks good.

@dbarrosop
Copy link
Member

Thanks!

@dbarrosop dbarrosop merged commit 4d226c5 into nhost:main Nov 3, 2023
3 checks passed
@ChrisSG
Copy link
Contributor Author

ChrisSG commented Nov 3, 2023

When can we expect to see this in the Docker image?

@dbarrosop
Copy link
Member

Just released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants