I have using Kiwi TCMS System in development, so I have created more test data. Now I want to delete all the test data, so I tried to reset the Kiwi DB tables using the following command as suggested in the article, https://kiwitcms.org/blog/atodorov/2018/07/30/how-to-backup-docker-volumes-for-kiwi-tcms/
First taken the backup,
docker exec -it kiwi_web /Kiwi/manage.py dumpdata --all --indent 2 > database.json
Then deleted all table records,
docker exec -it kiwi_web /bin/bash -c '/Kiwi/manage.py sqlflush | /Kiwi/manage.py dbshell'
I know this command has deleted everything including initial setup data completely from DB, so I have tried to apply the initial setup using the following commands,
docker exec -it kiwi_web /Kiwi/manage.py migrate
docker exec -it kiwi_web /Kiwi/manage.py createsuperuser
docker exec -it kiwi_web /Kiwi/manage.py refresh_permissions
The First 2 worked fine, but the last refresh_permissions was throwing an error, Refer to the error screenshot
This leads, some of the permission-related settings like groups are not restored.
Seems I'm doing some wrong way to delete all data and restore with the required initial setup. pLease correct me what would be the best way here.
You are getting errors because you don't understand what is happening. The commands and blog post referenced above are for backup & restore of the entire database, not selectively removing information which you don't want to be there anymore:
sqlflush
will remove all information from all tablesmigrate
will create DB schema (which already exists) and initial records in some tables. Because the DB schema already exists and the internal Django reference to which migration has been applied last hasn't changed you get a "No migrations to apply" messagerefresh_permissions
fails because it is looking for a group with the name "Administrator"You can either:
manage.py shell
.