Create tables magento install script

The tutorial explains how to create the custom table in magento database. The following script create the table named ‘customer_form_table’ in the magento database as shown below.

create_custom_table_magento_database

Please click here to refer the step by step explanation for the magento module which explains how to create the custom tables in magento database.

<?php

$installer = $this;

$installer->startSetup();

$installer->run("

DROP TABLE IF EXISTS `{$this->getTable('customer_form_table')}`;
CREATE TABLE `{$this->getTable('customer_form_table')}` (
  `log_id` int(11) unsigned NOT NULL auto_increment,
  `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  `admin_id` int(11) unsigned NOT NULL default '0',
  `customer_id` int(11) unsigned NOT NULL default '0',
  `terms_old` int(11) unsigned NOT NULL default '0',
  `terms_new` int(11) unsigned NOT NULL default '0',
  `limit_old` DECIMAL(10,5) NOT NULL default '0',
  `limit_new` DECIMAL(10,5) NOT NULL default '0',
  `available_old` DECIMAL(10,5) unsigned NOT NULL default '0',
  `available_new` DECIMAL(10,5) unsigned NOT NULL default '0',
  PRIMARY KEY (`log_id`),
  INDEX (customer_id),
  INDEX (admin_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

");

$installer->endSetup();

Share this Tutorial