|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * @copyright For copyright and license information, read the COPYING.txt file. |
| 5 | + * @link /COPYING.txt |
| 6 | + * @license Open Software License (OSL 3.0) |
| 7 | + * @package Mage_Paypal |
| 8 | + */ |
| 9 | + |
| 10 | +/** @var Mage_Paypal_Model_Resource_Setup $installer */ |
| 11 | +$installer = $this; |
| 12 | +$installer->startSetup(); |
| 13 | + |
| 14 | +/** |
| 15 | + * Create table 'paypal/settlement_report' |
| 16 | + */ |
| 17 | +$table = $installer->getConnection() |
| 18 | + ->newTable($installer->getTable('paypal/settlement_report')) |
| 19 | + ->addColumn('report_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, [ |
| 20 | + 'identity' => true, |
| 21 | + 'unsigned' => true, |
| 22 | + 'nullable' => false, |
| 23 | + 'primary' => true, |
| 24 | + ], 'Report Id') |
| 25 | + ->addColumn('report_date', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, [ |
| 26 | + ], 'Report Date') |
| 27 | + ->addColumn('account_id', Varien_Db_Ddl_Table::TYPE_TEXT, 64, [ |
| 28 | + ], 'Account Id') |
| 29 | + ->addColumn('filename', Varien_Db_Ddl_Table::TYPE_TEXT, 24, [ |
| 30 | + ], 'Filename') |
| 31 | + ->addColumn('last_modified', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, [ |
| 32 | + ], 'Last Modified') |
| 33 | + ->addIndex( |
| 34 | + $installer->getIdxName('paypal/settlement_report', ['report_date', 'account_id'], Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE), |
| 35 | + ['report_date', 'account_id'], |
| 36 | + ['type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE], |
| 37 | + ) |
| 38 | + ->setComment('Paypal Settlement Report Table'); |
| 39 | +$installer->getConnection()->createTable($table); |
| 40 | + |
| 41 | +/** |
| 42 | + * Create table 'paypal/settlement_report_row' |
| 43 | + */ |
| 44 | +$table = $installer->getConnection() |
| 45 | + ->newTable($installer->getTable('paypal/settlement_report_row')) |
| 46 | + ->addColumn('row_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, [ |
| 47 | + 'identity' => true, |
| 48 | + 'unsigned' => true, |
| 49 | + 'nullable' => false, |
| 50 | + 'primary' => true, |
| 51 | + ], 'Row Id') |
| 52 | + ->addColumn('report_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, [ |
| 53 | + 'unsigned' => true, |
| 54 | + 'nullable' => false, |
| 55 | + ], 'Report Id') |
| 56 | + ->addColumn('transaction_id', Varien_Db_Ddl_Table::TYPE_TEXT, 19, [ |
| 57 | + ], 'Transaction Id') |
| 58 | + ->addColumn('invoice_id', Varien_Db_Ddl_Table::TYPE_TEXT, 127, [ |
| 59 | + ], 'Invoice Id') |
| 60 | + ->addColumn('paypal_reference_id', Varien_Db_Ddl_Table::TYPE_TEXT, 19, [ |
| 61 | + ], 'Paypal Reference Id') |
| 62 | + ->addColumn('paypal_reference_id_type', Varien_Db_Ddl_Table::TYPE_TEXT, 3, [ |
| 63 | + ], 'Paypal Reference Id Type') |
| 64 | + ->addColumn('transaction_event_code', Varien_Db_Ddl_Table::TYPE_TEXT, 5, [ |
| 65 | + ], 'Transaction Event Code') |
| 66 | + ->addColumn('transaction_initiation_date', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, [ |
| 67 | + ], 'Transaction Initiation Date') |
| 68 | + ->addColumn('transaction_completion_date', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, [ |
| 69 | + ], 'Transaction Completion Date') |
| 70 | + ->addColumn('transaction_debit_or_credit', Varien_Db_Ddl_Table::TYPE_TEXT, 2, [ |
| 71 | + 'nullable' => false, |
| 72 | + 'default' => 'CR', |
| 73 | + ], 'Transaction Debit Or Credit') |
| 74 | + ->addColumn('gross_transaction_amount', Varien_Db_Ddl_Table::TYPE_DECIMAL, '20,6', [ |
| 75 | + 'nullable' => false, |
| 76 | + 'default' => '0.000000', |
| 77 | + ], 'Gross Transaction Amount') |
| 78 | + ->addColumn('gross_transaction_currency', Varien_Db_Ddl_Table::TYPE_TEXT, 3, [ |
| 79 | + 'default' => '', |
| 80 | + ], 'Gross Transaction Currency') |
| 81 | + ->addColumn('fee_debit_or_credit', Varien_Db_Ddl_Table::TYPE_TEXT, 2, [ |
| 82 | + ], 'Fee Debit Or Credit') |
| 83 | + ->addColumn('fee_amount', Varien_Db_Ddl_Table::TYPE_DECIMAL, '20,6', [ |
| 84 | + 'nullable' => false, |
| 85 | + 'default' => '0.000000', |
| 86 | + ], 'Fee Amount') |
| 87 | + ->addColumn('fee_currency', Varien_Db_Ddl_Table::TYPE_TEXT, 3, [ |
| 88 | + ], 'Fee Currency') |
| 89 | + ->addColumn('custom_field', Varien_Db_Ddl_Table::TYPE_TEXT, 255, [ |
| 90 | + ], 'Custom Field') |
| 91 | + ->addColumn('consumer_id', Varien_Db_Ddl_Table::TYPE_TEXT, 127, [ |
| 92 | + ], 'Consumer Id') |
| 93 | + ->addIndex( |
| 94 | + $installer->getIdxName('paypal/settlement_report_row', ['report_id']), |
| 95 | + ['report_id'], |
| 96 | + ) |
| 97 | + ->addForeignKey( |
| 98 | + $installer->getFkName('paypal/settlement_report_row', 'report_id', 'paypal/settlement_report', 'report_id'), |
| 99 | + 'report_id', |
| 100 | + $installer->getTable('paypal/settlement_report'), |
| 101 | + 'report_id', |
| 102 | + Varien_Db_Ddl_Table::ACTION_CASCADE, |
| 103 | + Varien_Db_Ddl_Table::ACTION_CASCADE, |
| 104 | + ) |
| 105 | + ->setComment('Paypal Settlement Report Row Table'); |
| 106 | +$installer->getConnection()->createTable($table); |
| 107 | + |
| 108 | +/** |
| 109 | + * Create table 'paypal/cert' |
| 110 | + */ |
| 111 | +$table = $installer->getConnection() |
| 112 | + ->newTable($installer->getTable('paypal/cert')) |
| 113 | + ->addColumn('cert_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, [ |
| 114 | + 'identity' => true, |
| 115 | + 'unsigned' => true, |
| 116 | + 'nullable' => false, |
| 117 | + 'primary' => true, |
| 118 | + ], 'Cert Id') |
| 119 | + ->addColumn('website_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, [ |
| 120 | + 'unsigned' => true, |
| 121 | + 'nullable' => false, |
| 122 | + 'default' => '0', |
| 123 | + ], 'Website Id') |
| 124 | + ->addColumn('content', Varien_Db_Ddl_Table::TYPE_TEXT, '64K', [ |
| 125 | + ], 'Content') |
| 126 | + ->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, [ |
| 127 | + ], 'Updated At') |
| 128 | + ->addIndex( |
| 129 | + $installer->getIdxName('paypal/cert', ['website_id']), |
| 130 | + ['website_id'], |
| 131 | + ) |
| 132 | + ->addForeignKey( |
| 133 | + $installer->getFkName('paypal/cert', 'website_id', 'core/website', 'website_id'), |
| 134 | + 'website_id', |
| 135 | + $installer->getTable('core/website'), |
| 136 | + 'website_id', |
| 137 | + Varien_Db_Ddl_Table::ACTION_CASCADE, |
| 138 | + Varien_Db_Ddl_Table::ACTION_CASCADE, |
| 139 | + ) |
| 140 | + ->setComment('Paypal Certificate Table'); |
| 141 | +$installer->getConnection()->createTable($table); |
| 142 | + |
| 143 | +/** |
| 144 | + * Add paypal attributes to the: |
| 145 | + * - sales/flat_quote_payment_item table |
| 146 | + * - sales/flat_order table |
| 147 | + */ |
| 148 | +$installer->addAttribute('quote_payment', 'paypal_payer_id', []); |
| 149 | +$installer->addAttribute('quote_payment', 'paypal_payer_status', []); |
| 150 | +$installer->addAttribute('quote_payment', 'paypal_correlation_id', []); |
| 151 | +$installer->addAttribute('order', 'paypal_ipn_customer_notified', ['type' => 'int', 'visible' => false, 'default' => 0]); |
| 152 | + |
| 153 | +/** |
| 154 | + * Prepare database after install |
| 155 | + */ |
| 156 | +$installer->endSetup(); |
0 commit comments