Useful Drush Commands
Log out all active Users:
drush sql-query 'TRUNCATE TABLE sessions;'
Log out all active Users:
drush sql-query 'TRUNCATE TABLE sessions;'
We wanted to change the MRP field 'field_per_item_cost' from DECIMAL (12,2) to DECIMAL (12,3).
The following SQL Query will do the trick:
ALTER TABLE field_data_field_per_item_cost MODIFY field_per_item_cost_value DECIMAL(12,3);
ALTER TABLE field_revision_field_per_item_cost MODIFY field_per_item_cost_value DECIMAL(12,3);
UPDATE field_config SET data = REPLACE(data, '"scale";s:1:"2";', '"scale";s:1:"3";') WHERE field_name = 'field_per_item_cost';
1. Install Upgrade Status[https://www.drupal.org/project/upgrade_status] module to check issues contrib and custom modules compatibility.
2. Remove Upgrade Status when all checks are green and ready to go. Uninstall Upgrade status and remove it from Composer.
composer remove drupal/upgrade_status
3. Temporarily add write access to protected files and directorieschmod 777 sites/default chmod 666 sites/default/*settings.php chmod 666 sites/default/*services.yml
Drush can be used for installing website programmatically. However after installation, you might want to update the synchronization. Install Drupal database: Installs drupal when executed inside the drupal folder.drush site-install --db-url=mysql://dbuser:dbpass@localhost/dbname --account-name=admin --account-pass=secret -y
Remove Shortcut links:drush ev '\Drupal::entityTypeManager()->getStorage("shortcut_set")->load("default")->delete();'
select gid, count(*) from og_membership inner join node on og_membership.etid = node.nid and node.created >= 1678127400 group by gid;select type,count(*) from node group by type;select gid,count(*) from og_membership group by gid;ALTER TABLE node AUTO_INCREMENT = 20000000;SELECT nid, COUNT(vid) AS count FROM node_revision GROUP BY nid ORDER BY count DESC LIMIT 20;mysql> select table_name, table_schema, round(data_length/1024/1024) as data_length_mb, round(data_free/1024/1024) as data_free_mb from information_schema.tables where round(data_free/1024/1024) > 50 order by data_free_mb;+---------------------------------+-----------------+----------------+--------------+
| TABLE_NAME | TABLE_SCHEMA | data_length_mb | data_free_mb |flagging | CREATE TABLE `flagging` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`flag_id` varchar(32) CHARACTER SET ascii NOT NULL COMMENT 'The ID of the target entity.',
`uuid` varchar(128) CHARACTER SET ascii NOT NULL,
`entity_type` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
`entity_id` int unsigned DEFAULT NULL,
`global` tinyint DEFAULT NULL,<?php
/*
* Utility to change the max length of a text field
*/
function change_text_field_max_length($field_name, $new_length) {
$field_table = 'field_data_' . $field_name;
$field_revision_table = 'field_revision_' . $field_name;
$field_column = $field_name . '_value';
// Alter value field length in fields table
db_query("ALTER TABLE `{$field_table}` CHANGE `{$field_column}` `{$field_column}` VARCHAR( {$new_length} )");
// Alter value field length in fields revision table