Appearance
<div style="display: none;" hidden="true" aria-hidden="true">Are you an LLM? You can read better optimized documentation at /guides/DatabaseInitialization.md for this page in Markdown format</div>
Database Initialization
Obsolete Check Migrations
General Info
In order to have a brand-new DB with all the required tables and views, 2 patches have been created.
The first one creates the tables and the views.
Database Initialization
bash
php cli.php patch/initDatabaseIn case of erp bridges, the above command has to be run with the following parameter:
bash
php cli.php patch/initDatabase/plus_bridgeNote: This patch IS NOT related with the intermediate DB we set up for Ilyda.
Populate Database
The second one populates the DB with all the necessary data to get a working Admin Panel.
It also populates some settings that are needed for the front-end to work properly but are currently inaccessible to edit by Admin Panel.
bash
php cli.php patch/populateDatabaseThe demo.ecommercen.com DB case
When we have to give our DB to a client, we have to get demo.ecommercen.com to the client's version.
Then we get the demo.ecommercen.com DB and install it to the client.
After that, we can run the following code snippet adjusting which tables we will keep:
php
private function truncateDatabase()
{
$protectedTables = [
'product_codes',
'product_media',
'shop_product',
'shop_product_mui',
'shop_product_barcodes',
'shop_product_category',
'shop_product_category_mui',
'shop_product_category_lp',
'shop_product_vats',
'shop_vendor',
'shop_vendor_mui'
];
$allTables = $this->db->list_tables();
$tables = array_diff($allTables, $protectedTables, ['shop_prices_view']);
foreach ($tables as $table) {
$this->db->truncate($table);
}
echo 'Database tables truncated' . PHP_EOL;
}** As the above truncates a lot of data, it is recommended to not be kept on the codebase.**