Drop a column from the table using db_schema.xml in Magento 2.

In Magento 2, You can create a new table using the db_schema.xml file. The table contains many columns based on your requirements.

Check the blog for, How to creates a new database table.

In the future, if you want to remove or drop some column from an existing table you can drop a column using db_schema.xml file.

Let’s assume, You have created a table name, my_custom_table in the database with the email column and you want to remove the email column.

Table with a list of entries and some of the columns you don’t require, You can remove those columns using the attribute disabled=true in a db_schema.xml file.

Create db_schema_whitelist.json file using CLI in Magento 2.

In Magento 2, Magento Version 2.3 and higher version contains the declarative schema approach for database tables history.

You can create db_schema_whitelist.json using the command line with a single command,

The generated file location is the <Vendorname>/<Modulename>/etc/db_schema_whitelist.json in your module.

Magento 2 truncate string to specific limit.

Magento 2 You can truncate the string using Magento best practice.

By default, You can truncate the string using substr() PHP method.

Magento gives Out of the box feature for a truncate string using Magento\Framework\Stdlib\StringUtils class.