0

when i try to install my custom module i got an error saying:

Installing schema... PHP Fatal error: Uncaught Error: Class 'Lime\Courier\Setup\Varien_Db_Ddl_Table' not found in C:\xampp7\htdocs\mage2\app\code\Lime\Courier\Setup\InstallSchema.php:81

Fatal error: Uncaught Error: Class 'Lime\Courier\Setup\Varien_Db_Ddl_Table' not found in C:\xampp7\htdocs\mage2\app\code\Lime\Courier\Setup\InstallSchema.php:81

here's my InstallSchema.php code :

<?php


namespace Lime\Courier\Setup;

use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\SchemaSetupInterface;
use Magento\Framework\Setup\InstallSchemaInterface;

class InstallSchema implements InstallSchemaInterface
{

    /**
     * {@inheritdoc}
     */
    public function install(
        SchemaSetupInterface $setup,
        ModuleContextInterface $context
    ) {
        $installer = $setup;
        $installer->startSetup();

        $table_lime_province = $setup->getConnection()->newTable($setup->getTable('lime_province'));


        $table_lime_province->addColumn(
            'province_id',
            \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
            null,
            array('identity' => true,'nullable' => false,'primary' => true,'unsigned' => true,),
            'Entity ID'
        );



        $table_lime_province->addColumn(
            'name',
            \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
            null,
            [],
            'name'
        );


        $table_lime_city = $setup->getConnection()->newTable($setup->getTable('lime_city'));


        $table_lime_city->addColumn(
            'city_id',
            \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
            null,
            array('identity' => true,'nullable' => false,'primary' => true,'unsigned' => true,),
            'Entity ID'
        );



        $table_lime_city->addColumn(
            'name',
            \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
            null,
            [],
            'name'
        );



        $table_lime_city->addColumn(
            'province_id',
            \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
            null,
            [],
            'province_id'
        );

        $table_lime_city->addForeignKey(
             $installer->getFkName('lime_courier/lime_city', 'province_id', 'lime_courier/lime_province','province_id'),
             'province_id',
             $installer->getTable('lime_courier/lime_province'),
             'province_id',
             Varien_Db_Ddl_Table::ACTION_CASCADE,
             Varien_Db_Ddl_Table::ACTION_CASCADE
        );


        $table_lime_subdistrict = $setup->getConnection()->newTable($setup->getTable('lime_subdistrict'));


        $table_lime_subdistrict->addColumn(
            'subdistrict_id',
            \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
            null,
            array('identity' => true,'nullable' => false,'primary' => true,'unsigned' => true,),
            'Entity ID'
        );



        $table_lime_subdistrict->addColumn(
            'name',
            \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
            null,
            [],
            'name'
        );



        $table_lime_subdistrict->addColumn(
            'city_id',
            \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
            null,
            [],
            'city_id'
        );

        $table_lime_subdistrict->addForeignKey(
             $installer->getFkName('lime_courier/lime_subdistrict', 'city_id', 'lime_courier/lime_city','city_id'),
             'city_id',
             $installer->getTable('lime_courier/lime_city'),
             'city_id',
             Varien_Db_Ddl_Table::ACTION_CASCADE,
             Varien_Db_Ddl_Table::ACTION_CASCADE
        );


        $table_lime_courier = $setup->getConnection()->newTable($setup->getTable('lime_courier'));


        $table_lime_courier->addColumn(
            'courier_id',
            \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
            null,
            array('identity' => true,'nullable' => false,'primary' => true,'unsigned' => true,),
            'Entity ID'
        );



        $table_lime_courier->addColumn(
            'name',
            \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
            null,
            [],
            'name'
        );



        $table_lime_courier->addColumn(
            'logo',
            \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
            null,
            [],
            'logo'
        );


        $table_lime_courier_service = $setup->getConnection()->newTable($setup->getTable('lime_courier_service'));


        $table_lime_courier_service->addColumn(
            'courier_service_id',
            \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
            null,
            array('identity' => true,'nullable' => false,'primary' => true,'unsigned' => true,),
            'Entity ID'
        );



        $table_lime_courier_service->addColumn(
            'name',
            \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
            null,
            [],
            'name'
        );



        $table_lime_courier_service->addColumn(
            'service',
            \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
            null,
            [],
            'service'
        );



        $table_lime_courier_service->addColumn(
            'courier_id',
            \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
            null,
            [],
            'courier_id'
        );

        $table_lime_courier_service->addForeignKey(
             $installer->getFkName('lime_courier/lime_courier_service', 'courier_id', 'lime_courier/lime_courier','city_id'),
             'courier_id',
             $installer->getTable('lime_courier/lime_courier'),
             'courier_id',
             Varien_Db_Ddl_Table::ACTION_CASCADE,
             Varien_Db_Ddl_Table::ACTION_CASCADE
        );

        $table_lime_calculated_price = $setup->getConnection()->newTable($setup->getTable('lime_calculated_price'));


        $table_lime_calculated_price->addColumn(
            'calculated_price_id',
            \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
            null,
            array('identity' => true,'nullable' => false,'primary' => true,'unsigned' => true,),
            'Entity ID'
        );



        $table_lime_calculated_price->addColumn(
            'origin_location',
            \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
            null,
            [],
            'origin_location'
        );



        $table_lime_calculated_price->addColumn(
            'city_destination',
            \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
            null,
            [],
            'city_destination'
        );



        $table_lime_calculated_price->addColumn(
            'subs_destination',
            \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
            null,
            [],
            'subs_destination'
        );



        $table_lime_calculated_price->addColumn(
            'courier_service_id',
            \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
            null,
            [],
            'courier_service_id'
        );



        $table_lime_calculated_price->addColumn(
            'description',
            \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
            null,
            [],
            'description'
        );



        $table_lime_calculated_price->addColumn(
            'price',
            \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
            null,
            [],
            'price'
        );



        $table_lime_calculated_price->addColumn(
            'estimation_time',
            \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
            null,
            [],
            'estimation_time'
        );



        $table_lime_calculated_price->addColumn(
            'created_at',
            \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP,
            null,
            [],
            'created_at'
        );



        $table_lime_courier_service->addColumn(
            'updated_at',
            \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP,
            null,
            [],
            'updated_at'
        );


        $setup->getConnection()->createTable($table_lime_calculated_price);

        $setup->getConnection()->createTable($table_lime_courier_service);

        $setup->getConnection()->createTable($table_lime_courier);

        $setup->getConnection()->createTable($table_lime_subdistrict);

        $setup->getConnection()->createTable($table_lime_city);

        $setup->getConnection()->createTable($table_lime_province);

        $setup->endSetup();
    }
}
0

You have to replace in above code,

Replace

   Varien_Db_Ddl_Table::ACTION_CASCADE,

With

   \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE

in all places in above code. Remove var folder and run command

php bin/magento setup:upgrade
| improve this answer | |
  • it works, but after that when i try to run my magento page there is exception log error saying main.CRITICAL: Exception: Item (Magento\Framework\App\Config\Value\Interceptor) with the same ID "0" already exists. in C:\xampp7\htdocs\mage2\vendor\magento\framework\Data\Collection.php:406 Stack trace: – Idham Choudry Jan 6 '17 at 5:29
  • you can just remove var folder first remove module entry from your setup_module table and after you run upgrade command. – Rakesh Jesadiya Jan 6 '17 at 5:33
  • Have you done using above tricks? – Rakesh Jesadiya Jan 6 '17 at 5:45
  • when i try to run upgrade i got the following error Item (Magento\Framework\App\Config\Value\Interceptor) with the same ID "0" already exists. – Idham Choudry Jan 6 '17 at 6:08
  • which error have you faced? – Rakesh Jesadiya Jan 6 '17 at 6:09
0

Use $installer->getConnection() in place of $setup->getConnection().

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.