admin) { die("Access denied. Admin rights required."); } // Set page title $title = "DeclarationTVA - Database Migration"; $mainmenu = "home"; $leftmenu = "home"; // Include Dolibarr header llxHeader($title, $mainmenu, $leftmenu); print '
'; print '
'; print '
DeclarationTVA Database Migration
'; // Check if migration has already been applied $sql_check = "SHOW COLUMNS FROM " . MAIN_DB_PREFIX . "declarationtva_ca3_lines LIKE 'line_label'"; $result_check = $db->query($sql_check); if ($result_check) { $obj_check = $db->fetch_object($result_check); if ($obj_check && strpos($obj_check->Type, 'text') !== false) { print '
'; print 'Migration already applied!
'; print 'The line_label field is already TEXT type. No migration needed.'; print '
'; } else { // Apply the migration print '
'; print 'Applying migration...
'; $sql_migration = "ALTER TABLE `" . MAIN_DB_PREFIX . "declarationtva_ca3_lines` MODIFY COLUMN `line_label` TEXT DEFAULT NULL COMMENT 'Combined account labels for this CA-3 line (can be long with many accounts)'"; $result_migration = $db->query($sql_migration); if ($result_migration) { print '
'; print 'Migration successful!
'; print 'The line_label field has been changed from varchar(255) to TEXT.
'; print 'You can now recalculate your declarations to see the full account labels.'; print '
'; } else { print '
'; print 'Migration failed!
'; print 'Error: ' . $db->lasterror(); print '
'; } } } else { print '
'; print 'Error checking current field type!
'; print 'Error: ' . $db->lasterror(); print '
'; } print '
'; print '
'; // Include Dolibarr footer llxFooter(); ?>