mirror of
				https://github.com/django/django.git
				synced 2025-10-31 01:25:32 +00:00 
			
		
		
		
	[1.8.x] Fixed #24893 -- Fixed lack of unique constraint when changing a field from primary_key=True to unique=True
Backport of e1e6399c2c from master
			
			
This commit is contained in:
		| @@ -659,7 +659,9 @@ class BaseDatabaseSchemaEditor(object): | ||||
|             for sql, params in post_actions: | ||||
|                 self.execute(sql, params) | ||||
|         # Added a unique? | ||||
|         if not old_field.unique and new_field.unique: | ||||
|         if (not old_field.unique and new_field.unique) or ( | ||||
|             old_field.primary_key and not new_field.primary_key and new_field.unique | ||||
|         ): | ||||
|             self.execute(self._create_unique_sql(model, [new_field.column])) | ||||
|         # Added an index? | ||||
|         if (not old_field.db_index and new_field.db_index and | ||||
|   | ||||
		Reference in New Issue
	
	Block a user