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 PostgreSQL configuration example #7
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So awesome. I made a few comments, worth minor updates. Most important is you'll probably want a docker volume.
For Drupal 8, the technique would be:
- Edit settings.php and add to the bottom (below settings.ddev.php inclusion):
$databases['default']['default'] = array(
'database' => "db",
'username' => "db",
'password' => "db",
'host' => 'postgres',
'driver' => 'pgsql',
);
## PostgreSQL | ||
|
||
Using PostgreSQL container with PostGIS support provided by [mdillon/postgis | ||
](https://hub.docker.com/r/mdillon/postgis). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Why?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In most of our project, we need some kind of spatial search (locations around you, locations in polygon, distance between locations, ... ) and it's really easy and fast with PostGIS. Until activated, there's zero performance penalty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was saying to say "why" in the README or docker-compose file. So people can understand why you made the choice (and maybe understand whether they should also be using this, or maybe the library version)
- POSTGRES_USER=db | ||
- POSTGRES_DB=db | ||
volumes: | ||
- ".:/mnt/ddev_config" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about a docker volume for the Postgres data so it's not volatile?
](https://hub.docker.com/r/mdillon/postgis). | ||
|
||
### Installation | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A note: People will often want to use the 'php' project type, so that ddev doesn't naively try to mess with their database configuration (AdditionalConfiguration.php or settings.ddev.php, etc)
- `ddev pgsql_export` : Use `pg_dump` to export `db` to `import-db/postgresql.db.sql` | ||
- `ddev pgsql_import` : Use `pgsql` to import `import-db/postgresql.db.sql` into `db` | ||
|
||
To import/export the `db` table automatically add the following hooks to your `config.yaml`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't a docker volume suit most people better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't remember why we did it that way, will look into this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, seems like it was just an example of calculated laziness
. We needed the import/export commands and they "just worked" for us when restarting projects.
I don't think the import-db directory is ever there in ddev any more, it's from long-ago versions of ddev? Wouldn't it be better to export to stdout though? Let people do with that what they will? DDEV_URL is obsolete, I'll comment there. |
1.9 I think.
That's how the script worked at the beginning. But I had issues with the import part where I did not find an easy way to pass stdin into |
Rewrite of pgsql_* commands to use stdin/stdout instead of hardcoded file
# Conflicts: # README.md
The changes to the commands do not seems to work correctly. Executing them manually works, but running them in the hooks does not. Could be stdin/stdout issue as it worked before the change. |
I reverted the commands for now. |
@dacostafilipe I pushed some minor changes to the readme and the commands in 15d9701 - if this is OK with you and you're ready for this to be pulled I'll pull it. |
I'm okay with the changes. Added those to my projects. |
ddev/ddev#1819 will add the ability to omit the db container, and it will be good to add that here, it should make things less confusing for people. |
We are using pgsql for one of our clients in a ddev setup. Usually we "fire" some post-import-db Commands after DB Import. But those commands are not fired after importing the pgsql. Is this still possible? |
Yes, it works on our postgresql project. Our hooks look like this:
|
@dacostafilipe |
Since importing doesn't use |
Example of the configuration we use internally for using PostgreSQL with
ddev