This Add-on allows you to open a DataGrip instance and connect to your local DDEV database without any manual configuration. It can also automatically select between MariaDB and MySQL drivers without any user input, based on the configured Database Family in the DDEV config.
Important
Currently, MariaDB and MySQL are the only supported database types. PostgreSQL may be supported in the future.
ddev add-on get natereprogle/ddev-datagrip
ddev restart
After installation, make sure to commit the .ddev directory to version control.
Note
DDEV doesn’t support changing its DB credentials, so it should be well known that its default credentials are root:root. To configure DataGrip correctly, this Add-On will store these credentials in the .ddev/datagrip folder in your project. If you use tooling such as Gitleaks, be sure to configure it to prevent false positives.
| Argument | Description |
|———-|————-|
| --database [database] | Specify the database to connect to |
| --reset | Resets the DataGrip project, including configuration and generated schemas. A manual refresh will be required upon next launch of DataGrip |
| --auto-refresh [time in seconds] | Enables auto-refresh in DataGrip. This only works if the datasource has been refreshed at least once. Minimum of 0.1 minutes (6 seconds), set to 0 to disable. Default is 1 minute |
| --help | Get command help |
Connect to your local default DDEV database
ddev datagrip
Connect to your local DDEV database using a specific database name
ddev datagrip --database my-db
Reset your datagrip configuration and datasource (note this will require you to manually refresh the datasource onced datagrip is launched)
ddev datagrip --reset
Unlike other SQL tools like Sequel Ace, SQL Pro, and others which can be launched with CLI arguments to immediately connect to a Database, DataGrip requires a “Project”. A “Project” is a directory which contains several configuration files, including ./.idea/dataSources.xml and the DB schema, located in ./.idea/dataSources/ and generated by DataGrip automatically. Projects must be created with the DataGrip GUI.
In order to support DataGrip at all, this Add-On creates a “project” and the necessary configuration files for you within the .ddev/datagrip directory. Normally, when you create a project in DataGrip, you would add a datasource in the UI and DataGrip automatically does an initial “refresh” to generate schemas. However, since the add-on “creates” this datasource for you outside of DataGrip, before DataGrip even launches, DataGrip does not automatically refresh the datasource.
As a result, the initial refresh never happens, and so schema are never generated. Automatic Introspection will also never run, and subsequent launches of DataGrip will never generate schema. No specific configuration settings seemed to be able to change this behavior. The only workaround for this issue is to do a manual refresh on the very first launch of DataGrip. Future usage of the ddev datagrip command will not require a refresh on its own. However, if the DB schema is changed, datagrip may require a manual refresh again. This is a limitation of DataGrip, not DDEV or this add-on. We hope this can be improved in the future.
DDEV uses root:root as its DB credentials. As it’s meant for local development, they’ve also stated they have no plans to allow changing this. This add-on stores DDEV’s DB credentials in plaintext in the JDBC URL within dataSources.xml. Certain tools, like Gitleaks, may pick up on these credentials and throw a fit. You will need to make adjustments to your tooling if storing these credentials in plaintext is an issue.