diefenbach / django-lfs

An online-shop based on Django
http://www.getlfs.com
BSD 3-Clause "New" or "Revised" License
622 stars 222 forks source link

Added missed columns of 'addresses_baseadress' in 'lfs_migrate.py' #117

Closed voronind closed 10 years ago

pigletto commented 11 years ago

These columns are added by South migration

voronind commented 11 years ago

But lfs_migrate will crash before that. When we recreate addresses.

(env)dimka@dimka-pc:~/Dropbox/Work/dice64$ python manage.py lfs_migrate
Detected version: 0.7
Traceback (most recent call last):
  File "manage.py", line 11, in <module>
    execute_manager(settings)
  File "/home/dimka/Dropbox/Work/dice64/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager
    utility.execute()
  File "/home/dimka/Dropbox/Work/dice64/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/dimka/Dropbox/Work/dice64/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 191, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/dimka/Dropbox/Work/dice64/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 220, in execute
    output = self.handle(*args, **options)
  File "/home/dimka/Dropbox/Repos/django-lfs/lfs/core/management/commands/lfs_migrate.py", line 51, in handle
    self.migrate_to_08(application, version)
  File "/home/dimka/Dropbox/Repos/django-lfs/lfs/core/management/commands/lfs_migrate.py", **line 149**, in migrate_to_08
    email = address["email"],
  File "/home/dimka/Dropbox/Work/dice64/env/local/lib/python2.7/site-packages/django/db/models/manager.py", line 138, in create
    return self.get_query_set().create(**kwargs)
  File "/home/dimka/Dropbox/Work/dice64/env/local/lib/python2.7/site-packages/django/db/models/query.py", line 360, in create
    obj.save(force_insert=True, using=self.db)
  File "/home/dimka/Dropbox/Work/dice64/env/local/lib/python2.7/site-packages/django/db/models/base.py", line 460, in save
    self.save_base(using=using, force_insert=force_insert, force_update=force_update)
  File "/home/dimka/Dropbox/Work/dice64/env/local/lib/python2.7/site-packages/django/db/models/base.py", line 504, in save_base
    self.save_base(cls=parent, origin=org, using=using)
  File "/home/dimka/Dropbox/Work/dice64/env/local/lib/python2.7/site-packages/django/db/models/base.py", line 553, in save_base
    result = manager._insert(values, return_id=update_pk, using=using)
  File "/home/dimka/Dropbox/Work/dice64/env/local/lib/python2.7/site-packages/django/db/models/manager.py", line 195, in _insert
    return insert_query(self.model, values, **kwargs)
  File "/home/dimka/Dropbox/Work/dice64/env/local/lib/python2.7/site-packages/django/db/models/query.py", line 1436, in insert_query
    return query.get_compiler(using=using).execute_sql(return_id)
  File "/home/dimka/Dropbox/Work/dice64/env/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 791, in execute_sql
    cursor = super(SQLInsertCompiler, self).execute_sql(None)
  File "/home/dimka/Dropbox/Work/dice64/env/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 735, in execute_sql
    cursor.execute(sql, params)
  File "/home/dimka/Dropbox/Work/dice64/env/local/lib/python2.7/site-packages/django/db/backends/util.py", line 34, in execute
    return self.cursor.execute(sql, params)
  File "/home/dimka/Dropbox/Work/dice64/env/local/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py", line 234, in execute
    return Database.Cursor.execute(self, query, params)
django.db.utils.DatabaseError: table addresses_baseaddress has no column named created
pigletto commented 11 years ago

I've modified migration command and south migrations, please try if it works for you now

voronind commented 11 years ago
...
management.call_command('migrate', all=True, fake="0001")
  File "/home/dimka/Dropbox/Work/dice64/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 166, in call_command
    return klass.execute(*args, **defaults)
  File "/home/dimka/Dropbox/Work/dice64/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 220, in execute
    output = self.handle(*args, **options)
  File "/home/dimka/Dropbox/Work/dice64/env/local/lib/python2.7/site-packages/south/management/commands/migrate.py", line 105, in handle
    ignore_ghosts = ignore_ghosts,
  File "/home/dimka/Dropbox/Work/dice64/env/local/lib/python2.7/site-packages/south/migration/__init__.py", line 191, in migrate_app
    success = migrator.migrate_many(target, workplan, database)
  File "/home/dimka/Dropbox/Work/dice64/env/local/lib/python2.7/site-packages/south/migration/migrators.py", line 298, in migrate_many
    interactive=self.interactive)
  File "/home/dimka/Dropbox/Work/dice64/env/local/lib/python2.7/site-packages/south/db/generic.py", line 808, in send_pending_create_signals
    interactive=interactive)
  File "/home/dimka/Dropbox/Work/dice64/env/local/lib/python2.7/site-packages/south/db/generic.py", line 829, in really_send_create_signal
    app = models.get_app(app_label)
  File "/home/dimka/Dropbox/Work/dice64/env/local/lib/python2.7/site-packages/django/db/models/loading.py", line 140, in get_app
    raise ImproperlyConfigured("App with label %s could not be found" % app_label)
django.core.exceptions.ImproperlyConfigured: App with label addresses could not be found
voronind commented 11 years ago

May be remove manage.py migrate from lfs_migrate?

  1. Instruction contains this commands
  2. User can have another apps, which will break.
voronind commented 11 years ago

When I run 'python manage.py migrate --all --fake 0001' in console there are no this error, but raises another.

pigletto commented 11 years ago

Works for me.

manage.py migrate has to be there. Do you have addresses app added to your INSTALLED_APPS?

voronind commented 11 years ago

No.

portlets app raises errors during migration too. some tables exists.

INSTALLED_APPS = [ ... "portlets", 'lfs.portlet', ... ]

Migration instruction keep silent about that.

pigletto commented 11 years ago

Instruction doesn't say anything about that because it is supposed to "just work" :)

Do you run lfs_migrate on clean 0.7 database? If migration script has failed and you're trying to just run it again then this might be a reason. Please always run lfs_migrate on 'clean' 0.7 db.

I've checked migration like that:

  1. installed lfs-buildout-development-0.7 and created database file (sqlite)
  2. installed lfs-buildout-development (trunk) and copied database from 0.7 to it
  3. run lfs_migrate

This worked for me. Might be that you have some issues with applications etc. Please check if your settings are similar to ones in trunk version of lfs-buildout-development.

pigletto commented 11 years ago

also check if apps in buildout.cfg are correct ones

voronind commented 11 years ago

I run it yesterday. It works good for me.

PS I learned about existing lfs-buildout-development now =)