2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-12 10:05:39 +00:00

Adds a management command to rebuild MPTT models

- Important to do after importing records / fixtures!
- Otherwise very strange things might happen especially when you try to use the API...
This commit is contained in:
Oliver
2021-06-18 21:53:15 +10:00
parent e36414b312
commit 9a4ccedf5c
2 changed files with 70 additions and 2 deletions

View File

@ -129,6 +129,14 @@ def wait(c):
manage(c, "wait_for_db")
@task
def rebuild(c):
"""
Rebuild database models with MPTT structures
"""
manage(c, "rebuild_models")
@task
def migrate(c):
"""
@ -311,7 +319,7 @@ def export_records(c, filename='data.json'):
print("Data export completed")
@task(help={'filename': 'Input filename'})
@task(help={'filename': 'Input filename'}, post=[rebuild])
def import_records(c, filename='data.json'):
"""
Import database records from a file
@ -354,7 +362,7 @@ def import_records(c, filename='data.json'):
print("Data import completed")
@task
@task(post=[rebuild])
def import_fixtures(c):
"""
Import fixture data into the database.