mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	models: Manage index from migration 0244 with Django.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							0799acf3b6
						
					
				
				
					commit
					cf0eb46afc
				
			@@ -1,6 +1,7 @@
 | 
			
		||||
import time
 | 
			
		||||
 | 
			
		||||
from django.db import connection, migrations
 | 
			
		||||
from django.contrib.postgres.operations import AddIndexConcurrently
 | 
			
		||||
from django.db import connection, migrations, models
 | 
			
		||||
from django.db.backends.postgresql.schema import DatabaseSchemaEditor
 | 
			
		||||
from django.db.migrations.state import StateApps
 | 
			
		||||
from django.db.models import Min
 | 
			
		||||
@@ -78,11 +79,8 @@ class Migration(migrations.Migration):
 | 
			
		||||
        """
 | 
			
		||||
        ),
 | 
			
		||||
        migrations.RunPython(copy_pub_date_to_date_sent, elidable=True),
 | 
			
		||||
        # The name for the index was chosen to match the name of the index Django would create
 | 
			
		||||
        # in a normal migration with AlterField of date_sent to have db_index=True:
 | 
			
		||||
        migrations.RunSQL(
 | 
			
		||||
            """
 | 
			
		||||
        CREATE INDEX CONCURRENTLY zerver_message_date_sent_3b5b05d8 ON zerver_message (date_sent);
 | 
			
		||||
        """
 | 
			
		||||
        AddIndexConcurrently(
 | 
			
		||||
            model_name="message",
 | 
			
		||||
            index=models.Index("date_sent", name="zerver_message_date_sent_3b5b05d8"),
 | 
			
		||||
        ),
 | 
			
		||||
    ]
 | 
			
		||||
 
 | 
			
		||||
@@ -2801,6 +2801,7 @@ class Message(AbstractMessage):
 | 
			
		||||
 | 
			
		||||
    class Meta:
 | 
			
		||||
        indexes = [
 | 
			
		||||
            models.Index("date_sent", name="zerver_message_date_sent_3b5b05d8"),
 | 
			
		||||
            models.Index(
 | 
			
		||||
                "recipient",
 | 
			
		||||
                Upper("subject"),
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user