Cannot set django-activity-stream database tables

Using django-south, is it possible to configure a table only in the latest, most recent configuration, without applying all previous migrations?

We are interested in using a third-party tool (django-activity-stream), but we are having difficulty performing all the migrations for several unknown reasons (possibly with MySQL problems regarding a specific field) - in particular, migration 003, which causes an error

_mysql_exceptions.OperationalError: (1170, "BLOB / TEXT column" object_id "is used in the key specification without key length") "I strongly suspect that avoiding migration and going directly to the current schema will avoid this.

The ability to transfer back is not required, only now you need to go to the current scheme, and I do not want to crack the package to deal with this. It seems I can’t install the commands or is it possible?

configurations:

south 0.7.6, django 1.3.x, mysql 5.5.x, django-activity-stream 0.4.4

+7
source share
2 answers

This error occurs due to the way actstream processes its shared foreign keys. The problem occurs with MySql, because it sees text fields without any specified length.

This error can be resolved if migration 0003 is missing.

Change the following things when migrating 0003_text_field_ids , 0004_char_field_ids to actstream:

0003_text_field_ids.py:

  • delete everything in def forwards(self, orm) , def backwards(self, orm) and just write pass in both.
  • Change TextField to PositiveIntegerField .

0004_char_field_ids.py:

  • In def backwards(self, orm) change the TextField to PositiveIntegerField in all db.altercolumns() .

This makes the 0003 noop migration using pass for forwards and back and makes the model definition using PositiveIntegerFields for the shared foreign keys, so they are saved in the same state as the 0001 migration. By doing this, the 0004 migration can receive from PositiveIntegerFields to varChars . The fix then changes the 0004 migration, so the reverse migration changes to PositiveIntegerFields instead of TextFields .

This hopefully fix your problem.

+4
source

I do not think the problem is caused by migrations, even syncdb will give you the same result.

The error occurs because MySQL can only index the first N characters of a BLOB or TEXT column. Thus, you should have the TEXT or BLOB field / column type that you are trying to make as a primary key or index.

With a full BLOB or TEXT without a length value, MySQL cannot guarantee the uniqueness of the column as its variable and dynamic sizes. Thus, when using the BLOB or TEXT types, the value N must be specified as an index so that MySQL can determine the key length.

Try to fix this problem, and then try to apply migration, it should work well. and Yes, you can apply any migrations and skip the old ones, but I recommend not to do this, since this is not how the south is supposed to be used.

Hope I made things a little clear.

+2
source

All Articles