On 7/30/2010 8:55 AM, Issac Kelly wrote:
Chris, I didn't think of this when we were talking on IRC, but it's
possible that this is a South bug and not a Satchmo bug as well.
Satchmo Team: Can anyone remember if apps/product/migrations/
0003_add_productattribute_option.py was hand-written by a dev or
auto-generated by South?
Either way, attached is a patch that fixes the following problems I had
when migrating my 0.9.0 Satchmo install to 0.9.1:
- minor typo (Inavlid -> Invalid)
- made the new AttributeOption's description field have the same data as
its name (admin showed blanks for all options)
- changed the migration to only create one AttributeOption per name
(otherwise you'd end up with lots of identical ones)
- fixed the bug causing the AttributeError below (added ".objects"
before ".get" - how could this have worked at all?)
I don't know if this is what all Satchmo users would want the migration
to do, but it did what I wanted.
Let me know if I did something completely wrong. :)
On Thu, Jul 29, 2010 at 6:01 PM, Chris Laux <[email protected]
<mailto:[email protected]>> wrote:
Hello Satchmo users,
I'm trying to upgrade a 0.9.0 Satchmo install to 0.9.1. When
running the migrations, I get this error:
$ ./manage.py migrate product
/home/chris/satchmo091/lib/python2.6/site-packages/registration/models.py:4:
DeprecationWarning: the sha module is deprecated; use the hashlib
module instead
import sha
Running migrations for product:
- Migrating forwards to 0011_split_products.
> product:0002_add_attributeoption
> product:0003_add_productattribute_option
! 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: = ALTER TABLE
`product_productattribute` DROP COLUMN `option_id` CASCADE; []
! The South developers regret this has happened, and would
! like to gently persuade you to consider a slightly
! easier-to-deal-with DBMS.
! NOTE: The error which caused the migration to fail is further up.
Traceback (most recent call last):
File "./manage.py", line 11, in <module>
execute_manager(settings)
File
"/home/chris/satchmo091/lib/python2.6/site-packages/django/core/management/__init__.py",
line 362, in execute_manager
utility.execute()
File
"/home/chris/satchmo091/lib/python2.6/site-packages/django/core/management/__init__.py",
line 303, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File
"/home/chris/satchmo091/lib/python2.6/site-packages/django/core/management/base.py",
line 195, in run_from_argv
self.execute(*args, **options.__dict__)
File
"/home/chris/satchmo091/lib/python2.6/site-packages/django/core/management/base.py",
line 222, in execute
output = self.handle(*args, **options)
File
"/home/chris/satchmo091/lib/python2.6/site-packages/south/management/commands/migrate.py",
line 109, in handle
ignore_ghosts = ignore_ghosts,
File
"/home/chris/satchmo091/lib/python2.6/site-packages/south/migration/__init__.py",
line 202, in migrate_app
success = migrator.migrate_many(target, workplan, database)
File
"/home/chris/satchmo091/lib/python2.6/site-packages/south/migration/migrators.py",
line 220, in migrate_many
result = migrator.__class__.migrate_many(migrator, target,
migrations, database)
File
"/home/chris/satchmo091/lib/python2.6/site-packages/south/migration/migrators.py",
line 291, in migrate_many
result = self.migrate(migration, database)
File
"/home/chris/satchmo091/lib/python2.6/site-packages/south/migration/migrators.py",
line 125, in migrate
result = self.run(migration)
File
"/home/chris/satchmo091/lib/python2.6/site-packages/south/migration/migrators.py",
line 99, in run
return self.run_migration(migration)
File
"/home/chris/satchmo091/lib/python2.6/site-packages/south/migration/migrators.py",
line 81, in run_migration
migration_function()
File
"/home/chris/satchmo091/lib/python2.6/site-packages/south/migration/migrators.py",
line 57, in <lambda>
return (lambda: direction(orm))
File
"/home/chris/satchmo091/src/satchmo/satchmo/apps/product/migrations/0003_add_productattribute_option.py",
line 21, in forwards
attr.option =
orm['product.AttributeOption'].get(name__exact=attr.name
<http://attr.name>)
AttributeError: type object 'AttributeOption' has no attribute 'get'
I've never used South before, but after looking over the migration
script, I thought the problem was a missing ".objects" before the
".get". Trying that, I got an exception because the .get()
returned more than 1 row.
Is this a known problem, or did I miss something stupid? I'm using
MySQL, Python 2.6, South 0.7.1. I'm running the upgrade on a copy
of my live site, both of which are in separate virtualenvs with
separate DBs.
Thanks.
--
Chris Laux
--
You received this message because you are subscribed to the Google
Groups "Satchmo users" group.
To post to this group, send email to
[email protected]
<mailto:[email protected]>.
To unsubscribe from this group, send email to
[email protected]
<mailto:satchmo-users%[email protected]>.
For more options, visit this group at
http://groups.google.com/group/satchmo-users?hl=en.
--
You received this message because you are subscribed to the Google
Groups "Satchmo users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/satchmo-users?hl=en.
--
Chris Laux
--
You received this message because you are subscribed to the Google Groups "Satchmo
users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/satchmo-users?hl=en.
diff -ru
satchmo-orig/satchmo/apps/product/migrations/0002_add_attributeoption.py
satchmo/satchmo/apps/product/migrations/0002_add_attributeoption.py
--- satchmo-orig/satchmo/apps/product/migrations/0002_add_attributeoption.py
2010-05-24 20:42:58.000000000 -0500
+++ satchmo/satchmo/apps/product/migrations/0002_add_attributeoption.py
2010-07-30 16:52:17.000000000 -0500
@@ -12,7 +12,7 @@
# Adding model 'AttributeOption'
db.create_table('product_attributeoption', (
('name',
self.gf('django.db.models.fields.SlugField')(max_length=100, db_index=True)),
- ('error_message',
self.gf('django.db.models.fields.CharField')(default=u'Inavlid Entry',
max_length=100)),
+ ('error_message',
self.gf('django.db.models.fields.CharField')(default=u'Invalid Entry',
max_length=100)),
('sort_order',
self.gf('django.db.models.fields.IntegerField')(default=1)),
('validation',
self.gf('django.db.models.fields.CharField')(max_length=100)),
('id',
self.gf('django.db.models.fields.AutoField')(primary_key=True)),
@@ -26,10 +26,11 @@
if not db.dry_run:
for attr in orm['product.productattribute'].objects.all():
- orm['product.attributeoption'].objects.create(
- description='', name=attr.name,
- validation=default_validation,
- )
+ if
orm['product.attributeoption'].objects.filter(name__exact=attr.name).count() <
1:
+ orm['product.attributeoption'].objects.create(
+ description=attr.name, name=attr.name,
+ validation=default_validation,
+ )
if db.backend_name=='sqlite3':
get_logger().debug("dropping and re-creating table for
ProductAttribute")
diff -ru
satchmo-orig/satchmo/apps/product/migrations/0003_add_productattribute_option.py
satchmo/satchmo/apps/product/migrations/0003_add_productattribute_option.py
---
satchmo-orig/satchmo/apps/product/migrations/0003_add_productattribute_option.py
2010-05-24 20:42:58.000000000 -0500
+++ satchmo/satchmo/apps/product/migrations/0003_add_productattribute_option.py
2010-07-30 16:51:46.000000000 -0500
@@ -18,7 +18,7 @@
if not db.dry_run:
for attr in orm['product.ProductAttribute'].objects.all():
- attr.option =
orm['product.AttributeOption'].get(name__exact=attr.name)
+ attr.option =
orm['product.AttributeOption'].objects.get(name__exact=attr.name)
attr.save()