-1

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.
User
  • 23,729
  • 38
  • 124
  • 207

4 Answers4

0

Recreate database is probably the best way. Also you can do it using reset_db management command from django-extensions package.

likeon
  • 791
  • 1
  • 6
  • 19
0

The Django 1.7 support migrate you just run python manage.py migrate again after edit. more features to see: release note

gshmu
  • 1
  • 2
0

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

User
  • 23,729
  • 38
  • 124
  • 207
0

Maybe its lazy, but I run:

django-admin.py reset_db --router=default --noinput
sahutchi
  • 2,223
  • 2
  • 19
  • 20