Skip to content

Database Templates

LabID Server uses PostgreSQL database templates to provide fast database resets during development and testing. This feature allows developers to quickly return their database to a known state without having to reload fixtures.

Commands

Store Template

python manage.py store_db_template

Creates a template from the current database state. This is typically done after loading initial fixtures or setting up a desired database state.

Reset from Template

python manage.py reset_db_from_template

Resets the database to the previously stored template state. This command will: 1. Terminate existing connections to the database 2. Recreate the database from the template 3. Restore all data to the template state

Use the --force flag to skip confirmation prompt.

Performance

Database templates provide significantly faster resets compared to traditional fixture loading, as they use PostgreSQL's native template functionality for block-level database copying.