Search code examples
pythondjangopython-2.7django-1.7

How do you remove all data after running syncdb?


I'm in production and just ran syncdb but I made a mistake and want to delete what syncdb did, including all data in the tables is fine. Just a fresh start in the databases so I can run syncdb again.

(virtualenv-2.7)[root@server mysite]# python manage.py sqlclear mainapp | python manage.py dbshell
CommandError: One or more models did not validate:
app.comment: 'poster' defines a relation with the model 'auth.User', which has been swapped out. Update the relation to point at settings.AUTH_USER_MODEL.
app.myuser: The field named as the USERNAME_FIELD should not be included in REQUIRED_FIELDS on a swappable User model.

Solution

  • As J0HN stated in the comments, the best thing to do to start fresh was to actually just delete the database. I thought it might mess something up, but it won't. Simply login to mysql.

    drop database whatever_your_database_name;
    create databse whatever_your_database_name;
    

    Then simply sync it again with python manage.py syncdb