Skip to content

Tool to automatically create a development database for local development by sampling your production database. It maintains referential integrity by looking up the dependencies for the selected rows.

License

Notifications You must be signed in to change notification settings

GetStream/dev_db

 
 

Repository files navigation

Django development database

Tool to automatically create a development database for local development by sampling your production database of your Django application. It maintains referential integrity by looking up the dependencies for the selected rows. Regarding sampling of users, it only selects the site staff, so the customer data will not be compromised.

Installation

Use the Python package manager pip:

  pip install dev_db

Add dev_db to your installed apps:

INSTALLED_APPS = [
    …
    "dev_db",
    …
]

Customization

Optionally, you can customize the DevDBCreator class by creating a new file dev_db_creator.py inside your project:

from dev_db.creator import DevDBCreator


class CustomisedDBCreator(DevDBCreator):
    …

You then need to provide the path to your customised class to your settings file:

DEV_DB_CREATOR = 'your_project.dev_db_creator.CustomisedDBCreator'

Creating the data

  python manage.py create_dev_db

Creating the test fixture usually takes a minute or two on a remote database. By default, the data are saved as development_data.json.gz. If you need to save them as a different filename, use the --output parameter.

Loading the data

First, you need to apply the migrations on an empty database:

  python manage.py migrate

Then, you just load the created fixture from the development_data.json.gz file:

  python manage.py load_dev_db

Beware, this step will truncate the auth_permission and django_content_type tables, which are filled up by the Django migrations. So do not ever attempt to run this command on the production database.

Running tests

From the dev_db_example directory run:

  python manage.py test

About

Tool to automatically create a development database for local development by sampling your production database. It maintains referential integrity by looking up the dependencies for the selected rows.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%