I'm using cnprog latest (git clone) and tried database migration with django evolution as described in [a former question][1], but migration fails. In short here is what i did:

  • added django_evloution to cnprog's settings.py
  • manage.py syncdb in cnprog's root
  • added django_evloution to osqa's settings.py
  • manage.py syncdb in osqa's root and below is the rest

any suggestions?

     den@ev:~/osqa > python manage.py syncdb 
    Syncing...
    Creating table south_migrationhistory
    Adding baseline version for new models
    Project signature has changed - an evolution is required

Synced:
     > django.contrib.auth
     > django.contrib.contenttypes
     > django.contrib.sessions
     > django.contrib.sites
     > django.contrib.admin
     > django.contrib.markup
     > django_evolution
     > django_authopenid
     > south

Not synced (use migrations):
     - forum
    (use ./manage.py migrate to migrate these)
    den@ev:~/osqa > python manage.py evolve --hint --execute 
    Cannot delete a primary key.
    den@ev:~/osqa > python manage.py evolve --execute 
    The stored evolutions do not completely resolve all model changes.
    Run `./manage.py evolve --hint` to see a suggestion for the changes required.

The following are the changes that could not be resolved:
    The model django_authopenid.UserPasswordQueue has been deleted
    The model django_authopenid.RegistrationKey has been deleted
    In model django_authopenid.UserAssociation:
        Field 'id' has been deleted
        In field 'user':
            Property 'unique' has changed
        In field 'openid_url':
            Property 'primary_key' has changed
    In model auth.User:
        Field 'gold' has been deleted
        Field 'badges' has been deleted
        Field 'questions_per_page' has been deleted
        Field 'use_uploaded' has been deleted
        Field 'email_key' has been deleted
        Field 'date_of_birth' has been deleted
        Field 'location' has been deleted
        Field 'website' has been deleted
        Field 'email_isvalid' has been deleted
        Field 'silver' has been deleted
        Field 'bronze' has been deleted
        Field 'favorite_questions' has been deleted
        Field 'about' has been deleted
        Field 'real_name' has been deleted
        Field 'reputation' has been deleted
        Field 'gravatar' has been deleted
        Field 'last_seen' has been deleted
    The model forum.EmailFeed has been deleted
    The model forum.FlaggedItem has been deleted
    The model forum.QuestionRevision has been deleted
    The model forum.AnonymousAnswer has been deleted
    The model forum.AnonymousQuestion has been deleted
    The model forum.AnswerRevision has been deleted
    The model forum.FavoriteQuestion has been deleted
    The model forum.Repute has been deleted
    The model forum.Activity has been deleted
    The model forum.Book has been deleted
    The model forum.BookAuthorInfo has been deleted
    The model forum.BookAuthorRss has been deleted
    The model forum.AnonymousEmail has been deleted
    The model forum.PrivateMessage has been deleted
    In model forum.Comment:
        Field 'comment' has been deleted
        Field 'added_at' has been deleted
        Field 'object_id' has been deleted
        Field 'content_type' has been deleted
        Field 'id' has been deleted
        Field 'user' has been deleted
    In model forum.Question:
        Field 'wiki' has been deleted
        Field 'vote_up_count' has been deleted
        Field 'answer_accepted' has been deleted
        Field 'deleted_by' has been deleted
        Field 'offensive_flag_count' has been deleted
        Field 'closed_at' has been deleted
        Field 'deleted_at' has been deleted
        Field 'id' has been deleted
        Field 'last_activity_by' has been deleted
        Field 'view_count' has been deleted
        Field 'locked_at' has been deleted
        Field 'author' has been deleted
        Field 'comment_count' has been deleted
        Field 'score' has been deleted
        Field 'vote_down_count' has been deleted
        Field 'closed' has been deleted
        Field 'last_edited_by' has been deleted
        Field 'favourite_count' has been deleted
        Field 'tags' has been deleted
        Field 'deleted' has been deleted
        Field 'answer_count' has been deleted
        Field 'locked' has been deleted
        Field 'closed_by' has been deleted
        Field 'close_reason' has been deleted
        Field 'last_activity_at' has been deleted
        Field 'tagnames' has been deleted
        Field 'locked_by' has been deleted
        Field 'html' has been deleted
        Field 'added_at' has been deleted
        Field 'summary' has been deleted
        Field 'wikified_at' has been deleted
        Field 'title' has been deleted
        Field 'last_edited_at' has been deleted
    In model forum.Award:
        Field 'node' has been added
        Field 'trigger' has been added
        Field 'action' has been added
        Field 'notified' has been deleted
        Field 'object_id' has been deleted
        Field 'content_type' has been deleted
        In field 'user':
            Property 'related_model' has changed
    In model forum.Answer:
        Field 'wiki' has been deleted
        Field 'accepted' has been deleted
        Field 'locked_at' has been deleted
        Field 'locked' has been deleted
        Field 'vote_up_count' has been deleted
        Field 'accepted_at' has been deleted
        Field 'author' has been deleted
        Field 'deleted' has been deleted
        Field 'locked_by' has been deleted
        Field 'question' has been deleted
        Field 'added_at' has been deleted
        Field 'deleted_by' has been deleted
        Field 'comment_count' has been deleted
        Field 'html' has been deleted
        Field 'vote_down_count' has been deleted
        Field 'offensive_flag_count' has been deleted
        Field 'wikified_at' has been deleted
        Field 'last_edited_by' has been deleted
        Field 'score' has been deleted
        Field 'id' has been deleted
        Field 'last_edited_at' has been deleted
    In model forum.Tag:
        Field 'marked_by' has been added
        In field 'created_by':
            Property 'related_model' has changed
        In field 'deleted_by':
            Property 'related_model' has changed
    In model forum.Vote:
        Field 'node' has been added
        Field 'value' has been added
        Field 'action' has been added
        Field 'object_id' has been deleted
        Field 'vote' has been deleted
        Field 'content_type' has been deleted
        In field 'user':
            Property 'related_model' has changed
    In model forum.Badge:
        Field 'awarded_to' has been added
        Field 'cls' has been added
        Field 'multiple' has been deleted
        Field 'description' has been deleted
        Field 'slug' has been deleted
        Field 'name' has been deleted
    den@ev:~/osqa > python manage.py migrate forum 
    Running migrations for forum:
     - Migrating forwards to 0037_initial.
     > forum:0001_initial
     ! Error found during real run of migration! Aborting.

! Since you have a database that does not support running
     ! schema-altering statements in transactions, we have had 
     ! to leave it in an interim state between migrations.

! You *might* be able to recover with:   = DROP TABLE `forum_user` CASCADE; []
       = DROP TABLE `activity` CASCADE; []
       = DROP TABLE `forum_subscriptionsettings` CASCADE; []
       = DROP TABLE `forum_validationhash` CASCADE; []
       = DROP TABLE `forum_authkeyuserassociation` CASCADE; []
       = DROP TABLE `vote` CASCADE; []
       = DROP TABLE `flagged_item` CASCADE; []
       = DROP TABLE `comment` CASCADE; []
       = DROP TABLE `tag` CASCADE; []
       = DROP TABLE `forum_markedtag` CASCADE; []
       = DROP TABLE `question` CASCADE; []
       = DROP TABLE `question_followed_by` CASCADE; []
       = DROP TABLE `question_tags` CASCADE; []
       = DROP TABLE `forum_questionsubscription` CASCADE; []
       = DROP TABLE `favorite_question` CASCADE; []
       = DROP TABLE `question_revision` CASCADE; []
       = DROP TABLE `forum_anonymousquestion` CASCADE; []
       = DROP TABLE `answer` CASCADE; []
       = DROP TABLE `answer_revision` CASCADE; []
       = DROP TABLE `forum_anonymousanswer` CASCADE; []
       = DROP TABLE `badge` CASCADE; []
       = DROP TABLE `award` CASCADE; []
       = DROP TABLE `repute` CASCADE; []
       = DROP TABLE `forum_keyvalue` CASCADE; []

! The South developers regret this has happened, and would
     ! like to gently persuade you to consider a slightly
     ! easier-to-deal-with DBMS.

Traceback (most recent call last):
      File "manage.py", line 13, in <module>
        execute_manager(settings)
      File "/usr//lib/python2.5/site-packages/django_1.1.1/core/management/__init__.py", line 362, in execute_manager
        utility.execute()
      File "/usr//lib/python2.5/site-packages/django_1.1.1/core/management/__init__.py", line 303, in execute
        self.fetch_command(subcommand).run_from_argv(self.argv)
      File "/usr//lib/python2.5/site-packages/django_1.1.1/core/management/base.py", line 195, in run_from_argv
        self.execute(*args, **options.__dict__)
      File "/usr//lib/python2.5/site-packages/django_1.1.1/core/management/base.py", line 222, in execute
        output = self.handle(*args, **options)
      File "/usr/lib/python2.5/site-packages/South-0.7-py2.5.egg/south/management/commands/migrate.py", line 102, in handle
        delete_ghosts = delete_ghosts,
      File "/usr/lib/python2.5/site-packages/South-0.7-py2.5.egg/south/migration/__init__.py", line 202, in migrate_app
        success = migrator.migrate_many(target, workplan, database)
      File "/usr/lib/python2.5/site-packages/South-0.7-py2.5.egg/south/migration/migrators.py", line 215, in migrate_many
        result = migrator.__class__.migrate_many(migrator, target, migrations, database)
      File "/usr/lib/python2.5/site-packages/South-0.7-py2.5.egg/south/migration/migrators.py", line 284, in migrate_many
        result = self.migrate(migration, database)
      File "/usr/lib/python2.5/site-packages/South-0.7-py2.5.egg/south/migration/migrators.py", line 121, in migrate
        result = self.run(migration)
      File "/usr/lib/python2.5/site-packages/South-0.7-py2.5.egg/south/migration/migrators.py", line 95, in run
        return self.run_migration(migration)
      File "/usr/lib/python2.5/site-packages/South-0.7-py2.5.egg/south/migration/migrators.py", line 77, in run_migration
        migration_function()
      File "/usr/lib/python2.5/site-packages/South-0.7-py2.5.egg/south/migration/migrators.py", line 56, in <lambda>
        return (lambda: direction(orm))
      File "/home/den/osqa/forum/migrations/0001_initial.py", line 42, in forwards
        ('activity_type', self.gf('django.db.models.fields.SmallIntegerField')()),
      File "/usr/lib/python2.5/site-packages/South-0.7-py2.5.egg/south/db/generic.py", line 210, in create_table
        ', '.join([col for col in columns if col]),
      File "/usr/lib/python2.5/site-packages/South-0.7-py2.5.egg/south/db/generic.py", line 134, in execute
        cursor.execute(sql, params)
      File "/usr//lib/python2.5/site-packages/django_1.1.1/db/backends/mysql/base.py", line 84, in execute
        return self.cursor.execute(query, args)
      File "/usr//lib/python2.5/site-packages/MySQL_python-1.2.2-py2.5-linux-i686.egg/MySQLdb/cursors.py", line 166, in execute
        self.errorhandler(self, exc, value)
      File "/usr//lib/python2.5/site-packages/MySQL_python-1.2.2-py2.5-linux-i686.egg/MySQLdb/connections.py", line 35, in defaulterrorhandler
        raise errorclass, errorvalue
    _mysql_exceptions.OperationalError: (1050, "Table 'activity' already exists")

[1]: http://meta.osqa.net/question/62/how-do-i-migrate-database-from-cnprog-to-osqa

asked 15 May '10, 21:50

hinoglu's gravatar image

hinoglu
16131
accept rate: 0%

btw, are you running cnprog somewhere in a live site and want to "migrate" to OSQA, or your starting a fresh installation?

(15 May '10, 22:29) Hernani Cerq... ♦♦

I'm running a live site, but trying the migration on a copy of database and existing code base.

(16 May '10, 15:48) hinoglu

Be prepared for some fun :-) Current osqa codebase and schema have left cnprog behind a lot, and I guess this will not be easy, and will involve some complex operations, specially because you will not be able to do it directly from cnprog to the current codebase and some intermediary steps will be required.

Grab some coffee backup your database and try the following recipe:

  1. First thing, clone our old repo into some folder (old_osqa for example):
    git clone git://github.com/OSQA/osqa.git old_osqa

  2. Now checkout some old revision before things started to diverge more seriously:
    cd old_osqa
    git checkout 717ee87bfe528af0839a

  3. Move settings_local.py.dist to settings_local.py, and set up the database credentials.

  4. Now is time to follow the instructions in that other question and use django evolution to do some introspection and modify the fields.

  5. Now travel a bit further in time and checkout a newer revision
    git checkout 5b60c2ce933d28d9cc99

  6. Run the following commands in order:
    python manage.py syncdb
    python manage.py create_subscriptions
    python manage.py create_extended_user

  7. Now is time to checkout our latest code (from the new repo), somewhere in a different folder:
    svn co http://svn.osqa.net/svnroot/osqa/trunk/ osqa

  8. Proceed as a normal install, using the same database credentials as above, except for the database creation commands.

  9. Make sure you have south installed and run:
    python manage.py syncdb
    python manage.py migrate forum 0001 --fake
    python manage.py migrate forum

Test everything and make sure the new installation is working. If you encounter any sort of problems on any of those steps, just post some comment here and I'll try to help you the best as I can.

link

answered 15 May '10, 22:25

Hernani%20Cerqueira's gravatar image

Hernani Cerq... ♦♦
16.8k65975
accept rate: 52%

edited 15 May '10, 22:27

Hernani, thanks for detailed and quick reply. At step 4 evolve command fails with "cannot delete primary key". Here is the detailed output. http://pastebin.com/nWnysDnQ . Output is from trying to migrate to old_osqa, not to 717ee87bfe528af0839a . I've tried migrating to 717ee87bfe528af0839a at first a few times but all failed with same error, that's why i tried old_osqa.

(15 May '10, 23:15) hinoglu

Well, you should use 717ee87bfe528af0839a for the evolution. Are you sure the output is the same? Probably I got you a revision to new for that. If it keeps failing, try c98f611472b65e8be594 and post the results back.

(16 May '10, 10:13) Hernani Cerq... ♦♦

Now in step 6, running python manage.py create_extended_user fails with "table xyz already exists" errors. ignoring these and continuing, step 9 fails with "table forum_user already exists". I'll try to convert the database manually.Hernani thanks for your help.

(17 May '10, 10:10) hinoglu

You really need to run the migrations, because the is some conversions going on that will be pretty much "impossible" to do manually. For some reasons you already installed tables that were supposed to be created only during migrations. Just drop those tables and you should be fine.

(17 May '10, 10:40) Hernani Cerq... ♦♦

Hi Hernani, http://pastebin.com/ig6nvri7 contains the details of my last try before giving up. I'll retry it later, when i have the required patience :) thanks for help.

(17 May '10, 12:12) hinoglu

Now you were trying to read columns that have been droped in a previous attempt :-) That's the problem of mysql not supporting transactions on schema altering queries. Sorry, we never really thought that there would be people wanting to migrate from cnprog to osqa.

(17 May '10, 12:22) Hernani Cerq... ♦♦

i've begun with cnprog, but it was too much for me to handle constantly. i really do not want to get into that trouble again :) that's why i'd like to migrate to osqa. anyway, if i can find a way to migrate, i'll update this post. thanks.

(17 May '10, 12:35) hinoglu
showing 5 of 7 show 2 more comments
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×37
×7
×1

Asked: 15 May '10, 21:50

Seen: 729 times

Last updated: 17 May '10, 13:22

powered by OSQA