mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	Migration plan: 1. Add NULLable .last_update_id column to UserPresence with default 0 for new objects. 2. Backfill the value to 0 for old UserPresences, can be done in the background while server is running. 3. Make the column non-NULL. 4. Add new model PresenceSequence and create its rows for old realms.
		
			
				
	
	
		
			30 lines
		
	
	
		
			1000 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
		
			1000 B
		
	
	
	
		
			Python
		
	
	
	
	
	
# Generated by Django 5.0.5 on 2024-05-02 02:17
 | 
						|
 | 
						|
from django.db import migrations, models
 | 
						|
 | 
						|
 | 
						|
class Migration(migrations.Migration):
 | 
						|
    atomic = False
 | 
						|
 | 
						|
    dependencies = [
 | 
						|
        ("zerver", "0524_remove_userprofile_onboarding_steps"),
 | 
						|
    ]
 | 
						|
 | 
						|
    operations = [
 | 
						|
        # Create a new column, making it NULLable to avoid locking the table
 | 
						|
        # rewriting rows with a non-NULL default value.
 | 
						|
        migrations.AddField(
 | 
						|
            model_name="userpresence",
 | 
						|
            name="last_update_id",
 | 
						|
            field=models.PositiveBigIntegerField(db_index=True, null=True),
 | 
						|
        ),
 | 
						|
        # This is an SQL noop, since Django doesn't add defaults at database level.
 | 
						|
        # The default guarantees new rows will have a value. Old rows can get backfilled
 | 
						|
        # in the next migration.
 | 
						|
        migrations.AlterField(
 | 
						|
            model_name="userpresence",
 | 
						|
            name="last_update_id",
 | 
						|
            field=models.PositiveBigIntegerField(db_index=True, default=0, null=True),
 | 
						|
        ),
 | 
						|
    ]
 |