Hi guys,
In some times my customers wrote me that module helper tables not created in database. Because, all privileges Granted.
How do you think about this?
Thank for all.
module install code:
public function install()
{
// Prepare tab
$tab = new Tab();
$tab->active = 1;
$tab->class_name = 'AdminMigrationPro';
$tab->name = array();
foreach (Language::getLanguages(true) as $lang) {
$tab->name[$lang['id_lang']] = 'MigrationPro';
}
$tab->id_parent = -1;
$tab->module = $this->name;
include(dirname(__FILE__) . '/sql/install.php');
if (!$tab->add() ||
!parent::install() ||
!$this->registerHook('header') ||
!$this->registerHook('backOfficeHeader')
) {
return false;
}
return true;
}
install.php
$sql = array();
$sql[] = 'DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'migrationpro_data`;
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'migrationpro_data` (
`id_data` int(11) NOT NULL AUTO_INCREMENT,
`type` varchar(3) NOT NULL,
`source_id` int(11) NOT NULL,
`local_id` int(11) NOT NULL,
PRIMARY KEY (`id_data`),
UNIQUE KEY `type_source_id` (`type`,`source_id`),
KEY `type` (`type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;';
$sql[] = 'DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'migrationpro_mapping`;
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'migrationpro_mapping` (
`id_mapping` int(255) NOT NULL AUTO_INCREMENT,
`type` varchar(255) NOT NULL,
`source_id` int(11) NOT NULL,
`source_name` varchar(255) NOT NULL,
`local_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id_mapping`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;';
$sql[] = 'DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'migrationpro_process`;
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'migrationpro_process` (
`id_process` int(11) NOT NULL AUTO_INCREMENT,
`type` varchar(100) NOT NULL,
`total` int(11) NOT NULL,
`imported` int(11) NOT NULL,
`id_source` int(11) NOT NULL,
`error` int(11) NOT NULL,
`point` int(11) NOT NULL,
`time_start` timestamp NOT NULL,
`finish` tinyint(1) NOT NULL,
PRIMARY KEY (`id_process`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;';
foreach ($sql as $query) {
if (Db::getInstance()->execute($query) == false) {
return false;
}
}