mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	models: Add unique constraint on RealmUserDefault.realm.
This model is by designed intended to exist on a 1:1 relationship with Realms, and we attempt to ensure that with application code, but we should have a unique constraint too, since a database with duplicate such entries would be corrupted. We do this via the standard Django OneToOneField.
This commit is contained in:
		
							
								
								
									
										21
									
								
								zerver/migrations/0378_alter_realmuserdefault_realm.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								zerver/migrations/0378_alter_realmuserdefault_realm.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,21 @@
 | 
			
		||||
# Generated by Django 3.2.12 on 2022-03-05 02:59
 | 
			
		||||
 | 
			
		||||
import django.db.models.deletion
 | 
			
		||||
from django.db import migrations, models
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Migration(migrations.Migration):
 | 
			
		||||
 | 
			
		||||
    dependencies = [
 | 
			
		||||
        ("zerver", "0377_message_edit_history_format"),
 | 
			
		||||
    ]
 | 
			
		||||
 | 
			
		||||
    operations = [
 | 
			
		||||
        migrations.AlterField(
 | 
			
		||||
            model_name="realmuserdefault",
 | 
			
		||||
            name="realm",
 | 
			
		||||
            field=models.OneToOneField(
 | 
			
		||||
                on_delete=django.db.models.deletion.CASCADE, to="zerver.realm"
 | 
			
		||||
            ),
 | 
			
		||||
        ),
 | 
			
		||||
    ]
 | 
			
		||||
		Reference in New Issue
	
	Block a user