mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Django migrations doesn't account for PostgreSQL completely
This was a weird bug to run into.  Basically I changed a CharField into
a ForeignKey field and ran `makemigrations` to get the job done.
However, rather than doing a `RemoveField` and an `AddField`, migrations
created a single `AlterField` which worked just fine in SQLite, but blew
up in PostgreSQL with:
    psycopg2.ProgrammingError: operator class "varchar_pattern_ops" does
    not accept data type integer
The fix was to rewrite the single migration into the two separate steps.
			
			
This commit is contained in:
		| @@ -47,7 +47,11 @@ class Migration(migrations.Migration): | ||||
|             ], | ||||
|         ), | ||||
|         migrations.RunPython(move_sender_strings_to_sender_model), | ||||
|         migrations.AlterField( | ||||
|         migrations.RemoveField( | ||||
|             model_name='document', | ||||
|             name='sender', | ||||
|         ), | ||||
|         migrations.AddField( | ||||
|             model_name='document', | ||||
|             name='sender', | ||||
|             field=models.ForeignKey(blank=True, on_delete=django.db.models.deletion.CASCADE, to='documents.Sender'), | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Daniel Quinn
					Daniel Quinn