Skip to content
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

[4.x]: Database migration truncated column, data too long #3843

Open
JshGrn opened this issue Jan 8, 2025 · 2 comments
Open

[4.x]: Database migration truncated column, data too long #3843

JshGrn opened this issue Jan 8, 2025 · 2 comments
Labels
bug commerce4 Issues related to Commerce v4 Craft Commerce

Comments

@JshGrn
Copy link

JshGrn commented Jan 8, 2025

What happened?

Description

Performing craft commerce/upgrade I get a database error:
Migrating address data…
Deleted 1 addresses that were not used in orders or customer addresses.
[=========================================================> ] 45% (94/206) ETA: n/aException 'yii\db\Exception' with message 'SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'field_addressNotes_nxprammy' at row 1
The SQL being executed was: INSERT INTO content (elementId, title, siteId, dateCreated, dateUpdated, uid, field_addressAttention_ntgbaazz, field_addressAddress3_lrxlvxzm, field_addressPhone_fsxsdspy, field_addressNotes_nxprammy) VALUES (9627, 'Address', 1, '2021-12-18 18:02:01', '2021-12-18 18:02:01', 'ba14c703-8805-4d98-9b99-cea53ee30231', 'REDACTED', 'REDACTED', '+REDACTED', 'REDACTED')'

in /var/www/html/vendor/yiisoft/yii2/db/Schema.php:676

Error Info:
Array
(
[0] => 22001
[1] => 1406
[2] => Data too long for column 'field_addressNotes_nxprammy' at row 1
)

Caused by: Exception 'PDOException' with message 'SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'field_addressNotes_nxprammy' at row 1'

in /var/www/html/vendor/yiisoft/yii2/db/Command.php:1320

The length of the redacted field was 285. I think this should be a longer text field in the migration.

Steps to reproduce

  1. Have a notes field with content longer than the column supports
  2. Run craft commerce/upgrade

Expected behavior

Migration to finish correctly.

Actual behavior

Throws exception

Craft CMS version

4.10.3

Craft Commerce version

4.6.3.1

PHP version

8.3

Operating system and version

No response

Database type and version

MariaDB

Image driver and version

No response

Installed plugins and versions

@JshGrn JshGrn added bug commerce4 Issues related to Commerce v4 Craft Commerce labels Jan 8, 2025
Copy link

linear bot commented Jan 8, 2025

PT-2375 [4.x]:

@JshGrn JshGrn changed the title [4.x]: [4.x]: Database migration truncated column, data too long Jan 8, 2025
@JshGrn
Copy link
Author

JshGrn commented Jan 13, 2025

The issue is because in commerce_addresses the notes field is set to the type text where the column that is created is set to varchar(255) inside content table.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug commerce4 Issues related to Commerce v4 Craft Commerce
Projects
None yet
Development

No branches or pull requests

1 participant