Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Spruced up the ApiKey migration to not fail on MySQL.

  • Loading branch information...
commit e41ec9c92cd157f2b911f7f27abc3f71614bfb4a 1 parent 504a487
Daniel Lindsley toastdriven authored
28 docs/compatibility_notes.rst
View
@@ -0,0 +1,28 @@
+.. _ref-compatibility-notes:
+
+===================
+Compatibility Notes
+===================
+
+
+Tastypie does it's best to be a good third-party app, trying to interoperate
Daniel Gerzo
dgerzo added a note

s/it's/its/

Daniel Lindsley Owner

@dgerzo Fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+with the widest range of Django environments it can. However, there are times
+where certain things aren't possible. We'll do our best to document them here.
+
+
+``ApiKey`` Database Index
+-------------------------
+
+When the ``ApiKey`` model was added to Tastypie, an index was lacking on the
+``key`` field. This was the case until the v0.9.12 release. The model was
+updated & a migration was added (``0002_add_apikey_index.py``). However, due
+to the way MySQL works & the way Django generates index names, this migration
+would fail miserably on many MySQL installs.
+
+If you are using MySQL, South & the ``ApiKey`` authentication class, you should
+manually add an index for the the ``ApiKey.key`` field. Something to the effect
+of::
+
+ BEGIN; -- LOLMySQL
+ CREATE INDEX tastypie_apikey_key_index ON tastypie_apikey (`key`);
+ COMMIT;
1  docs/index.rst
View
@@ -14,6 +14,7 @@ interfaces.
non_orm_data_sources
tools
testing
+ compatibility_notes
resources
bundles
2  docs/toc.rst
View
@@ -11,6 +11,7 @@ Table Of Contents
non_orm_data_sources
tools
testing
+ compatibility_notes
resources
bundles
@@ -23,6 +24,7 @@ Table Of Contents
throttling
paginator
geodjango
+ content_types
cookbook
debugging
10 tastypie/migrations/0002_add_apikey_index.py
View
@@ -8,12 +8,14 @@
class Migration(SchemaMigration):
def forwards(self, orm):
- # Adding index on 'ApiKey', fields ['key']
- db.create_index('tastypie_apikey', ['key'])
+ if not db.backend_name in ('mysql', 'sqlite'):
+ # Adding index on 'ApiKey', fields ['key']
+ db.create_index('tastypie_apikey', ['key'])
def backwards(self, orm):
- # Removing index on 'ApiKey', fields ['key']
- db.delete_index('tastypie_apikey', ['key'])
+ if not db.backend_name in ('mysql', 'sqlite'):
+ # Removing index on 'ApiKey', fields ['key']
+ db.delete_index('tastypie_apikey', ['key'])
models = {
'auth.group': {
Please sign in to comment.
Something went wrong with that request. Please try again.