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

Add support for managing multiple databases with a --database flag and geni.toml configuration #167

Open
5 tasks
slavakurilyak opened this issue Aug 24, 2024 · 2 comments · May be fixed by #172
Open
5 tasks
Labels
enhancement New feature or request

Comments

@slavakurilyak
Copy link

Problem

Geni currently lacks a way to specify which database to target when running commands, making it challenging to manage multiple libSQL databases in a single project. Additionally, the tool relies solely on environment variables for configuration, which can be cumbersome for projects with multiple databases.

Proposed Solution

  1. Introduce a new --database or -d flag for Geni commands to allow specifying the target database.
  2. Implement support for a geni.toml configuration file to define multiple database configurations.

Example usage:

geni up --database project
geni up --database project-schema

Implementation Details

  1. Add support for a geni.toml file with the following structure:

    [project]
    database_url = "libsql://project"
    database_token = "your_database_token_here"
    
    [project-schema]
    database_url = "libsql://project-schema"
    database_token = "your_database_token_here"
  2. Modify the Geni CLI to:

    • Accept and parse the new --database flag
    • Read and parse the geni.toml file if present
    • Fall back to environment variables if no geni.toml file is found or no --database flag is specified
  3. Update the internal logic to use the specified database configuration when executing commands.

  4. Update documentation to reflect the new functionality and geni.toml usage.

Benefits

  • Simplifies management of multiple databases within a single project
  • Improves workflow for multi-tenant database setups
  • Enhances CLI flexibility for database migrations and management
  • Provides a more convenient way to manage database configurations

Questions

  • Should we provide a way to set a default database in the geni.toml file?
  • How should we handle precedence between geni.toml, command-line flags, and environment variables?
  • Should we consider allowing environment variable overrides for database-specific configurations?

Acceptance Criteria

  • Geni CLI accepts a --database flag for all relevant commands
  • Geni supports reading and parsing a geni.toml configuration file
  • Commands correctly target the specified database using either the flag or geni.toml configuration
  • Documentation is updated to explain the new feature and geni.toml usage
  • Error handling is implemented for invalid database specifications and configuration issues

Your feedback and additional ideas for this feature are welcome!

@emilpriver
Copy link
Owner

Hey!
Thank you for the contributing with this issue. I like the idea and I think I might tweak the database_token to allow to read ENV variable mainly as this is a secret. But I like the idea! :D

@emilpriver emilpriver added the enhancement New feature or request label Aug 26, 2024
@emilpriver
Copy link
Owner

Btw, PRs are welcome :D

@emilpriver emilpriver linked a pull request Aug 28, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants