PDOException Object
(
    [message:protected] => SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'affiliateplus_discount'
    [string:Exception:private] => 
    [code:protected] => 42S21
    [file:protected] => /var/www/vhosts/savantinimagento/public_html/lib/Zend/Db/Statement/Pdo.php
    [line:protected] => 228
    [trace:Exception:private] => Array
        (
            [0] => Array
                (
                    [file] => /var/www/vhosts/savantinimagento/public_html/lib/Zend/Db/Statement/Pdo.php
                    [line] => 228
                    [function] => execute
                    [class] => PDOStatement
                    [type] => ->
                    [args] => Array
                        (
                            [0] => Array
                                (
                                )

                        )

                )

            [1] => Array
                (
                    [file] => /var/www/vhosts/savantinimagento/public_html/lib/Varien/Db/Statement/Pdo/Mysql.php
                    [line] => 110
                    [function] => _execute
                    [class] => Zend_Db_Statement_Pdo
                    [type] => ->
                    [args] => Array
                        (
                            [0] => Array
                                (
                                )

                        )

                )

            [2] => Array
                (
                    [file] => /var/www/vhosts/savantinimagento/public_html/lib/Zend/Db/Statement.php
                    [line] => 300
                    [function] => _execute
                    [class] => Varien_Db_Statement_Pdo_Mysql
                    [type] => ->
                    [args] => Array
                        (
                            [0] => Array
                                (
                                )

                        )

                )

            [3] => Array
                (
                    [file] => /var/www/vhosts/savantinimagento/public_html/lib/Zend/Db/Adapter/Abstract.php
                    [line] => 479
                    [function] => execute
                    [class] => Zend_Db_Statement
                    [type] => ->
                    [args] => Array
                        (
                            [0] => Array
                                (
                                )

                        )

                )

            [4] => Array
                (
                    [file] => /var/www/vhosts/savantinimagento/public_html/lib/Zend/Db/Adapter/Pdo/Abstract.php
                    [line] => 238
                    [function] => query
                    [class] => Zend_Db_Adapter_Abstract
                    [type] => ->
                    [args] => Array
                        (
                            [0] => ALTER TABLE sales_flat_order
  ADD COLUMN `affiliateplus_discount` decimal(12,4) default NULL,
  ADD COLUMN `base_affiliateplus_discount` decimal(12,4) default NULL
                            [1] => Array
                                (
                                )

                        )

                )

            [5] => Array
                (
                    [file] => /var/www/vhosts/savantinimagento/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php
                    [line] => 419
                    [function] => query
                    [class] => Zend_Db_Adapter_Pdo_Abstract
                    [type] => ->
                    [args] => Array
                        (
                            [0] => ALTER TABLE sales_flat_order
  ADD COLUMN `affiliateplus_discount` decimal(12,4) default NULL,
  ADD COLUMN `base_affiliateplus_discount` decimal(12,4) default NULL
                            [1] => Array
                                (
                                )

                        )

                )

            [6] => Array
                (
                    [file] => /var/www/vhosts/savantinimagento/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php
                    [line] => 340
                    [function] => query
                    [class] => Varien_Db_Adapter_Pdo_Mysql
                    [type] => ->
                    [args] => Array
                        (
                            [0] => ALTER TABLE sales_flat_order
  ADD COLUMN `affiliateplus_discount` decimal(12,4) default NULL,
  ADD COLUMN `base_affiliateplus_discount` decimal(12,4) default NULL
                        )

                )

            [7] => Array
                (
                    [file] => /var/www/vhosts/savantinimagento/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php
                    [line] => 608
                    [function] => raw_query
                    [class] => Varien_Db_Adapter_Pdo_Mysql
                    [type] => ->
                    [args] => Array
                        (
                            [0] => ALTER TABLE sales_flat_order
  ADD COLUMN `affiliateplus_discount` decimal(12,4) default NULL,
  ADD COLUMN `base_affiliateplus_discount` decimal(12,4) default NULL
                        )

                )

            [8] => Array
                (
                    [file] => /var/www/vhosts/savantinimagento/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php
                    [line] => 590
                    [function] => multi_query
                    [class] => Varien_Db_Adapter_Pdo_Mysql
                    [type] => ->
                    [args] => Array
                        (
                            [0] => 

DROP TABLE IF EXISTS affiliateplus_referer;
DROP TABLE IF EXISTS affiliateplus_payment_paypal;
DROP TABLE IF EXISTS affiliateplus_payment;
DROP TABLE IF EXISTS affiliateplus_transaction;
DROP TABLE IF EXISTS affiliateplus_banner_value;
DROP TABLE IF EXISTS affiliateplus_banner;
DROP TABLE IF EXISTS affiliateplus_account_value;
DROP TABLE IF EXISTS affiliateplus_account;

CREATE TABLE affiliateplus_account(
  `account_id` int(10) unsigned NOT NULL auto_increment,
  `customer_id` int(10) unsigned NOT NULL,
  `address_id` int(10) unsigned NOT NULL default '0',
  `identify_code` varchar(63) NOT NULL default '',
  `name` varchar(255) NOT NULL default '',
  `email` varchar(255) NOT NULL default '',
  `balance` decimal(12,4) NOT NULL default '0',
  `total_commission_received` decimal(12,4) NOT NULL default '0',
  `total_paid` decimal(12,4) NOT NULL default '0',
  `total_clicks` int(11) NOT NULL default '0',
  `unique_clicks` int(11) NOT NULL default '0',
  `paypal_email` varchar(255) NOT NULL default '',
  `created_time` datetime NOT NULL default '0000-00-00 00:00:00',
  `status` tinyint(1) NOT NULL default '2',
  `approved` tinyint(1) NOT NULL default '2',
  UNIQUE(`customer_id`),
  UNIQUE(`identify_code`),
  INDEX(`customer_id`),
  FOREIGN KEY (`customer_id`) REFERENCES customer_entity(`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  PRIMARY KEY (`account_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE affiliateplus_account_value(
  `value_id` int(10) unsigned NOT NULL auto_increment,
  `account_id` int(10) unsigned NOT NULL,
  `store_id` smallint(5) unsigned  NOT NULL,
  `attribute_code` varchar(63) NOT NULL default '',
  `value` text NOT NULL,
  UNIQUE(`account_id`,`store_id`,`attribute_code`),
  INDEX (`account_id`),
  INDEX (`store_id`),
  FOREIGN KEY (`account_id`) REFERENCES affiliateplus_account (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  FOREIGN KEY (`store_id`) REFERENCES core_store (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  PRIMARY KEY (`value_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE affiliateplus_banner(
  `banner_id` int(10) unsigned NOT NULL auto_increment,
  `title` varchar(255) NOT NULL default '',
  `type_id` tinyint(1) NOT NULL default '1',
  `source_file` varchar(255) NOT NULL default '',
  `width` int(11) NOT NULL,
  `height` int(11) NOT NULL,
  `link` varchar(255) NOT NULL,
  `status` tinyint(1) NOT NULL default '1',
  PRIMARY KEY (`banner_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE affiliateplus_banner_value(
  `value_id` int(10) unsigned NOT NULL auto_increment,
  `banner_id` int(10) unsigned NOT NULL,
  `store_id` smallint(5) unsigned  NOT NULL,
  `attribute_code` varchar(63) NOT NULL default '',
  `value` text NOT NULL,
  UNIQUE(`banner_id`,`store_id`,`attribute_code`),
  INDEX (`banner_id`),
  INDEX (`store_id`),
  FOREIGN KEY (`banner_id`) REFERENCES affiliateplus_banner (`banner_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  FOREIGN KEY (`store_id`) REFERENCES core_store (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  PRIMARY KEY (`value_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE affiliateplus_transaction(
  `transaction_id` int(10) unsigned NOT NULL auto_increment,
  `account_id` int(10) unsigned NOT NULL,
  `account_name` varchar(255) NOT NULL default '',
  `account_email` varchar(255)  NOT NULL,
  `customer_id` int(10) unsigned  NOT NULL,
  `customer_email` varchar(255)  NOT NULL,
  `order_id` int(10) unsigned  NOT NULL,
  `order_number` varchar(50) default '',
  `order_item_ids` text default '',
  `order_item_names` text default '',
  `total_amount` decimal(12,4) NOT NULL default '0',
  `commission` decimal(12,4) NOT NULL default '0',
  `discount` decimal(12,4) NOT NULL default '0',
  `created_time` datetime NULL,
  `status` tinyint(1) NOT NULL default '1',
  `store_id` smallint(5) unsigned  NOT NULL,
  INDEX(`account_id`),
  INDEX(`store_id`),
  FOREIGN KEY (`account_id`) REFERENCES affiliateplus_account (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  FOREIGN KEY (`store_id`) REFERENCES core_store (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  PRIMARY KEY (`transaction_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE affiliateplus_payment(
  `payment_id` int(10) unsigned NOT NULL auto_increment,
  `account_id` int(10) unsigned  NOT NULL,
  `account_name` varchar(255) NOT NULL,
  `account_email` varchar(255) NOT NULL,
  `payment_method` varchar(63) NOT NULL default '',
  `amount` decimal(12,4) NOT NULL default '0',
  `fee` decimal(12,4) NOT NULL default '0',
  `request_time` datetime NULL,
  `status` tinyint(1) NOT NULL default '1',
  `description` text NOT NULL,
  `store_ids` text NOT NULL,
  `is_request` tinyint(1) NOT NULL default '1',
  `is_payer_fee` tinyint(1) NOT NULL default '1',
  INDEX(`account_id`),
  FOREIGN KEY (`account_id`) REFERENCES affiliateplus_account (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  PRIMARY KEY (`payment_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE affiliateplus_payment_paypal(
  `payment_paypal_id` int(10) unsigned NOT NULL auto_increment,
  `payment_id` int(10) unsigned NOT NULL,
  `email` varchar(255) NOT NULL default '',
  `transaction_id` varchar(255) NOT NULL default '',
  `description` text NOT NULL default '',
  INDEX(`payment_id`),
  FOREIGN KEY (`payment_id`) REFERENCES affiliateplus_payment (`payment_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  PRIMARY KEY (`payment_paypal_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE affiliateplus_referer(
  `referer_id` int(10) unsigned NOT NULL auto_increment,
  `account_id` int(10) unsigned NOT NULL,
  `referer` varchar(255) NOT NULL default '',
  `url_path` varchar(255) NOT NULL default '/',
  `total_clicks` int(11) NOT NULL default '0',
  `unique_clicks` int(11) NOT NULL default '0',
  `ip_list` longtext NOT NULL default '',
  `store_id` smallint(5) unsigned  NOT NULL,
  INDEX(`account_id`),
  INDEX(`store_id`),
  FOREIGN KEY (`account_id`) REFERENCES affiliateplus_account (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  FOREIGN KEY (`store_id`) REFERENCES core_store (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  PRIMARY KEY (`referer_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

ALTER TABLE sales_flat_order
  ADD COLUMN `affiliateplus_discount` decimal(12,4) default NULL,
  ADD COLUMN `base_affiliateplus_discount` decimal(12,4) default NULL;		


                        )

                )

            [9] => Array
                (
                    [file] => /var/www/vhosts/savantinimagento/public_html/app/code/core/Mage/Core/Model/Resource/Setup.php
                    [line] => 933
                    [function] => multiQuery
                    [class] => Varien_Db_Adapter_Pdo_Mysql
                    [type] => ->
                    [args] => Array
                        (
                            [0] => 

DROP TABLE IF EXISTS affiliateplus_referer;
DROP TABLE IF EXISTS affiliateplus_payment_paypal;
DROP TABLE IF EXISTS affiliateplus_payment;
DROP TABLE IF EXISTS affiliateplus_transaction;
DROP TABLE IF EXISTS affiliateplus_banner_value;
DROP TABLE IF EXISTS affiliateplus_banner;
DROP TABLE IF EXISTS affiliateplus_account_value;
DROP TABLE IF EXISTS affiliateplus_account;

CREATE TABLE affiliateplus_account(
  `account_id` int(10) unsigned NOT NULL auto_increment,
  `customer_id` int(10) unsigned NOT NULL,
  `address_id` int(10) unsigned NOT NULL default '0',
  `identify_code` varchar(63) NOT NULL default '',
  `name` varchar(255) NOT NULL default '',
  `email` varchar(255) NOT NULL default '',
  `balance` decimal(12,4) NOT NULL default '0',
  `total_commission_received` decimal(12,4) NOT NULL default '0',
  `total_paid` decimal(12,4) NOT NULL default '0',
  `total_clicks` int(11) NOT NULL default '0',
  `unique_clicks` int(11) NOT NULL default '0',
  `paypal_email` varchar(255) NOT NULL default '',
  `created_time` datetime NOT NULL default '0000-00-00 00:00:00',
  `status` tinyint(1) NOT NULL default '2',
  `approved` tinyint(1) NOT NULL default '2',
  UNIQUE(`customer_id`),
  UNIQUE(`identify_code`),
  INDEX(`customer_id`),
  FOREIGN KEY (`customer_id`) REFERENCES customer_entity(`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  PRIMARY KEY (`account_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE affiliateplus_account_value(
  `value_id` int(10) unsigned NOT NULL auto_increment,
  `account_id` int(10) unsigned NOT NULL,
  `store_id` smallint(5) unsigned  NOT NULL,
  `attribute_code` varchar(63) NOT NULL default '',
  `value` text NOT NULL,
  UNIQUE(`account_id`,`store_id`,`attribute_code`),
  INDEX (`account_id`),
  INDEX (`store_id`),
  FOREIGN KEY (`account_id`) REFERENCES affiliateplus_account (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  FOREIGN KEY (`store_id`) REFERENCES core_store (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  PRIMARY KEY (`value_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE affiliateplus_banner(
  `banner_id` int(10) unsigned NOT NULL auto_increment,
  `title` varchar(255) NOT NULL default '',
  `type_id` tinyint(1) NOT NULL default '1',
  `source_file` varchar(255) NOT NULL default '',
  `width` int(11) NOT NULL,
  `height` int(11) NOT NULL,
  `link` varchar(255) NOT NULL,
  `status` tinyint(1) NOT NULL default '1',
  PRIMARY KEY (`banner_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE affiliateplus_banner_value(
  `value_id` int(10) unsigned NOT NULL auto_increment,
  `banner_id` int(10) unsigned NOT NULL,
  `store_id` smallint(5) unsigned  NOT NULL,
  `attribute_code` varchar(63) NOT NULL default '',
  `value` text NOT NULL,
  UNIQUE(`banner_id`,`store_id`,`attribute_code`),
  INDEX (`banner_id`),
  INDEX (`store_id`),
  FOREIGN KEY (`banner_id`) REFERENCES affiliateplus_banner (`banner_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  FOREIGN KEY (`store_id`) REFERENCES core_store (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  PRIMARY KEY (`value_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE affiliateplus_transaction(
  `transaction_id` int(10) unsigned NOT NULL auto_increment,
  `account_id` int(10) unsigned NOT NULL,
  `account_name` varchar(255) NOT NULL default '',
  `account_email` varchar(255)  NOT NULL,
  `customer_id` int(10) unsigned  NOT NULL,
  `customer_email` varchar(255)  NOT NULL,
  `order_id` int(10) unsigned  NOT NULL,
  `order_number` varchar(50) default '',
  `order_item_ids` text default '',
  `order_item_names` text default '',
  `total_amount` decimal(12,4) NOT NULL default '0',
  `commission` decimal(12,4) NOT NULL default '0',
  `discount` decimal(12,4) NOT NULL default '0',
  `created_time` datetime NULL,
  `status` tinyint(1) NOT NULL default '1',
  `store_id` smallint(5) unsigned  NOT NULL,
  INDEX(`account_id`),
  INDEX(`store_id`),
  FOREIGN KEY (`account_id`) REFERENCES affiliateplus_account (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  FOREIGN KEY (`store_id`) REFERENCES core_store (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  PRIMARY KEY (`transaction_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE affiliateplus_payment(
  `payment_id` int(10) unsigned NOT NULL auto_increment,
  `account_id` int(10) unsigned  NOT NULL,
  `account_name` varchar(255) NOT NULL,
  `account_email` varchar(255) NOT NULL,
  `payment_method` varchar(63) NOT NULL default '',
  `amount` decimal(12,4) NOT NULL default '0',
  `fee` decimal(12,4) NOT NULL default '0',
  `request_time` datetime NULL,
  `status` tinyint(1) NOT NULL default '1',
  `description` text NOT NULL,
  `store_ids` text NOT NULL,
  `is_request` tinyint(1) NOT NULL default '1',
  `is_payer_fee` tinyint(1) NOT NULL default '1',
  INDEX(`account_id`),
  FOREIGN KEY (`account_id`) REFERENCES affiliateplus_account (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  PRIMARY KEY (`payment_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE affiliateplus_payment_paypal(
  `payment_paypal_id` int(10) unsigned NOT NULL auto_increment,
  `payment_id` int(10) unsigned NOT NULL,
  `email` varchar(255) NOT NULL default '',
  `transaction_id` varchar(255) NOT NULL default '',
  `description` text NOT NULL default '',
  INDEX(`payment_id`),
  FOREIGN KEY (`payment_id`) REFERENCES affiliateplus_payment (`payment_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  PRIMARY KEY (`payment_paypal_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE affiliateplus_referer(
  `referer_id` int(10) unsigned NOT NULL auto_increment,
  `account_id` int(10) unsigned NOT NULL,
  `referer` varchar(255) NOT NULL default '',
  `url_path` varchar(255) NOT NULL default '/',
  `total_clicks` int(11) NOT NULL default '0',
  `unique_clicks` int(11) NOT NULL default '0',
  `ip_list` longtext NOT NULL default '',
  `store_id` smallint(5) unsigned  NOT NULL,
  INDEX(`account_id`),
  INDEX(`store_id`),
  FOREIGN KEY (`account_id`) REFERENCES affiliateplus_account (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  FOREIGN KEY (`store_id`) REFERENCES core_store (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  PRIMARY KEY (`referer_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

ALTER TABLE sales_flat_order
  ADD COLUMN `affiliateplus_discount` decimal(12,4) default NULL,
  ADD COLUMN `base_affiliateplus_discount` decimal(12,4) default NULL;		


                        )

                )

            [10] => Array
                (
                    [file] => /var/www/vhosts/savantinimagento/public_html/app/code/local/Magestore/Affiliateplus/sql/affiliateplus_setup/mysql4-install-0.1.0.php
                    [line] => 155
                    [function] => run
                    [class] => Mage_Core_Model_Resource_Setup
                    [type] => ->
                    [args] => Array
                        (
                            [0] => 

DROP TABLE IF EXISTS affiliateplus_referer;
DROP TABLE IF EXISTS affiliateplus_payment_paypal;
DROP TABLE IF EXISTS affiliateplus_payment;
DROP TABLE IF EXISTS affiliateplus_transaction;
DROP TABLE IF EXISTS affiliateplus_banner_value;
DROP TABLE IF EXISTS affiliateplus_banner;
DROP TABLE IF EXISTS affiliateplus_account_value;
DROP TABLE IF EXISTS affiliateplus_account;

CREATE TABLE affiliateplus_account(
  `account_id` int(10) unsigned NOT NULL auto_increment,
  `customer_id` int(10) unsigned NOT NULL,
  `address_id` int(10) unsigned NOT NULL default '0',
  `identify_code` varchar(63) NOT NULL default '',
  `name` varchar(255) NOT NULL default '',
  `email` varchar(255) NOT NULL default '',
  `balance` decimal(12,4) NOT NULL default '0',
  `total_commission_received` decimal(12,4) NOT NULL default '0',
  `total_paid` decimal(12,4) NOT NULL default '0',
  `total_clicks` int(11) NOT NULL default '0',
  `unique_clicks` int(11) NOT NULL default '0',
  `paypal_email` varchar(255) NOT NULL default '',
  `created_time` datetime NOT NULL default '0000-00-00 00:00:00',
  `status` tinyint(1) NOT NULL default '2',
  `approved` tinyint(1) NOT NULL default '2',
  UNIQUE(`customer_id`),
  UNIQUE(`identify_code`),
  INDEX(`customer_id`),
  FOREIGN KEY (`customer_id`) REFERENCES customer_entity(`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  PRIMARY KEY (`account_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE affiliateplus_account_value(
  `value_id` int(10) unsigned NOT NULL auto_increment,
  `account_id` int(10) unsigned NOT NULL,
  `store_id` smallint(5) unsigned  NOT NULL,
  `attribute_code` varchar(63) NOT NULL default '',
  `value` text NOT NULL,
  UNIQUE(`account_id`,`store_id`,`attribute_code`),
  INDEX (`account_id`),
  INDEX (`store_id`),
  FOREIGN KEY (`account_id`) REFERENCES affiliateplus_account (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  FOREIGN KEY (`store_id`) REFERENCES core_store (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  PRIMARY KEY (`value_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE affiliateplus_banner(
  `banner_id` int(10) unsigned NOT NULL auto_increment,
  `title` varchar(255) NOT NULL default '',
  `type_id` tinyint(1) NOT NULL default '1',
  `source_file` varchar(255) NOT NULL default '',
  `width` int(11) NOT NULL,
  `height` int(11) NOT NULL,
  `link` varchar(255) NOT NULL,
  `status` tinyint(1) NOT NULL default '1',
  PRIMARY KEY (`banner_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE affiliateplus_banner_value(
  `value_id` int(10) unsigned NOT NULL auto_increment,
  `banner_id` int(10) unsigned NOT NULL,
  `store_id` smallint(5) unsigned  NOT NULL,
  `attribute_code` varchar(63) NOT NULL default '',
  `value` text NOT NULL,
  UNIQUE(`banner_id`,`store_id`,`attribute_code`),
  INDEX (`banner_id`),
  INDEX (`store_id`),
  FOREIGN KEY (`banner_id`) REFERENCES affiliateplus_banner (`banner_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  FOREIGN KEY (`store_id`) REFERENCES core_store (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  PRIMARY KEY (`value_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE affiliateplus_transaction(
  `transaction_id` int(10) unsigned NOT NULL auto_increment,
  `account_id` int(10) unsigned NOT NULL,
  `account_name` varchar(255) NOT NULL default '',
  `account_email` varchar(255)  NOT NULL,
  `customer_id` int(10) unsigned  NOT NULL,
  `customer_email` varchar(255)  NOT NULL,
  `order_id` int(10) unsigned  NOT NULL,
  `order_number` varchar(50) default '',
  `order_item_ids` text default '',
  `order_item_names` text default '',
  `total_amount` decimal(12,4) NOT NULL default '0',
  `commission` decimal(12,4) NOT NULL default '0',
  `discount` decimal(12,4) NOT NULL default '0',
  `created_time` datetime NULL,
  `status` tinyint(1) NOT NULL default '1',
  `store_id` smallint(5) unsigned  NOT NULL,
  INDEX(`account_id`),
  INDEX(`store_id`),
  FOREIGN KEY (`account_id`) REFERENCES affiliateplus_account (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  FOREIGN KEY (`store_id`) REFERENCES core_store (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  PRIMARY KEY (`transaction_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE affiliateplus_payment(
  `payment_id` int(10) unsigned NOT NULL auto_increment,
  `account_id` int(10) unsigned  NOT NULL,
  `account_name` varchar(255) NOT NULL,
  `account_email` varchar(255) NOT NULL,
  `payment_method` varchar(63) NOT NULL default '',
  `amount` decimal(12,4) NOT NULL default '0',
  `fee` decimal(12,4) NOT NULL default '0',
  `request_time` datetime NULL,
  `status` tinyint(1) NOT NULL default '1',
  `description` text NOT NULL,
  `store_ids` text NOT NULL,
  `is_request` tinyint(1) NOT NULL default '1',
  `is_payer_fee` tinyint(1) NOT NULL default '1',
  INDEX(`account_id`),
  FOREIGN KEY (`account_id`) REFERENCES affiliateplus_account (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  PRIMARY KEY (`payment_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE affiliateplus_payment_paypal(
  `payment_paypal_id` int(10) unsigned NOT NULL auto_increment,
  `payment_id` int(10) unsigned NOT NULL,
  `email` varchar(255) NOT NULL default '',
  `transaction_id` varchar(255) NOT NULL default '',
  `description` text NOT NULL default '',
  INDEX(`payment_id`),
  FOREIGN KEY (`payment_id`) REFERENCES affiliateplus_payment (`payment_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  PRIMARY KEY (`payment_paypal_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE affiliateplus_referer(
  `referer_id` int(10) unsigned NOT NULL auto_increment,
  `account_id` int(10) unsigned NOT NULL,
  `referer` varchar(255) NOT NULL default '',
  `url_path` varchar(255) NOT NULL default '/',
  `total_clicks` int(11) NOT NULL default '0',
  `unique_clicks` int(11) NOT NULL default '0',
  `ip_list` longtext NOT NULL default '',
  `store_id` smallint(5) unsigned  NOT NULL,
  INDEX(`account_id`),
  INDEX(`store_id`),
  FOREIGN KEY (`account_id`) REFERENCES affiliateplus_account (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  FOREIGN KEY (`store_id`) REFERENCES core_store (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  PRIMARY KEY (`referer_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

ALTER TABLE sales_flat_order
  ADD COLUMN `affiliateplus_discount` decimal(12,4) default NULL,
  ADD COLUMN `base_affiliateplus_discount` decimal(12,4) default NULL;		


                        )

                )

            [11] => Array
                (
                    [file] => /var/www/vhosts/savantinimagento/public_html/app/code/core/Mage/Core/Model/Resource/Setup.php
                    [line] => 624
                    [args] => Array
                        (
                            [0] => /var/www/vhosts/savantinimagento/public_html/app/code/local/Magestore/Affiliateplus/sql/affiliateplus_setup/mysql4-install-0.1.0.php
                        )

                    [function] => include
                )

            [12] => Array
                (
                    [file] => /var/www/vhosts/savantinimagento/public_html/app/code/core/Mage/Core/Model/Resource/Setup.php
                    [line] => 421
                    [function] => _modifyResourceDb
                    [class] => Mage_Core_Model_Resource_Setup
                    [type] => ->
                    [args] => Array
                        (
                            [0] => install
                            [1] => 
                            [2] => 0.3.1
                        )

                )

            [13] => Array
                (
                    [file] => /var/www/vhosts/savantinimagento/public_html/app/code/core/Mage/Core/Model/Resource/Setup.php
                    [line] => 327
                    [function] => _installResourceDb
                    [class] => Mage_Core_Model_Resource_Setup
                    [type] => ->
                    [args] => Array
                        (
                            [0] => 0.3.1
                        )

                )

            [14] => Array
                (
                    [file] => /var/www/vhosts/savantinimagento/public_html/app/code/core/Mage/Core/Model/Resource/Setup.php
                    [line] => 235
                    [function] => applyUpdates
                    [class] => Mage_Core_Model_Resource_Setup
                    [type] => ->
                    [args] => Array
                        (
                        )

                )

            [15] => Array
                (
                    [file] => /var/www/vhosts/savantinimagento/public_html/app/code/core/Mage/Core/Model/App.php
                    [line] => 417
                    [function] => applyAllUpdates
                    [class] => Mage_Core_Model_Resource_Setup
                    [type] => ::
                    [args] => Array
                        (
                        )

                )

            [16] => Array
                (
                    [file] => /var/www/vhosts/savantinimagento/public_html/app/code/core/Mage/Core/Model/App.php
                    [line] => 343
                    [function] => _initModules
                    [class] => Mage_Core_Model_App
                    [type] => ->
                    [args] => Array
                        (
                        )

                )

            [17] => Array
                (
                    [file] => /var/www/vhosts/savantinimagento/public_html/app/Mage.php
                    [line] => 683
                    [function] => run
                    [class] => Mage_Core_Model_App
                    [type] => ->
                    [args] => Array
                        (
                            [0] => Array
                                (
                                    [scope_code] => stressnomore
                                    [scope_type] => website
                                    [options] => Array
                                        (
                                        )

                                )

                        )

                )

            [18] => Array
                (
                    [file] => /var/www/vhosts/stressnomore.co.uk/public_html/index.php
                    [line] => 87
                    [function] => run
                    [class] => Mage
                    [type] => ::
                    [args] => Array
                        (
                            [0] => stressnomore
                            [1] => website
                        )

                )

        )

    [previous:Exception:private] => 
    [errorInfo] => Array
        (
            [0] => 42S21
            [1] => 1060
            [2] => Duplicate column name 'affiliateplus_discount'
        )

    [xdebug_message] => 
PDOException: SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'affiliateplus_discount' in /var/www/vhosts/savantinimagento/public_html/lib/Zend/Db/Statement/Pdo.php on line 228

Call Stack:
    0.0000     630896   1. {main}() /var/www/vhosts/stressnomore.co.uk/public_html/index.php:0
    0.0009     768512   2. Mage::run() /var/www/vhosts/stressnomore.co.uk/public_html/index.php:87
    0.0019    1126848   3. Mage_Core_Model_App->run() /var/www/vhosts/savantinimagento/public_html/app/Mage.php:683
    0.0047    1667584   4. Mage_Core_Model_App->_initModules() /var/www/vhosts/savantinimagento/public_html/app/code/core/Mage/Core/Model/App.php:343
    0.3753    1695568   5. Mage_Core_Model_Resource_Setup::applyAllUpdates() /var/www/vhosts/savantinimagento/public_html/app/code/core/Mage/Core/Model/App.php:417
    0.4613    3531080   6. Mage_Core_Model_Resource_Setup->applyUpdates() /var/www/vhosts/savantinimagento/public_html/app/code/core/Mage/Core/Model/Resource/Setup.php:235
    0.4615    3472200   7. Mage_Core_Model_Resource_Setup->_installResourceDb() /var/www/vhosts/savantinimagento/public_html/app/code/core/Mage/Core/Model/Resource/Setup.php:327
    0.4615    3472360   8. Mage_Core_Model_Resource_Setup->_modifyResourceDb() /var/www/vhosts/savantinimagento/public_html/app/code/core/Mage/Core/Model/Resource/Setup.php:421
    0.4619    3475248   9. include('/var/www/vhosts/savantinimagento/public_html/app/code/local/Magestore/Affiliateplus/sql/affiliateplus_setup/mysql4-install-0.1.0.php') /var/www/vhosts/savantinimagento/public_html/app/code/core/Mage/Core/Model/Resource/Setup.php:624
    0.4637    3492296  10. Mage_Core_Model_Resource_Setup->run() /var/www/vhosts/savantinimagento/public_html/app/code/local/Magestore/Affiliateplus/sql/affiliateplus_setup/mysql4-install-0.1.0.php:155
    0.4637    3492296  11. Varien_Db_Adapter_Pdo_Mysql->multiQuery() /var/www/vhosts/savantinimagento/public_html/app/code/core/Mage/Core/Model/Resource/Setup.php:933
    0.4637    3492296  12. Varien_Db_Adapter_Pdo_Mysql->multi_query() /var/www/vhosts/savantinimagento/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php:590

)