1.Add to new table in database:

<?php
/*
 * Add to new table in database warranty_stickernumber_master assignment to product
 * This table will trak record for sticker id assignment to product
 */
 
$installer = $this;

$installer->startSetup();

$installer->run("
                
        DROP TABLE IF EXISTS {$this->getTable('warranty_stickernumber_master')};
        CREATE TABLE {$this->getTable('warranty_stickernumber_master')} (
          `id` bigint(20) unsigned NOT NULL auto_increment COMMENT 'ID',
          `sticker_number` varchar(255) NOT NULL COMMENT 'Sticker Number',
          `serial_number` varchar(255) NOT NULL COMMENT 'Serial Number',
          `status` tinyint(4) NOT NULL,
          `created_time` datetime NULL,
          `update_time` datetime NULL,
          PRIMARY KEY (`id`),
          UNIQUE KEY `sticker_number` (`sticker_number`),
          UNIQUE KEY `serial_number` (`serial_number`)
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
    ");
$installer->endSetup();
?>

2.Update or add existing table in database:

<?php

/*
 add upgrade for adding new fields
15-03-2018
 */

$installer = $this;

$installer->startSetup();

$installer->run("
                
        ALTER TABLE {$this->getTable('affiliateplus_account')}
        ADD COLUMN `instagram_handle` VARCHAR(255) NULL DEFAULT NULL AFTER `moneybooker_email`;
        
        ALTER TABLE {$this->getTable('affiliateplus_account')}
        ADD COLUMN `facebook_handle` VARCHAR(255) NULL DEFAULT NULL AFTER `instagram_handle`;
        
        ALTER TABLE {$this->getTable('affiliateplus_account')}
        ADD COLUMN `youtube_channel` VARCHAR(255) NULL DEFAULT NULL AFTER `facebook_handle`;
        
        ALTER TABLE {$this->getTable('affiliateplus_account')}
        ADD COLUMN `specialty` VARCHAR(255) NULL DEFAULT NULL AFTER `youtube_channel`;
        
        ALTER TABLE {$this->getTable('affiliateplus_account')}
        ADD COLUMN `preferred_nicotine_level` VARCHAR(255) NULL DEFAULT NULL AFTER `specialty`;
        
        ALTER TABLE {$this->getTable('affiliateplus_account')}
        ADD COLUMN `t_shirt_size` VARCHAR(255) NULL DEFAULT NULL `preferred_nicotine_level`;
        
        ALTER TABLE {$this->getTable('affiliateplus_account')}
        ADD COLUMN `why_should_be_on_vgod_team` TEXT NULL DEFAULT NULL AFTER `t_shirt_size`;
        
        ALTER TABLE {$this->getTable('affiliateplus_account')} CHANGE `req` `req` VARCHAR(255) NOT NULL COMMENT 'REQ #';
        
    ");
$installer->endSetup();
?>

Categories: Magento

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *