-
Notifications
You must be signed in to change notification settings - Fork 638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Field column size improvements #13025
Field column size improvements #13025
Conversation
[ci skip]
@brandonkelly Is there any risk of the automatic column resizing on option fields causing problems for people using the To be more specific, my thought is that since the resizing occurs when the field is saved, additional options defined via that event might be longer than what's supported by the column size. |
@Mosnar Good point! Yes, that could be an issue. And I don’t think we can safely call the event when determining the column length, because event handlers could return different options depending on the current entry, etc. I’ve just added a new “Column Type” setting for Dropdown and Radio Buttons fields, which has two options – “Automatic” and “varchar”. The setting will be set to “varchar” for existing fields, and “Automatic” for new fields. So you will need to opt into the smart column sizing for existing fields (if you know it’s safe to do so), and you can opt out of it for new ones. |
@brandonkelly Any chance this could be ported to Craft CMS 3? |
@lineke Craft 3 is now feature-locked. Bug/security fixes only now. |
@brandonkelly We are now upgrading to craft 4 in order to solve the issue. Any idea when 4.5 will be released? |
@lineke Probably not for another month or so. You can start using it while it’s still in development by changing your |
Description
Makes the following improvements for custom field
content
table columns:content_<columnName>_bak_<timestamp>
to store the existing column’s non-null values, along with the rows’id
,elementId
, andsiteId
values, and then the original column will be deleted from thecontent
table. (Previously, the column was just renamed to<columnName>_old
, adding to the table’s row size.)null
, then thealter table
command will be attempted once again. (Previously, the column was just renamed to<columnName>_old
and a new column was created, effectively wiping out the field’s existing values until manually reconstructed.)Example
If you have a Dropdown field with
yes
,no
, andmaybe
options, its column type will bevarchar(5)
(instead ofvarchar(255)
as before).If its
maybe
option is removed later on, its column type will be changed tovarchar(3)
. If any entries exist that hadmaybe
selected, a newcontent_<columnName>_bak_<timestamp>
table will be created, which will contain all of the non-null Dropdown field values, and then allmaybe
options will be set tonull
in thecontent
table.Related issues