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

Allow table inspection when the database connection config is generated on the fly. #1372

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

rabrowne85
Copy link

@rabrowne85 rabrowne85 commented Sep 2, 2022

Summary

For applications were the developer is using a multi-tenancy setup, utilising multiple databases i.e., one for the landlord and many for the tenants, the database config definition is usually altered by the multi-tenancy package when a new tenant is activated.

This however, means that the database.connections.tenant config is usually missing a value for database.connections.tenant.database so laravel-ide-helper cannot connect to the database to inspect the properties.

This modification adds a new config entry into the ide-helper.php config file that allows for overrides for the database.connections array to be set. When the model generator command is run, these overrides are set in the in-memory config values, such that when the connection is used to inspect the database schema, it has the full information. However, this doesn't have a knock on effect that the database.php config file needs to be constantly altered and then reset.

The user can also elect to use an env() value in the ide-helper.db_connections_override array so that between developers the database name can be set as needed.

This has been referenced in the following issues:
#1141
#1280

An attempt at a pull request #1285 was submitted by vpratfr which attempts a similar idea, but requires specifying a specific connection to use and alters the connection logic. I can see that this could have "breaking" implications and makes things difficult to test. This PR uses the existing connections and allows for the user to specify a database name (in essence) i.e., it's there if the user wants to use it, but if not nothing really changes.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Misc. change (internal, infrastructure, maintenance, etc.)

Checklist

  • Existing tests have been adapted and/or new tests have been added
  • Add a CHANGELOG.md entry
  • Update the README.md
  • Code style has been fixed via composer fix-style

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

1 participant