Adding sql script to create database table

filename: mysql4-install-1.1.1.php

<?php
 
$installer = $this;
$installer->startSetup();
 
$tableName = $installer->getTable('your_table_name');
 
// Check if the table already exists
if ($installer->getConnection()->isTableExists($tableName) != true) {
 
    $table = $installer->getConnection()
        ->newTable($installer->getTable($tableName))
        ->addColumn('column_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
            'identity'  => true,
            'unsigned'  => true,
            'nullable'  => false,
            'primary'   => true,
        ), 'Email Stats Id')
        ->addColumn('customer_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
            'identity'  => false,
            'unsigned'  => true,
            'nullable'  => false,
        ), 'Customer Id')
        ->addColumn('timestamp', Varien_Db_Ddl_Table::TYPE_DATETIME, null,
            array(
                'nullable' => false
        ), 'Timestamp')
    ;
    $installer->getConnection()->createTable($table);
}
 
$installer->endSetup();

Leave a Reply