Bonjour,
Je suis en train de créer une module custom et j'ai un soucis pour la génération des différentes tables que j'ai mise en place dans le fichier thelia.sql
Les différentes tables que j'ai voulu créés n'apparaissent pas dans ma base de données
Merci
thelia.sql
-- ---------------------------------------------------------------------
-- paiement_mode
-- ---------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `paiement_mode`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
`customer_id` INTEGER,
`reg_mode` VARCHAR(255),
`alias` VARCHAR(20),
`date_val` VARCHAR(255),
`iban` VARCHAR(255),
`bic` VARCHAR(255),
`status` VARCHAR(2),
`created_at` DATETIME,
`updated_at` DATETIME,
PRIMARY KEY (`id`)
CONSTRAINT `fk_CustomerPaiement` FOREIGN KEY (`customer_id`) REFERENCES `customer` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- subscription
-- ---------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `subscription`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
`customer_id` INTEGER,
`order_id` INTEGER,
`paiement_mode_id` INTEGER,
`num_evo` INTEGER,
`reg_mode` VARCHAR(10),
`period_prv` VARCHAR(2),
`amount` DECIMAL(2),
`prv_day` VARCHAR(2),
`rum` VARCHAR(25),
`statut` VARCHAR(2),
`date_next_prv` DATETIME,
`date_start` DATETIME,
`date_creation` DATETIME,
`created_at` DATETIME,
`updated_at` DATETIME,
PRIMARY KEY (`id`),
CONSTRAINT `fk_CustomerSubscription` FOREIGN KEY (`customer_id`) REFERENCES `customer` (`id`) ON DELETE CASCADE
CONSTRAINT `fk_OrderSubscription` FOREIGN KEY (`order_id`) REFERENCES `order` (`id`) ON DELETE CASCADE
CONSTRAINT `fk_PaiementSubscription` FOREIGN KEY (`paiement_mode_id`) REFERENCES `paiement_mode` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- subscription_financial
-- ---------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `subscription_financial`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
`subscription_id` INTEGER,
`bank_transfert_id` INTEGER,
`amount` DECIMAL(2),
`prv_date` DATETIME,
`status` VARCHAR(2),
`created_at` DATETIME,
`updated_at` DATETIME,
PRIMARY KEY (`id`)
CONSTRAINT fk_SubcriptionSubcriptionF FOREIGN KEY (`subscription_id`) REFERENCES `subscription` (`id`) ON DELETE CASCADE
CONSTRAINT fk_BankTransfertSubcriptionF FOREIGN KEY (`bank_transfert_id`) REFERENCES `bank_transfer` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- subscription_suspension
-- ---------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `subscription_suspension`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
`subscription_id` INTEGER,
`date_crea` DATETIME,
`date_first` DATETIME,
`date_last` DATETIME,
`status` VARCHAR(2),
`created_at` DATETIME,
`updated_at` DATETIME,
PRIMARY KEY (`id`)
CONSTRAINT fk_SubcriptionSubcriptionS FOREIGN KEY (`subscription_id`) REFERENCES `subscription` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- bank_transfer
-- ---------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `bank_transfer`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
`code_lot` VARCHAR(10),
`reg_mode` VARCHAR(10),
`rpv_date` DATETIME,
`quantity_calculated` INTEGER,
`amount_calculated` DECIMAL(2),
`amount_paid` DECIMAL(2),
`amount_unpaid` DECIMAL(2),
`status` VARCHAR(2),
`created_at` DATETIME,
`updated_at` DATETIME,
PRIMARY KEY (`id`)
) ENGINE=InnoDB;
# This restores the fkey checks, after having unset them earlier
SET FOREIGN_KEY_CHECKS = 1;
fichier Custom.php
namespace Custom;
use Propel\Runtime\Connection\ConnectionInterface;
use Thelia\Install\Database;
use Thelia\Module\BaseModule;
class Custom extends BaseModule
{
/** @var string */
const DOMAIN_NAME = 'custom';
/*
* You may now override BaseModuleInterface methods, such as:
* install, destroy, preActivation, postActivation, preDeactivation, postDeactivation
*
* Have fun !
*/
public function preActivation(ConnectionInterface $con = null)
{
if (! $this->getConfigValue('is_initialized', false)) {
$database = new Database($con);
$database->insertSql(null, array(__DIR__ . '/Config/thelia.sql'));
$this->setConfigValue('is_initialized', true);
}
return true;
}
public function destroy(ConnectionInterface $con = null, $deleteModuleData = false)
{
$database = new Database($con);
$database->insertSql(null, array(__DIR__ . '/Config/sql/destroy.sql'));
}
}