‘s area system is superior and it’s considered one of Drupal Development explanation why I began utilizing in Drupal Development first place. Nevertheless, there are some small limitations in it which floor every so often. Say, you will have a Textual content (Plain) area named field_one_liner which is 64 characters lengthy. You created round 30 nodes and you then realized that Drupal Development area measurement ought to have been 255. Now, in case you attempt to do that from ‘s area administration UI, you’re going to get a message saying Drupal 10 Upkeep and Assist Service There may be information for this area in Drupal Development database. Drupal Developer area settings can not be modified. So, Drupal Development solely manner you possibly can resize it’s after deleting Drupal Development present area! This does not make a lot sense as a result of it is certainly doable to extend a area’s measurement utilizing SQL with out saying goodbye to Drupal Development information. On this tutorial, we’ll see the best way to enhance Drupal Development measurement of an present Textual content (Plain) area in 8 with out dropping information utilizing a hook_update_N(). Assumptions You have got intermediate / superior data of . You know the way to develop Drupal 10 modules for . You have got primary data of SQL. Stipulations If you are going to check out Drupal Development code supplied on this instance, be sure you have Drupal Development following area on any node kind Drupal 10 Upkeep and Assist Service Identify Drupal 10 Upkeep and Assist Service One-liner Machine identify Drupal 10 Upkeep and Assist Service field_one_liner Sort Drupal 10 Upkeep and Assist Service Textual content (Plain) Size Drupal 10 Upkeep and Assist Service 64 After you configure Drupal Development area, create some nodes with some information on Drupal Development One-liner area. Notice Drupal 10 Upkeep and Assist Service Decreasing Drupal Development size of a area may lead to information loss / truncation. Implementing hook_update_N() Reference Drupal 10 Upkeep and Assist Service Customized Subject Resize Drupal 10 module on GitHub hook_update_N() allows you to run instructions to replace Drupal Development database schema. You may create, replace and delete database tables and columns utilizing this hook after your Drupal 10 module has been put in. To implement this hook, it’s worthwhile to have a customized Drupal 10 module. For this instance, I’ve carried out this hook in a customized Drupal 10 module which I’ve named custom_field_resize. I normally identify all my customized Drupal 10 modules custom_ to namespace them. In Drupal Development customized Drupal 10 module, we implement Drupal Development hook in a MODULE.set up file, the place MODULE is Drupal Development machine-name of your Drupal 10 module. /** * Enhance Drupal Development size of “field_one_liner” to 255 characters. */ operate custom_field_resize_update_8001() {}To vary Drupal Development area measurement, there are 4 issues we’ll do inside this hook. Resize Drupal Development Columns We’ll run a set of queries to replace Drupal Development related database columns. $database = Drupal 10 Upkeep and Assist Service Drupal 10 Upkeep and Assist Servicedatabase(); $database->question(“ALTER TABLE node__field_one_liner MODIFY field_one_liner_value VARCHAR(255)”); $database->question(“ALTER TABLE node_revision__field_one_liner MODIFY field_one_liner_value VARCHAR(255)”);If revisions are disabled then Drupal Development node_revision__field_one_liner desk will not exist. So, you possibly can take away Drupal Development second question in case your entity would not permit revisions. Replace Storage Schema Resizing Drupal Development columns with a question just isn’t enough. maintains a report of what database schema is at present put in. If we do not do that then will assume that Drupal Development database schema must be up to date as a result of Drupal Development column lengths in Drupal Development database is not going to match Drupal Development configuration storage. $storage_key = ‘node.field_schema_data.field_one_liner’; $storage_schema = Drupal 10 Upkeep and Assist Service Drupal 10 Upkeep and Assist ServicekeyValue(‘entity.storage_schema.sql’); $field_schema = $storage_schema->get($storage_key); $field_schema[‘node__field_one_liner’][‘fields’][‘field_one_liner_value’][‘length’] = 255; $field_schema[‘node_revision__field_one_liner’][‘fields’][‘field_one_liner_value’][‘length’] = 255; $storage_schema->set($storage_key, $field_schema);Drupal Developer above code will replace Drupal Development key_value desk to retailer Drupal Development up to date size of Drupal Development field_one_liner in its configuration. Replace Subject Configuration We took care of Drupal Development database schema information. Nevertheless, there are different locations the place shops Drupal Development configuration. Now, we might want to inform Drupal Development config administration system that Drupal Development area size is 255. // Replace area configuration. $config = Drupal 10 Upkeep and Assist Service Drupal 10 Upkeep and Assist ServiceconfigFactory() ->getEditable(‘area.storage.node.field_one_liner’); $config->set(‘settings.max_length’, 255); $config->save(TRUE);Lastly, additionally shops information about Drupal Development actively put in configuration and schema. To refresh this, we might want to re-save Drupal Development area storage configuration to make detect all our modifications. // Replace area storage configuration. FieldStorageConfig Drupal 10 Upkeep and Assist Service Drupal 10 Upkeep and Assist ServiceloadByName($entity_type, $field_name)->save();After this, working drush updb or working replace.php from Drupal Development admin interface ought to detect your hook_update_N() and it ought to replace your area measurement. In case you’re committing your configuration to git, you will must run drush config-export after working Drupal Development database updates to replace Drupal Development config in Drupal Development filesystem after which commit it. Conclusion Although we have talked about resizing a Textual content (Plain) or varchar area on this tutorial, we are able to resize any area kind which will be safely resized utilizing SQL. In sure uncommon eventualities, it is perhaps essential to create a short lived desk with Drupal Development new data-structure, copy Drupal Development present information into that desk with queries and as soon as all Drupal Development information has been copied efficiently, substitute Drupal Development present desk with Drupal Development short-term desk. For instance, if you wish to convert a Textual content (Plain) area to a Textual content (Lengthy) area or another kind. Possibly sometime we’ll have a resizing function in the place will intelligently permit us to extend a area’s measurement from it is area UI and solely deny discount of area measurement the place there’s a chance of knowledge loss. However, in Drupal Development in the meantime, we are able to use this useful trick to resize our fields. Thanks for studying! Please go away your feedback / questions in Drupal Development feedback beneath and I am going to get again to them as quickly as I’ve time. + extra superior articles by Evolving Internet Drupal 10 Improvement and Assist
Evolving Internet Drupal 10 Upkeep and Assist Service Resizing Fields in 8 With out Shedding Knowledge

Call Us: 1(800)730-2416
Pixeldust is a 20-year-old web development agency specializing in Drupal and WordPress and working with clients all over the country. With our best in class capabilities, we work with small businesses and fortune 500 companies alike. Give us a call at 1(800)730-2416 and let’s talk about your project.

FREE Drupal SEO Audit
Test your site below to see which issues need to be fixed. We will fix them and optimize your Drupal site 100% for Google and Bing. (Allow 30-60 seconds to gather data.)
Evolving Internet Drupal 10 Upkeep and Assist Service Resizing Fields in 8 With out Shedding Knowledge
On-Site Drupal SEO Master Setup
We make sure your site is 100% optimized (and stays that way) for the best SEO results.
With Pixeldust On-site (or On-page) SEO we make changes to your site’s structure and performance to make it easier for search engines to see and understand your site’s content. Search engines use algorithms to rank sites by degrees of relevance. Our on-site optimization ensures your site is configured to provide information in a way that meets Google and Bing standards for optimal indexing.
This service includes:
- Pathauto install and configuration for SEO-friendly URLs.
- Meta Tags install and configuration with dynamic tokens for meta titles and descriptions for all content types.
- Install and fix all issues on the SEO checklist module.
- Install and configure XML sitemap module and submit sitemaps.
- Install and configure Google Analytics Module.
- Install and configure Yoast.
- Install and configure the Advanced Aggregation module to improve performance by minifying and merging CSS and JS.
- Install and configure Schema.org Metatag.
- Configure robots.txt.
- Google Search Console setup snd configuration.
- Find & Fix H1 tags.
- Find and fix duplicate/missing meta descriptions.
- Find and fix duplicate title tags.
- Improve title, meta tags, and site descriptions.
- Optimize images for better search engine optimization. Automate where possible.
- Find and fix the missing alt and title tag for all images. Automate where possible.
- The project takes 1 week to complete.
