2
0
forked from Wavyzz/dolibarr

Fix trouble in migrationon. Fix pb with large database

This commit is contained in:
ldestailleur
2025-04-05 13:37:21 +02:00
parent c7ec63b702
commit d97ebb9a33
4 changed files with 15 additions and 9 deletions

View File

@@ -196,9 +196,13 @@ ALTER TABLE llx_product_customer_price ADD CONSTRAINT fk_product_customer_price_
ALTER TABLE llx_product_customer_price ADD CONSTRAINT fk_product_customer_price_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe(rowid);
UPDATE llx_product_customer_price SET date_begin = datec WHERE date_begin IS NULL;
UPDATE llx_product_customer_price_log SET date_begin = datec WHERE date_begin IS NULL;
ALTER TABLE llx_accounting_bookkeeping ADD COLUMN ref VARCHAR(30) AFTER rowid;
ALTER TABLE llx_accounting_bookkeeping_tmp ADD COLUMN ref VARCHAR(30) AFTER rowid;
ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_ref (ref);
ALTER TABLE llx_accounting_bookkeeping_tmp ADD INDEX idx_accounting_bookkeeping_tmp_ref (ref);
ALTER TABLE llx_session ADD COLUMN date_creation datetime AFTER session_variable;
UPDATE llx_session SET date_creation = NOW() WHERE date_creation IS NULL;
-- VMYSQL4.3 ALTER TABLE llx_session MODIFY COLUMN date_creation datetime NOT NULL;

View File

@@ -16,6 +16,7 @@
--
-- ============================================================================
ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_ref (ref);
ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_fk_doc (fk_doc);
ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_fk_docdet (fk_docdet);
ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_doc_date (doc_date);
@@ -23,5 +24,5 @@ ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_nume
ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_code_journal (code_journal, entity);
ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_piece_num (piece_num, entity);
-- Current unicity is tested by the journalize page on couple (fk_doc, doc_type)
-- Current unicity is tested by the journalize page on couple (fk_doc, doc_type)
-- TODO Add a key for unicity (not so easy as fk_doc, doc_type may have several lines for one piece)

View File

@@ -16,6 +16,7 @@
--
-- ============================================================================
ALTER TABLE llx_accounting_bookkeeping_tmp ADD INDEX idx_accounting_bookkeeping_tmp_ref (ref);
ALTER TABLE llx_accounting_bookkeeping_tmp ADD INDEX idx_accounting_bookkeeping_tmp_doc_date (doc_date);
ALTER TABLE llx_accounting_bookkeeping_tmp ADD INDEX idx_accounting_bookkeeping_tmp_fk_docdet (fk_docdet);
ALTER TABLE llx_accounting_bookkeeping_tmp ADD INDEX idx_accounting_bookkeeping_tmp_numero_compte (numero_compte);

View File

@@ -5239,8 +5239,9 @@ function migrate_accountingbookkeeping(int $entity)
if ($bookKeepingAddon === 'mod_bookkeeping_argon') {
$db->begin();
$sql = "SELECT DISTINCT YEAR(doc_date) as doc_year, MONTH(doc_date) as doc_month, code_journal, piece_num FROM {$db->prefix()}accounting_bookkeeping";
$sql .= " WHERE ref IS NULL AND entity = {$entity}";
$sql .= " WHERE ref IS NULL AND entity = ".((int) $entity);
$sql .= " ORDER BY doc_year, doc_month, code_journal, piece_num";
$resql = $db->query($sql);
@@ -5253,7 +5254,7 @@ function migrate_accountingbookkeeping(int $entity)
$bookkeeping->code_journal = $obj->code_journal;
$ref = $bookkeeping->getNextNumRef();
$sqlUpd = "UPDATE {$db->prefix()}accounting_bookkeeping SET ref='{$ref}' WHERE piece_num = '{$obj->piece_num}' AND entity = {$entity}";
$sqlUpd = "UPDATE ".$db->prefix()."accounting_bookkeeping SET ref = '".$db->escape($ref)."' WHERE piece_num = '".$db->escape($obj->piece_num)."' AND entity = ".((int) $entity);
$resultstring = '.';
print $resultstring;
$resqlUpd = $db->query($sqlUpd);
@@ -5265,13 +5266,12 @@ function migrate_accountingbookkeeping(int $entity)
} else {
$error++;
}
}
if (!$error) {
$db->commit();
} else {
$db->rollback();
if (!$error) {
$db->commit();
} else {
$db->rollback();
}
}
print '</td></tr>';