How to add new table in existing module using UpgradeSchema in Magento 2

i have got the correct working answer.

<?php

namespace Vendor\Module\Setup;

use Magento\Framework\Setup\UpgradeSchemaInterface;
use Magento\Framework\Setup\SchemaSetupInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\DB\Ddl\Table;


class UpgradeSchema implements  UpgradeSchemaInterface
{
  public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
{
    $setup->startSetup();

    if (version_compare($context->getVersion(), '2.0.2', '<')) {
      $setup->getConnection()->addColumn(
        $setup->getTable("enter table name here"),
        'enter new column name here',
        [
          "type" => Table::TYPE_TEXT,
          "nullable" => true,
          "comment" => "xample"
        ]
      );
      $setup->getConnection()->addColumn(
        $setup->getTable("enter table name here"),
        'enter new second column name here',
        [
          "type" => Table::TYPE_TEXT,
          "nullable" => true,
          "comment" => "Xample 2"
        ]
      );
      $setup->getConnection()->addColumn(
        $setup->getTable("enter table name here"),
        'enter new third column name here',
        [
          "type" => Table::TYPE_TEXT,
          "nullable" => true,
          "comment" => "Xample 3"
        ]
      );

    }
    $setup->endSetup();
}
}

also you need to change etc/module.xml file. where setup_version="2.0.1" schema_version="2.0.1" .


Try this

class UpgradeSchema implements UpgradeSchemaInterface
{

    public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
    {
        $installer = $setup;
        $setup->startSetup();

        $version = $context->getVersion();
        $connection = $setup->getConnection();

        if (version_compare($version, '2.0.0') < 0) {
            $connection->addColumn(
                $setup->getTable('my_booster'),
                'author_id',
                [
                    'type' => \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
                    'nullable' => true,
                    'comment' => 'Author ID',

                ]
            );

        }
    }