मैं माइग्रेशन वाले ऐप के लिए Field.db_index
का उपयोग करके मॉडल फ़ील्ड पर इंडेक्स जोड़ने की कोशिश कर रहा हूं। Django's documentation सब मैं क्या करने की जरूरत को देखते हुए db_index=True
स्थापित करने के लिए है:माइग्रेशन के साथ Django में मॉडल फ़ील्ड्स में इंडेक्स जोड़ना
class Person(models.Model):
first_name = models.CharField()
last_name = models.CharField(db_index=True)
और उसके बाद मैं पहली बार नई Django के प्रवासन की कोशिश की:
./manage.py makemigrations app-name
लेकिन प्रवासन परिवर्तन की सूचना नहीं लगता है और नहीं जोड़ता है एक सूचकांक बनाने के लिए एसक्यूएल कमांड। इसलिए मैं django-admin.py
की कोशिश की के रूप में समझाया here:
django-admin.py sqlindexes app-name
लेकिन है कि या तो एसक्यूएल आदेश मुद्रित नहीं करता है और यह निम्न त्रुटि के साथ बाहर निकल जाता है:
CommandError: App 'app-name' has migrations. Only the sqlmigrate and sqlflush commands can be used when an app has migrations.