0

I searched all over and don't see anyone with the same issue.

Below are steps I tried to solve this with no success

  • I deleted the module from setup_module table.
  • I don't see any errors in var/log/debug I don't see the log below, I do see the log from registration.php I put in
  • It works for the other plugin I have under BB/StoreSchedule/Setup

I tried running the commands below:

  • php bin/magento setup:upgrade
  • php bin/magento setup:di:compile
  • php bin/magento cache:clean
  • I looked over my code for typos 50+ times
  • I did not see the log from the InstallSchema in the log file.

Please any suggestions!

I am running Magento ver. 2.3.2

I am running on a mac using https://github.com/markshust/docker-magento as my dev environment

Running in the following mode

app@c98698704947:~/html$ php bin/magento deploy:mode:show
Current application mode: default. (Note: Environment variables may override this value.)

InstallSchema.php

<?php

namespace BB\CustomerGroup\Setup;

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

/**
 * @codeCoverageIgnore
 */
class InstallSchema implements InstallSchemaInterface
{
  /**
   * {@inheritdoc}
   * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
   */
  public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
  {
    $writer = new \Zend\Log\Writer\Stream(BP . '/var/log/debug.log');
    $logger = new \Zend\Log\Logger();
    $logger->addWriter($writer);
    $logger->info('TEST GOT HERE');

    $setup->startSetup();
    $table = $setup->getTable('customer_group');
    $setup->getConnection()->addColumn(
      $table,
      'zip_codes',
      [
        'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
        'length' => 255,
        'nullable' => true,
        'default' => '',
        'comment' => 'Zip codes covered by this customer group'
      ]
    );
    $setup->endSetup();
  }
}
  • Hello, welcome to Magento Stack Exchange. Could you please tell me what is your Magento version? – Khoa TruongDinh Sep 5 at 3:03
  • @KhoaTruongDinh I am using Magento ver. 2.3.2. I'll add to the question – Y Talansky Sep 5 at 4:20
  • did you see the "TEST GOT HERE" write in your installschema in the log file? – aravind Sep 5 at 4:39
  • @aravind. No I did not see the log. I put another log in the register file and that I saw. – Y Talansky Sep 5 at 12:42
  • I think You need to add that field in customer_group using upgradeschema..As that table is already created..So custom attributes should be added using upgradeschema – aravind Sep 5 at 12:49
0

First You Need To Change the Mode Default to Developer Mode.

After This InstallSchema.php That shown Below

<?php

namespace vendor\module_name\Setup;
use Magento\Framework\Setup\SchemaSetupInterface ;
use Magento\Framework\Setup\ModuleContextInterface;

class InstallSchema implements \Magento\Framework\Setup\InstallSchemaInterface
{

    public function install(SchemaSetupInterface $setup,ModuleContextInterface $context)
    {
        $installer = $setup;
        $installer->startSetup();
        if (!$installer->tableExists('table_name')) {
            $table = $installer->getConnection()->newTable(
                $installer->getTable('table_name')
            )

                ->addColumn(
                    'zip_codes',
                    \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
                    255,
                    ['nullable => false'],
                    'Zip Code'
                );

            $installer->getConnection()->createTable($table);

            $installer->getConnection()->addIndex(
                $installer->getTable('table_name'),
                $setup->getIdxName(
                    $installer->getTable('table_name'),
                    ['zip_codes'],
                    \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT
                ),
                ['zip_codes'],
                \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT
            );
        }
        $installer->endSetup();
    }
}

Note :: First Delete from Setup_module Tabel then Run Commna php bin/magento setup:upgrade Because the installschema run's one time at the installtion of the module

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.