1

I have a Django app deployed on DjangoZoom. People have been signing up, so there are users in that database.

I want to restructure the database of one of my apps within the project. My plan was to drop all the tables then do syncdb to establish the new structure. Then, I would add all the content from the site back by installing locally-created fixtures on the production database.

The problem is I would lose all this user data with the plan. How do I just drop the relevant tables (the ones for which I can re-load the content with fixtures) and leave the auth tables intact? Please note that on DjangoZoom I only have the ability to run manage.py commands with --noinput and I can not access the database directly. Also, my project is in Django 1.3, so using manage.py reset app_name has been deprecated.

I suppose I could do south migrations for this, but it is a relatively simple change and since I have all the data in fixtures anyway it doesn't seem worth it. Any suggestions?

gohnjanotis
  • 6,513
  • 6
  • 37
  • 57
  • You could try creating the new tables (along with fixtures and models) that you want to use and then change your application code so that it inserts into both tables (this will necessarily be slower). Then, when you're happy with the new tables, just drop the old tables and remove the old models/fixtures. – tjarratt Sep 19 '11 at 16:54

2 Answers2

0

Just do:

./manage.py reset appname
Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895
  • I tried this, but it says there are still relations with other tables in other apps that prevent it from being deleted even though I've also done reset on those apps. Also, the Django docs say that 'reset' is deprecated in 1.3. – gohnjanotis Sep 19 '11 at 18:36
0

I ended up implementing south for migrations to make changes to the tables on DjangoZoom instead of trying to clear the tables for some apps.

The changes were easily made to the existing database by using south's schemamigration --auto to generate a migration for the changes. Also, doing a migration allowed me to preserve most of the content in my project.

gohnjanotis
  • 6,513
  • 6
  • 37
  • 57