2
0
mirror of https://github.com/inventree/inventree-docs.git synced 2025-04-27 05:06:43 +00:00
Oliver Walters 3483c85380 Initial commit
- Copied from inventree.github.io
2020-09-21 22:19:42 +10:00

1.3 KiB

title, layout
title layout
Migrating Data page

Migrating Data

In the case that data needs to be migrated from one database installation to another, the following procedure can be used to export data, initialize the new database, and re-import the data.

!!! warning "Backup Database" Ensure that the original database is securely backed up first!

Export Data

python3 InvenTree/manage.py dumpdata --exclude contenttypes --exclude auth.permission --indent 2 > data.json

This will export all data (including user information) to a json data file.

Initialize New Database

Configure the new database using the normal processes (see Configuration)

Then, ensure that the database schema are correctly initialized in the new database:

python3 InvenTree/manage.py makemigrations
python3 InvenTree/manage.py migrate --run-syncdb

Import Data

The new database should now be correctly initialized with the correct table structures requried to import the data. Run the following command to load the databased dump file into the new database.

python3 InvenTree/manage.py loaddata data.json

!!! info "Character Encoding" If the character encoding of the data file does not exactly match the target database, the import operation may not succeed. In this case, some manual editing of the database JSON file may be required.