emilpriver / geni

Standalone database migration tool which works for Postgres, MariaDB, MySQL, Sqlite and LibSQL(Turso).
MIT License
192 stars 3 forks source link

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

Open slavakurilyak opened 2 months ago

slavakurilyak commented 2 months ago

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

Questions

Acceptance Criteria

Your feedback and additional ideas for this feature are welcome!

emilpriver commented 2 months ago

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 commented 2 months ago

Btw, PRs are welcome :D