fballiano / openmage-image-cleaner

Image cleaner for Magento 1 and OpenMage. Cleans orphans category, product and wysiwyg images.
19 stars 3 forks source link

Set auto_increment to 1 after truncating the table #13

Closed ADDISON74 closed 3 years ago

ADDISON74 commented 3 years ago

Here is the code from ImaClean for resetting the table:

        $model = Mage::getModel('defcon2imaclean/imaclean');

        $resource = $model->getResource();
        $connection = $resource->getReadConnection();
        $connection->truncateTable($resource->getMainTable());
        $connection->changeTableAutoIncrement($resource->getMainTable(), 1);

Please set auto_increment value to 1 after truncating the table.

ADDISON74 commented 3 years ago

Checking the database after pressing the Reset button the table auto_increment value is set to 1.

fballiano commented 3 years ago

truncate already resets auto_increment:

https://www.mysqltutorial.org/mysql-reset-auto-increment/#:~:text=Using%20TRUNCATE%20TABLE%20statement,auto%2Dincrement%20value%20to%20zero.&text=By%20using%20the%20TRUNCATE%20TABLE,auto%2Dincrement%20value%20to%20zero.

there's no need for a specific instruction, at least in mysql