Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions src/how-to/deploy-production.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,30 +90,30 @@ class NewTable(dj.Manual):
NewTable() # Creates the table
```

## Use Schema Prefixes
## Use Database Prefixes

When multiple projects share a database server, use prefixes to avoid naming collisions and organize schemas.

### Configure Project Prefix
### Configure Database Prefix

```python
import datajoint as dj

dj.config.database.schema_prefix = 'myproject_'
dj.config.database.database_prefix = 'myproject_'
```

Or via environment variable:

```bash
export DJ_SCHEMA_PREFIX=myproject_
export DJ_DATABASE_PREFIX=myproject_
```

Or in `datajoint.json`:

```json
{
"database": {
"schema_prefix": "myproject_"
"database_prefix": "myproject_"
}
}
```
Expand All @@ -125,7 +125,7 @@ Use the prefix when creating schemas:
```python
import datajoint as dj

prefix = dj.config.database.schema_prefix # 'myproject_'
prefix = dj.config.database.database_prefix # 'myproject_'

# Schema names include prefix
subject_schema = dj.Schema(prefix + 'subject') # myproject_subject
Expand Down Expand Up @@ -197,7 +197,7 @@ export DJ_PASS=prod_password

# Production mode
export DJ_CREATE_TABLES=false
export DJ_SCHEMA_PREFIX=myproject_
export DJ_DATABASE_PREFIX=myproject_

# Disable interactive prompts
export DJ_SAFEMODE=false
Expand All @@ -215,7 +215,7 @@ services:
environment:
- DJ_HOST=db.example.com
- DJ_CREATE_TABLES=false
- DJ_SCHEMA_PREFIX=prod_
- DJ_DATABASE_PREFIX=prod_
volumes:
# Mount secrets directory
- type: bind
Expand Down Expand Up @@ -282,7 +282,7 @@ export DJ_PASS=<from-secret-manager>

# Production behavior
export DJ_CREATE_TABLES=false
export DJ_SCHEMA_PREFIX=prod_
export DJ_DATABASE_PREFIX=prod_
export DJ_SAFEMODE=false

# Logging
Expand All @@ -304,9 +304,9 @@ def verify_production_config():
if dj.config.database.create_tables:
errors.append("create_tables should be False in production")

# Check schema prefix is set
if not dj.config.database.schema_prefix:
errors.append("schema_prefix should be set in production")
# Check database prefix is set
if not dj.config.database.database_prefix:
errors.append("database_prefix should be set in production")

# Check not pointing to localhost
if dj.config.database.host == 'localhost':
Expand All @@ -330,7 +330,7 @@ if __name__ == '__main__':
| Setting | Development | Production |
|---------|-------------|------------|
| `database.create_tables` | `true` | `false` |
| `database.schema_prefix` | `""` or `dev_` | `prod_` |
| `database.database_prefix` | `""` or `dev_` | `prod_` |
| `safemode` | `true` | `false` (automated) |
| `loglevel` | `DEBUG` | `WARNING` |

Expand Down
6 changes: 3 additions & 3 deletions src/index.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# DataJoint Documentation

!!! info "Documentation for DataJoint 2.0 (Pre-Release)"
!!! info "Documentation for DataJoint 2.x (Pre-Release)"

This documentation covers **DataJoint 2.0**, currently in pre-release.
This documentation covers **DataJoint 2.0–2.1**, currently in pre-release.

- **Using stable 0.14.x?** Visit [legacy docs](https://datajoint.github.io/datajoint-python)
- **Want to test 2.0?** See [Installation Guide](how-to/installation.md)
- **Want to test 2.x?** See [Installation Guide](how-to/installation.md)
- **Migrating a pipeline?** Follow the [Migration Guide](how-to/migrate-to-v20.md)

## About DataJoint
Expand Down
2 changes: 1 addition & 1 deletion src/reference/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Configuration is loaded in priority order:
| `database.password` | `DJ_PASS` | — | Database password (required) |
| `database.reconnect` | — | `True` | Auto-reconnect on connection loss |
| `database.use_tls` | — | `None` | Enable TLS encryption |
| `database.schema_prefix` | `DJ_SCHEMA_PREFIX` | `""` | Project-specific prefix for schema names |
| `database.database_prefix` | `DJ_DATABASE_PREFIX` | `""` | Prefix for database/schema names |
| `database.create_tables` | `DJ_CREATE_TABLES` | `True` | Default for `Schema(create_tables=)`. Set `False` for production mode |

## Connection Settings
Expand Down