|
1 | 1 | <?php |
2 | 2 | /** |
3 | 3 | * This file is part of FacturaScripts |
4 | | - * Copyright (C) 2013-2024 Carlos Garcia Gomez <carlos@facturascripts.com> |
| 4 | + * Copyright (C) 2013-2025 Carlos Garcia Gomez <carlos@facturascripts.com> |
5 | 5 | * |
6 | 6 | * This program is free software: you can redistribute it and/or modify |
7 | 7 | * it under the terms of the GNU Lesser General Public License as |
|
25 | 25 | use FacturaScripts\Core\DbQuery; |
26 | 26 | use FacturaScripts\Core\DbUpdater; |
27 | 27 | use FacturaScripts\Core\Lib\Import\CSVImport; |
| 28 | +use FacturaScripts\Core\Tools; |
28 | 29 |
|
29 | 30 | /** |
30 | 31 | * The class from which all models inherit, connects to the database, |
@@ -140,12 +141,12 @@ public function __construct(array $data = []) |
140 | 141 | throw new Exception('The table name is not defined in the model ' . $this->modelClassName()); |
141 | 142 | } |
142 | 143 |
|
143 | | - if (false === DbUpdater::isTableChecked(static::tableName())) { |
144 | | - if (self::$dataBase->tableExists(static::tableName())) { |
145 | | - DbUpdater::updateTable(static::tableName()); |
146 | | - } else { |
147 | | - DbUpdater::createTable(static::tableName(), [], $this->install()); |
148 | | - } |
| 144 | + if (DbUpdater::isTableChecked(static::tableName())) { |
| 145 | + // none |
| 146 | + } elseif (self::$dataBase->tableExists(static::tableName())) { |
| 147 | + DbUpdater::updateTable(static::tableName()); |
| 148 | + } elseif (false === DbUpdater::createTable(static::tableName(), [], $this->install())) { |
| 149 | + Tools::log()->critical('Failed to create table ' . static::tableName()); |
149 | 150 | } |
150 | 151 |
|
151 | 152 | $this->loadModelFields(self::$dataBase, static::tableName()); |
|
0 commit comments