I have created Custom Table Using below code. Table has been created successfully with columns.
<?xml version="1.0"?>
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
<table name="custom_table" resource="default" engine="innodb" comment="Custom Table">
<column xsi:type="int" name="inc_id" padding="11" unsigned="false" nullable="false" identity="true" comment="ID"/>
<column xsi:type="varchar" name="title" nullable="false" length="255" comment="Title"/>
<column xsi:type="varchar" name="subtitle" nullable="false" length="255" comment="Subtitle"/>
<constraint xsi:type="primary" name="PRIMARY">
<column name="inc_id"/>
</constraint>
</table>
</schema>
But when i try to remove the column by removing the subtitle column, It doesn't get deleted.My Updated Xml looks like this,
<?xml version="1.0"?>
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
<table name="custom_table" resource="default" engine="innodb" comment="Custom Table">
<column xsi:type="int" name="inc_id" padding="11" unsigned="false" nullable="false" identity="true" comment="ID"/>
<column xsi:type="varchar" name="title" nullable="false" length="255" comment="Title"/>
<constraint xsi:type="primary" name="PRIMARY">
<column name="inc_id"/>
</constraint>
</table>
</schema>
I have run following command after removing the column from xml,which created db_schema_whitelist.json in etc folder.
$ bin/magento setup:db-declaration:generate-whitelist [options]
Finally upgrade command.
$ bin/magento setup:upgrade