﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
28816	Silent data loss when decreasing the max_length of a CharField	Gavin Wahl	Hasan Ramezani	"I have a CharField that I want to decrease the max_length on. I change the value and generate a migration, then run it on my database. 

Desired:

I should get an error from postgres if existing data doesn't fit in the new length:

      ERROR:  value too long for type character varying(5)

Observed:

Any existing data longer than the new_max length is truncated and lost.

This behavior was introducted in #25002, which unconditionally added a cast to the new type. This changes the default behavior of postgres (which is to never lose data), to implicitly truncate. Django should not lose data by default.

"	Bug	closed	Migrations	dev	Normal	fixed			Accepted	1	0	0	0	0	0
