Closed (fixed)
Project:
Custom Field
Version:
4.0.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
14 Nov 2025 at 08:26 UTC
Updated:
8 Dec 2025 at 06:15 UTC
Jump to comment: Most recent
Related with #3525924: DB error in updating 3.1.7 => 3.1.8 in that way that the same update function fails, but the reason is different.
I upgraded from 3.1.4 to 3.1.16.
The error is this:
> [error] Exception thrown while performing a schema update. SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_credit_notes_date__timezone' in 'WHERE': SELECT 1 AS `expression`
> FROM
> `node_revision__field_credit_notes` `t`
> WHERE (`field_credit_notes_date` IS NOT NULL) OR (`field_credit_notes_date__timezone` IS NOT NULL) OR (`field_credit_notes_price` IS NOT NULL) OR (`field_credit_notes_file` IS NOT NULL)
> LIMIT 1 OFFSET 0; Array
The timezone column indeed doesn't exist at all in that table, not sure what the best approach is here to fix.
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
apmsooner commentedI wonder if commenting this line out @ line 121 would help?
Attach your field config otherwise prior to pulling in the update and I'll see if I can reproduce the issue and provide a solution.
Comment #3
apmsooner commentedThe timezone column was added in version 3.1.14 so maybe try updating to 3.1.13 first actually.
Comment #4
apmsooner commentedI think the issue is these update hooks are perhaps competing with each other with the schema changes. If you can get past that issue this way, I'll update the project page with a note for others. I'm planning on putting out a 4.0.1 version over the weekend also so would recommend jumping to that as its basically the same but will support 11.x, has lots of new features and 3.x will no longer be supported.
Comment #5
swentel commentedAh yes, I see that custom_field_update_8007() is adding the timezone column, so it's a racing condition indeed.
I'll test the approach of upgrading to 3.1.13 first. I'll ping back when I've tested this approach.. Commenting out line 121 might work isolated, but if another update runs first which also clears these definitions, you'll probably end up with the same error.
(The project isn't on D11 yet, so can't go for 4.x - and we'll keep on the D10 LTS for a while before upgrading anyway)
Comment #6
apmsooner commented4.x still supports D10 also FWIW.
Comment #7
swentel commentedInteresting, did the 3.1.13 approach, then to 4.0.0 but the same timezone problem (on another field/table though), so that trick doesn't seem to work either. Will paste my config later.
Comment #8
swentel commentedActually, I'm confused, the update did run, but with a SQL error:
Comment #9
swentel commentedOh, this is not good: all the data in node_revision__field_invoices and node__field_invoices is lost now (luckily on a local install heh)
Comment #10
apmsooner commentedOdd, others I know updated that had datetime fields and didn't have any of these issues. I'll have to roll back my own local and try doing some tests to see if I can figure something out for you. Appears that 8007 is indeed an issue.
Comment #11
apmsooner commented@swentel,
Theres a weird thing going on between the updates that's causing 8005 to fail when the other updates try to run. I'm not really sure how to fix them so they run in sequence so the only immediate solution I can provide you is to first just install the update for 8005 which is in version 3.1.8 and then you should be able to advance to the latest 4.x version and run the additional updates without issue.
Steps assuming you have ddev installed locally but you will need to deploy each step separately
Let me know please if this gets you past the issue and I'll note this for others. I'm not sure otherwise how to prevent the failure and want to make sure you can at least move forward. Thanks
Comment #12
apmsooner commentedAnd actually step 1 can be:
ddev composer require drupal/custom_field:3.1.13cause the next field update is in 3.1.14 where the conflict is happening.Comment #13
swentel commentedThat did not do the trick. When going to 4.0, I'm getting the same SQL error again as above and the resulting table after the update is empty.
However, I think I know what's going on: my field has two datetime fields. And that's the problem if I read the code right: custom_field_update_8007() iterates every custom field and calls addExtraColumns for that single custom field. It goes in for my first date field, creates the column and then tries to select the existing data. However, at that point, the second date timezone column has not been created yet, and the query does seem to know already there should be a second timezone column, but it doesn't exist yet.
Note: the timezone columns for the two date fields have been created, but it's when the first timezone field is being added, all data is gone because the select query fails. For the second field, the select query does not fail, however, at this point, there's no data anymore as it has been truncated when adding the first column.
I guess ::addExtraColumns should be refactored to allow receiving an array of fields with their extra columns so that they are added all before trying to select the data from the table to preserve the data.
Comment #14
apmsooner commentedAhh okay, thanks for the additional info. I will spend some more time on this today and see if I can come up with an actual fix then. Adding/removing columns to fields has always been a black hole of trial and error for alot of devs but I'll figure this thing out soon.
Comment #15
apmsooner commentedComment #17
apmsooner commentedOkay @swentel,
I've tested this with multiple datetime subfields on various custom fields on multiple entity types with varying cardinality and the updates now do what they are supposed to and data is restored properly. You should be able to update now to latest 4.x with this patch without issue. Please let me know how it goes and thank you for all the feedback!
Comment #18
swentel commentedOk, I've planned to test the patch coming friday and I'll let you know!
Comment #19
apmsooner commented@swentel, are you still able to test this out today? I would like to put out a new release over the weekend and while i'm pretty sure I've fixed this bug, you're testing would instill some additional confidence. Thanks
Comment #20
swentel commented@ampsooner all is good, you can release!
Comment #21
apmsooner commentedThank you for the confirmation and all the great feedback! A new release will be going out over the weekend so look out for that and now that you're on 4.x, you might dig deeper into all the new features related to date fields as well as the new daterange field. There's some pretty advanced functionality in the widget/formatter settings you might find useful :)
Comment #23
apmsooner commented