install-0.0.1.php 7.89 KB
<?php
/**
 * @package  anc_text 
 * @category magento
 * @mailto	code [at] netz.coop
 * @author	netz.coop eG* 
 * @copyright (c) 2014, netz.coop eG
 * 
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */ 
/**
 * @var Mage_Sales_Model_Mysql4_Setup $installer
 */
$installer = $this;
$installer->startSetup();

// Erstellen der anc_pricespercustomer Tabelle
$tableName = $installer->getTable('anc_text/nctext');
if ($installer->getConnection()->isTableExists($tableName) != true ){
    $table = $installer->getConnection()->newTable($tableName)
		->addColumn('entity_id',			Varien_Db_Ddl_Table::TYPE_INTEGER,null,array('identity' => true,'unsigned' => true,'nullable' => false,'primary' => true,),'Id')
			
		->addColumn('customer_id',	Varien_Db_Ddl_Table::TYPE_INTEGER,null,array('unsigned' => true,'nullable' => false,'default' => '0',),'Who Created frontend')			
		->addColumn('admin_user_id',Varien_Db_Ddl_Table::TYPE_INTEGER,null,array('unsigned' => true,'nullable' => false,'default' => '0',),'Who Created backend')			
		->addColumn('created_at',	Varien_Db_Ddl_Table::TYPE_TIMESTAMP,null,array(),'When beginn')
		->addColumn('updated_at',	Varien_Db_Ddl_Table::TYPE_TIMESTAMP,null,array(),'When updated')
		->addColumn('deleted_at',	Varien_Db_Ddl_Table::TYPE_TIMESTAMP,null, array(), 'When deleted')
		->addColumn('deleted',		Varien_Db_Ddl_Table::TYPE_TINYINT,null,array('default' => '0'),'Deleted')			

//		->addColumn('path',			Varien_Db_Ddl_Table::TYPE_VARCHAR,null,array(),'file path')			
//		->addColumn('file',			Varien_Db_Ddl_Table::TYPE_VARCHAR,null,array(),'file')			
		->addColumn('name',			Varien_Db_Ddl_Table::TYPE_VARCHAR,null,array(),'Name')
		->addColumn('comment',		Varien_Db_Ddl_Table::TYPE_VARCHAR,null,array(),'comment')
		->addColumn('content',			Varien_Db_Ddl_Table::TYPE_VARCHAR,null,array(),'content text')	
		
		->addColumn('ncalbum_id',	Varien_Db_Ddl_Table::TYPE_INTEGER,	null, array('unsigned' => true,'nullable' => false,'default' => '0',),'gehört zum album')
		->addColumn('original_id',	Varien_Db_Ddl_Table::TYPE_INTEGER,	null, array('unsigned' => true,'nullable' => false,'default' => '0',),'wenn album dupliziert wird, würde hier die original album id angezeigt werden')
		->addColumn('ncright_id',	Varien_Db_Ddl_Table::TYPE_INTEGER,	null, array('unsigned' => true,'nullable' => false,'default' => '0',),'Who Created frontend')
		->addColumn('ordered',Varien_Db_Ddl_Table::TYPE_BOOLEAN,null,array(),'standard')
		->addColumn('visibleingallery',Varien_Db_Ddl_Table::TYPE_BOOLEAN,null,array(),'Sichtbar in Gallerie')
		->addColumn('used_byitem_id',Varien_Db_Ddl_Table::TYPE_INTEGER,null,array('unsigned' => true,'nullable' => false,'default' => '0',),'Welches Produkt')		
		->addIndex($installer->getIdxName('anc_text/nctext', array('customer_id')),	array('customer_id'))
		->addIndex($installer->getIdxName('anc_text/nctext', array('admin_user_id')),	array('admin_user_id'))
		->addIndex($installer->getIdxName('anc_text/nctext', array('original_id')),	array('original_id'))
		->addIndex($installer->getIdxName('anc_text/nctext', array('ncalbum_id')),	array('ncalbum_id'))
		
			
			
			
			
			
		// http://docs.magentocommerce.com/Varien/Varien_Db/Varien_Db_Ddl_Table.html#addForeignKey
//		->addForeignKey( 
//			$installer->getFkName( 'anc_text/nctext','customer_id','customer/entity','entity_id'),	'customer_id', 
//			$installer->getTable('customer/entity'),	'entity_id', 
//			Varien_Db_Ddl_Table::ACTION_CASCADE,			Varien_Db_Ddl_Table::ACTION_CASCADE
//		)
//		->addForeignKey( 
//			$installer->getFkName( 'anc_text/nctext','admin_user_id','admin/user','user_id'),			'admin_user_id', 
//			$installer->getTable('admin/user'),			'user_id', 
//			Varien_Db_Ddl_Table::ACTION_NO_ACTION,			Varien_Db_Ddl_Table::ACTION_NO_ACTION
//		)			
//		->addForeignKey( 
//			$installer->getFkName( 'anc_text/nctext','original_id','anc_text/nctext','entity_id'),	'original_id', 
//			$installer->getTable('anc_text/nctext'),	'entity_id', 
//			Varien_Db_Ddl_Table::ACTION_NO_ACTION,			Varien_Db_Ddl_Table::ACTION_NO_ACTION
//		)					
//		->addForeignKey( 
//			$installer->getFkName( 'anc_text/nctext','ncalbum_id','anc_album/ncalbum','entity_id'),	'ncalbum_id', 
//			$installer->getTable('anc_album/ncalbum'),	'entity_id', 
//			Varien_Db_Ddl_Table::ACTION_CASCADE,			Varien_Db_Ddl_Table::ACTION_CASCADE
//		)					
    ;
    $installer->getConnection()->createTable($table);
}

/**
 * für die anzeige ob kunde schon mal bild benutzt hat, und wenn ja wan 
 * redudant weil info ansich vorhanden, aber zu performant um ran zukommen
 */
$tableName = $installer->getTable('anc_text/nctext_quoteitemoption');
if ($installer->getConnection()->isTableExists($tableName) != true ){
    $table = $installer->getConnection()->newTable($tableName)
		->addColumn('entity_id',	Varien_Db_Ddl_Table::TYPE_INTEGER,null,array('identity' => true,'unsigned' => true,'nullable' => false,'primary' => true,),'Id')
		->addColumn('customer_id',	Varien_Db_Ddl_Table::TYPE_INTEGER,null,array('unsigned' => true,'nullable' => false,'default' => '0',),'Who Created frontend')			
		->addColumn('nctext_id',	Varien_Db_Ddl_Table::TYPE_INTEGER,null,array('unsigned' => true,'nullable' => false,'default' => '0',),'Who Created backend')			
		->addColumn('order_id',		Varien_Db_Ddl_Table::TYPE_INTEGER,null,array('unsigned' => true,'nullable' => false,'default' => '0',),'Who Created backend')			
		->addColumn('quote_item_id',Varien_Db_Ddl_Table::TYPE_INTEGER,null,array('unsigned' => true,'nullable' => false,'default' => '0',),'Who Created backend')			
		->addColumn('ordertime',	Varien_Db_Ddl_Table::TYPE_TIMESTAMP,null,array(),'Bestellzeitpunkt')
		->addColumn('product_name',	Varien_Db_Ddl_Table::TYPE_VARCHAR,null,array(),'Produktname')			
			
		->addIndex($installer->getIdxName('anc_text/nctext_quoteitemoption', array('customer_id')),array('customer_id'))
		->addIndex($installer->getIdxName('anc_text/nctext_quoteitemoption', array('nctext_id')),array('nctext_id'))
		->addIndex($installer->getIdxName('anc_text/nctext_quoteitemoption', array('order_id')),array('order_id'))
		->addIndex($installer->getIdxName('anc_text/nctext_quoteitemoption', array('quote_item_id')),array('quote_item_id'))
			
//		->addForeignKey( 
//			$installer->getFkName( 'anc_text/nctext_quoteitemoption','customer_id','customer/entity','entity_id'),	'customer_id', 
//			$installer->getTable('customer/entity'),	'entity_id', 
//			Varien_Db_Ddl_Table::ACTION_CASCADE,			Varien_Db_Ddl_Table::ACTION_CASCADE
//		)		
//		->addForeignKey( 
//			$installer->getFkName( 'anc_text/nctext_quoteitemoption','nctext_id','anc_text/nctext','entity_id'),	'nctext_id', 
//			$installer->getTable('anc_text/nctext'),	'entity_id', 
//			Varien_Db_Ddl_Table::ACTION_CASCADE,			Varien_Db_Ddl_Table::ACTION_CASCADE
//		)			
//		->addForeignKey( 
//			$installer->getFkName( 'anc_text/nctext_quoteitemoption','order_id','sales/order','entity_id'),	'order_id', 
//			$installer->getTable('sales/order'),	'entity_id', 
//			Varien_Db_Ddl_Table::ACTION_CASCADE,			Varien_Db_Ddl_Table::ACTION_CASCADE
//		)		
//		->addForeignKey( 
//			$installer->getFkName( 'anc_text/nctext_quoteitemoption','quote_item_id','sales/quote_item','item_id'),	'quote_item_id', 
//			$installer->getTable('sales/quote_item'),	'item_id', 
//			Varien_Db_Ddl_Table::ACTION_CASCADE,			Varien_Db_Ddl_Table::ACTION_CASCADE
//		)					
	;
    $installer->getConnection()->createTable($table);	
}

$installer->endSetup();
?>