SQL Versionning

Versioning SQL allows you to preserve the same structure in production and pre-production. This also allows you to modify the structure of your database so that logged and no access to SQL or phpMyAdmin

In etc/sql_versionning.php you can add the creations of tables, fields, creation of indexes, modification of the fields like this:

 $sql_versionning[TABLE][FIELDS] = SQL REQUEST; 

For example, if we want to add a field id_country in the customer table

 $sql_versionning['clients']['id_country'] = "ALTER TABLE `gen_clients` ADD `id_country` MEDIUMINT NULL DEFAULT NULL ;"

This works in the case of an existing table. In the case of a table not existing, we have to pass the variable "create" :

$sql_versionning['create'][] = "CREATE TABLE IF NOT EXISTS `gen_appsms` ( 
`id_sms` int(10) unsigned NOT NULL AUTO_INCREMENT, 
`num` varchar(20) NOT NULL, 
`content` varchar(255) NOT NULL, 
`smells` tinyint(1) DEFAULT NULL, 
`sent_at` datetime DEFAULT NULL, 
`created_at` datetime NOT NULL, 
PRIMARY KEY (`id_sms`)