mirror of
https://github.com/inventree/InvenTree.git
synced 2026-11-09 10:33:05 +00:00
Tweaks to fixture data setup command (#13047)
This commit is contained in:
1 parent
b69beb9f38
commit
bef18f0390
1 file changed
+12
-3
@@ -1579,8 +1579,14 @@ def delete_data(c, force: bool = False, migrate: bool = False, verbose: bool = F
|
||||
success('Existing data deleted')
|
||||
|
||||
|
||||
@task(post=[rebuild_models, rebuild_thumbnails])
|
||||
def import_fixtures(c):
|
||||
@task(
|
||||
post=[rebuild_models, rebuild_thumbnails],
|
||||
help={
|
||||
'clear': 'Clear existing data before importing fixtures',
|
||||
'verbose': 'Print verbose output from management commands',
|
||||
},
|
||||
)
|
||||
def import_fixtures(c, clear: bool = False, verbose: bool = False):
|
||||
"""Import fixture data into the database.
|
||||
|
||||
This command imports all existing test fixture data into the database.
|
||||
@@ -1590,6 +1596,9 @@ def import_fixtures(c):
|
||||
- Running this command may overwrite existing database data!!
|
||||
- Don't say you were not warned...
|
||||
"""
|
||||
if clear:
|
||||
delete_data(c, force=True, verbose=verbose)
|
||||
|
||||
fixtures = [
|
||||
# Build model
|
||||
'build',
|
||||
@@ -1617,7 +1626,7 @@ def import_fixtures(c):
|
||||
|
||||
command = 'loaddata ' + ' '.join(fixtures)
|
||||
|
||||
manage(c, command, pty=True)
|
||||
manage(c, command, pty=True, verbose=verbose)
|
||||
|
||||
|
||||
# Execution tasks
|
||||
|
||||
Reference in new issue
Block a user