Skip to content

Commit 7efc21e

Browse files
committed
Add more documentation on custom database back-end
1 parent c6686f1 commit 7efc21e

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

docs/db-engine.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
`psqlextra.backend` is an extension of the standard PostgreSQL back-end that comes with Django. This is required in order to implement automatic migrations for all the extra features that `psqlextra` offers.
2+
3+
## Common pitfalls
4+
### Superuser required
5+
The `psqlextra.backend` attempts to enable the HStore extension through the following statement:
6+
7+
```sql
8+
CREATE EXTENSION IF NOT EXISTS hstore'
9+
```
10+
11+
This requires the user connecting to the database to be a super-user. If you're using a non-superuser to connect to your database, make sure to manually enable the extension on your database, otherwise migrations will fail with an exception:
12+
13+
```
14+
django.db.utils.ProgrammingError: permission denied to create extension "hstore"
15+
HINT: Must be superuser to create this extension.
16+
```
17+
18+
### Using a custom database back-end
19+
Are you already using a custom database back-end that is not the standard PostgreSQL back-end? For example, the `postgis` back-end? You can control the base back-end for `psqlextra` by setting this setting:
20+
21+
```python
22+
POSTGRES_EXTRA_DB_BACKEND_BASE = 'django.contrib.gis.db.backends.postgis'
23+
```
24+
25+
`psqlextra` will use the specified back-end as the base. By default, this is the standard PostgreSQL back-end that comes with Django.

docs/index.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ Explore the documentation to learn about all features:
2020
* [Indexes](/indexes)
2121
* [ConditionalUniqueIndex](/indexes/#conditional-unique-index)
2222

23+
* [Database engine](/db-engine)
24+
2325
## Installation
2426

2527
1. Install the package from PyPi:
@@ -46,6 +48,8 @@ Explore the documentation to learn about all features:
4648

4749
4. Make sure all models that inherit from `psqlextra.models.PostgresModel` or use the `psqlextra.manager.PostgresManager`. Without this, most features **do not work**.
4850

51+
5. Read the documentation about the custom database engine to avoid common pitfalls: [Database engine](/db-engine) .
52+
4953
## Requirements
5054
In order to use this package, your project must be using:
5155

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ pages:
55
- HStore: hstore.md
66
- Signals: signals.md
77
- Indexes: indexes.md
8+
- Database engine: db-engine.md

0 commit comments

Comments
 (0)