2

Is there a simple way to increase the maxlength value of a plain text field that has data in it already?

1

To directly answer the question, there is no simple way in Drupal 8 to modify the schema for a field once it's been populated with data.

But, there is a more complicated way to manage it.

We've used the work done here by J-P Stacey to update a field in our platform.

  • ALTER the database tables directly using raw SQL.
  • Change the site configuration for the field.
  • Force the current, "desired" schema records in Drupal to match.
  • Force the "most recently installed" schema records to also match.

Additional information can be found in this article written by Marcus Bernal.

  • There’s no API for it? So the whole system is informed? – Kevin Feb 10 '18 at 2:23
  • I haven't been able to find one for D8. This example here is pretty close to what you need to do. The gist of it is: collect the field data, remove the field from the db,define and add the new field,put the data back in. I haven't tested this solution but there will be some challenges. If you have a lot of data you may run out of php memory. It also looks like you'll need to do some additional work to update the configs to match. – ec0g Feb 10 '18 at 18:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.