Magento 1.4.1.1 -> 1.7 upgrade: foreign key constraint fails - upgrade

it seems updating magento is really hard :)
I have magento 1.4.1.1 and i want to update it to the newest magento 1.4.2.
I follow this guide:
How to upgrade magento 1.4 1.1 to 1.7.0.2
What i of course do:
- Disable and clear cache
- Clear sessions
- Disable all extensions before update
- Backup backup backup :D
When i update from 1.4.1.1 to 1.4.2 i trigger the mainpage to make the mysql changes. This is where to problems start.
I get this error:
a:5:{i:0;s:435:"Error in file: "/var/www/vhosts/dev/docs/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-1.4.0.20-1.4.0.21.php" - SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`dev`.<result 2 when explaining filename '#sql-20eb_3d66'>, CONSTRAINT `FK_PRODUCT_ORDERED_AGGREGATED_MONTHLY_PRODUCT_ID` FOREIGN KEY (`product_id`) REFERENCES `catalog_product_entity` (`entit)";i:1;s:974:"#0 /var/www/vhosts/dev/docs/app/code/core/Mage/Core/Model/Resource/Setup.php(390): Mage::exception('Mage_Core', 'Error in file: ...')
I have also tried to upgrade to 1.7 directly which leeds to numerous other similar errors. I of course could comment out all those pieces which cause problems but i dont think that would be wise :)
Do you have any idea what i can do avoid / fix these errors?
Thank you very much :)
Greets

Yes, upgrading Magento is almost never smooth.
To diagnose this particular problem you have to compare types sales_bestsellers_aggregated_monthly.product_id and catalog_product_entity.entity_id fields.
You can find more details on what is causing this problem and also a solution in my article dedicated to this subject.
In English: How 3rd Party Extensions Can Ruin Your Magento Upgrade
Auf Deutsch: Wie Externe Extensions Dein Magento-Upgrade Ruinieren Können

If you had made a backup of your database and it is possible to restart the process, I would advise you to go another way, but here you will have to move to 1.5 than to 1.6 than to 1.7:
First, you have to get SSH access from your hosting provider and connect to your server via SSH protocol.
Then,
1 – Change permissions on lib/pear folder to writable (recursively):
chmod -R 777 lib/PEAR
2 – Execute this command to prepare Magento for upgrade:
./pear mage-setup
Most likely you will see this result after command execution:
Channel “connect.magentocommerce.com/core” is already initialized
Upgrade from Magento 1.4.1.x to Magento 1.4.2.0
This step is necessary even if you upgrade your Magento store to 1.5 or 1.6 versions.
3 – Execute Magento upgrade command:
./pear upgrade -f magento-core/Mage_All_Latest-stable
Output of the command will show you what core packages were upgraded:
upgrade ok: channel://connect.magentocommerce.com/core/Interface_Adminhtml_Default-1.4.2.0
4 – When this part of the upgrade will be complete, enter these commands:
chmod 550 ./mage
./mage mage-setup .
You will see this result after command execution:
Successfully added: connect20.magentocommerce.com/community
It means that Magento connect 2.0 channel was added to the channels list successfully.
5 – Next, enter this command:
./mage sync
Here you should see::
…
Successfully added: community/Mage_Locale_en_US-1.4.2.0
Successfully added: community/Interface_Install_Default-1.4.2.0
Successfully added: community/Phoenix_Moneybookers-1.2.3
Successfully added: community/Mage_Downloader-1.5.0.0
Successfully added: community/Lib_Google_Checkout-1.4.2.0
Upgrade to Magento 1.4.2.0 is complete and now you can proceed with upgrade to Magento 1.5.1.0 or 1.6.0.0.
Before proceeding with this part of Magento upgrade, it is very important to see to what version Magento upgrade scripts will upgrade your store. Enter this command to check this:
./mage list-upgrades
If you will see this result:
Updates for community:
Mage_All_Latest: 1.4.2.1 => 1.6.0.0
Lib_Js_Mage: 1.4.2.0 => 1.6.0.0
Lib_Varien: 1.4.2.0 => 1.6.0.0
Lib_Phpseclib: 1.4.2.0 => 1.5.0.0
It means that your Magento will be upgraded to version 1.6.0.0. If it is not what you need you can change upgrade channel to “stable” and upgrade your Magento to version 1.5.1.0.
6 – Enter this command to change the upgrade channel to stable:
./mage config-set preferred_state stable
After this the “./mage list-upgrades” command will show you this result:
Updates for community:
Mage_All_Latest: 1.4.2.1 => 1.5.1.0.1
Lib_Js_Mage: 1.4.2.0 => 1.5.1.0
Lib_Varien: 1.4.2.0 => 1.5.1.0
Lib_Phpseclib: 1.4.2.0 => 1.5.0.0
Mage_Core_Adminhtml: 1.4.2.0 => 1.5.1.0
Mage_Core_Modules: 1.4.2.0 => 1.5.1.0
7 – After channel selection you can upgrade your Magento to 1.5.1.0 (or to Magento 1.6.0.0) using this command:
./mage upgrade-all –force
You will see upgraded packages on your screen:
…
Package upgraded: community/Mage_Locale_en_US 1.6.0.0
Package upgraded: community/Lib_Mage 1.6.0.0
Package upgraded: community/Lib_ZF 1.11.1.0
Package upgraded: community/Lib_Js_Prototype 1.7.0.0.1
Package upgraded: community/Lib_ZF_Locale 1.11.1.0
Now the upgrade is complete. If everything was upgraded correctly, you will see upgraded store in your browser.
In the admin panel, you can check the version of your store.
If you had made a brand new installation of Magento version, and you won’t do manual data transfer, since it would take days or even weeks. What you can do to move your database directly from 1.4 to the new Magento 1.7 you can use automated service.

I have similiar problem:
app\code\core\Mage\Sales\sql\sales_setup\mysql4-upgrade-1.4.0.20-1.4.0.21.php" - SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails ..
but i my case, error appeared with this key:
FK_PRODUCT_ORDERED_AGGREGATED_DAILY_PRODUCT_ID
The solution was quite easy, I just delete entries from tables:
sales_bestsellers_aggregated_daily
sales_bestsellers_aggregated_monthly
sales_bestsellers_aggregated_yearly
where product_id wasn't correspond with entity_id at catalog_product_entity table.
This query helps you detect useless product_ids:
SELECT product_id FROM sales_bestsellers_aggregated_yearly where product_id not in
(select entity_id from catalog_product_entity)

Related

MassTransit JobConsumer: (0x80131904): Incorrect syntax near the keyword 'UPDATE'

I try to start MassTransit/Sample-JobConsumer on EntityFramework Core, but having strange error
(0x80131904): Incorrect syntax near the keyword 'UPDATE'
Steps to reproduce:
Clone MassTransit/Sample-JobConsumer
Remove PostgreSQL an install EntityFrameworkCore
Command Update-Database creates a correct database
Start project JobService.Service
Post request from Postman (response is valid):
RabbitMQ accept requests:
But error occured during processing (in console):
Please, anyone help me to understand what is happened.
You can see repository on github with EntityFrameworkCore storage implemented
P.S. With default configuration the error was different
[Update 1]
After I changed PostgresLockStatementProvider to SqlServerLockStatementProvider (Thanks to Chris Patterson for help). But I`ve got another error:
[Update 2]
After I was installed plugin for RabbitMQ everything became works fine with EntityFrameworkCore too! (Thanks to Chris Patterson)
To change to SQL Server, you'd need to change the EF Core configuration to UseSqlServer, you also need to remove the PostgreSQL lock provider (the default lock provider is SqlServer). There are three lines where this change is needed, one for each state machine.

Upgrading postgres 9.5 to 11

So ive been tasked of upgrading our postgres server to version 11, however all the guide ive found either dont work for me or are not complete.
I have tried 2 methods and had to recall all changes:
https://www.hutsky.cz/blog/2019/02/upgrade-postgresql-from-9-3-to-11/
In this method not only are the dependency checks and upgrade commands exactly the same but also none of these commands work for me, i keep getting the error of:
"You must identify the directory where the new cluster binaries reside.
Please use the -B command-line option or the PGBINNEW environment variable.
Failure, exiting"
And ive been unable to find any fix to this.
And also tried the delete old method :
https://techcyclist.com/postgres/upgrading-postgres-to-the-latest-version-on-centos-7-server/
but in this method he deletes the old postgres completely and also the config files, but our config files have been made by the EX sys admin and i simply dont have the time it takes to study the configs to redo them in the new version, and i cant risk simply replacing the new config file with the ole one.
If anyone has done such a assignment and is willing to help, i would much appreciate it.
I used : yum install postgresql11 postgresql11-contrib postgresql11-devel postgresql11-libs postgresql11-server
to install the new postgres 11 and :
/usr/pgsql-11/bin/initdb -D /var/lib/pgsql/11/data
to init it. with a few dependencies installing in between.
afterwards all other commands :
/usr/pgsql-11/bin/pg_upgrade --old-bindir=/usr/pgsql-9.3/bin/ --
new-bindir=/usr/pgsql-11/bin/ --old-
datadir=/var/lib/pgsql/9.3/data/ --new-
datadir=/var/lib/pgsql/11/data/ --check
gave errors as described.

Call to undefined function mysql_connect after upgrade to Moodle 3.6 [duplicate]

This question already has answers here:
Fatal error: Uncaught Error: Call to undefined function mysql_connect()
(9 answers)
Closed 3 months ago.
I have ran aptitude install php5-mysql (and restarted MySQL/Apache 2), but I am still getting this error:
Fatal error: Call to undefined function mysql_connect() in /home/validate.php on line 21
phpinfo() says the /etc/php5/apache2/conf.d/pdo_mysql.ini file has been parsed.
In case, you are using PHP7 already, the formerly deprecated functions mysql_* were removed entirely, so you should update your code using the PDO-functions or mysqli_* functions instead.
If that's not possible, as a workaround, I created a small PHP include file, that recreates the old mysql_* functions with mysqli_*()-functions: fix_mysql.inc.php
I see that you tagged this with Ubuntu. Most likely the MySQL driver (and possibly MySQL) is not installed. Assuming you have SSH or terminal access and sudo permissions, log into the server and run this:
sudo apt-get install mysql-server mysql-client php5-mysql
If the MySQL packages or the php5-mysql package are already installed, this will update them.
UPDATE
Since this answer still gets the occasional click I am going to update it to include PHP 7. PHP 7 requires a different package for MySQL so you will want to use a different argument for the apt-get command.
# Replace 7.4 with your version of PHP
sudo apt-get install mysql-server mysql-common php7.4 php7.4-mysql
And importantly, mysql_connect() has been deprecated since PHP v5.5.0. Refer the official documentation here: PHP: mysql_connect()
Well, this is your chance! It looks like PDO is ready; use that instead.
Try checking to see if the PHP MySQL extension module is being loaded:
<?php
phpinfo();
?>
If it's not there, add the following to the php.ini file:
extension=php_mysql.dll
If someone came here with the problem of docker php official images, type below command inside the docker container.
$ docker-php-ext-install mysql mysqli pdo pdo_mysql
For more information, please refer to the link above How to install more PHP extensions section(But it's a bit difficult for me...).
Or this doc may help you.
https://docs.docker.com/samples/library/php/
I was also stuck with the same problem of undefined MySQL_connect().I tried to make changes in PHP.ini file but it was giving me the same error.
Then I came to this solution where I changed my code from depreciated php functions to new functions.
$con=mysqli_connect($host,$user,$password);
mysqli_select_db($con,dbname);
//To select the database
session_start(); //To start the session
$query=mysqli_query($con,your query);
//made query after establishing connection with database.
I hope this will help you .
This solution is correctly working for me .
EDIT:
If you upgrade form old php you need to apt-get install php7.0-mysql
Try:
<?php
phpinfo();
?>
Run the page and search for mysql. If not found, run the following in the shell and restart the Apache server:
sudo apt-get install mysql-server mysql-client php5-mysql
Also make sure you have all the following lines uncommented somewhere in your apache2.conf (or in your conf.d/php.ini) file, from
;extension=php_mysql.so
to
extension=php_mysql.so
In php.ini file
change this
;extension=php_mysql.dll
into
extension=php_mysql.dll
My guess is your PHP installation wasn't compiled with MySQL support.
Check your configure command (php -i | grep mysql). You should see something like '--with-mysql=shared,/usr'.
You can check for complete instructions at http://php.net/manual/en/mysql.installation.php. Although, I would rather go with the solution proposed by #wanovak.
Still, I think you need MySQL support in order to use PDO.
The question is tagged with ubuntu, but the solution of un-commenting the extension=mysqli.dll is specific to windows. I am confused here?!, anyways, first thing run <? php phpinfo ?> and search for mysql* under Configuration heading. If you don't see such a thing implies you have not installed or enabled php-mysql. So first install php-mysql
sudo apt get install php-mysql
This command will install php-mysql depending on the php you have already installed, so no worries about the version!!.
Then comes the unix specific solution, in the php.ini file un-comment the line
extension=msql.so
verify that msql.so is present in /usr/lib/php/<timestamp_folder>,
ELSE
extension=path/to/msql.so
Then finally restart the apache and mysql services, and you should now see the mysql section under Configrations heading in phpinfo page
I was getting this error because the project I was working on was developed on php 5.6 and after install, the project was unable to run on php7.1.
Just for anyone that uses Vagrant with ubuntu/nginx, in the nginx directory(/etc/nginx/), there is a directory named "sites-available" which contains a file named like the url configured for the vagrant maschine. In my case was homestead.app. Within this file there is a line that says something like
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
There you can change the php version to the desired for that particular site.
Googled this but wasnt really able to find a simple answer that said where to look and what to change.
Hope that this helps anyone.
Thanks.
If you are getting the error as
Fatal error: Call to undefined function mysql_connect()
Kindly login to the cPanel >> Click on Select Php version >> select the extension MYSQL
For CentOS 7.8 & PHP 7.3
yum install rh-php73-php-mysqlnd
And then restart apache/php.
(Windows mysql config)
Step 1 : Go To Apache Control Panel > Apache > Config > PHP.ini
Step 2 : Search in Notepad (Ctrl+F) For: ;extension_dir = "" (could be commented with a ;). Replace this line with: extension_dir = "C:\php\ext" (please do not you need to remove the ; on the beginning of the sentence).
Step 3 : Search For: extension=php_mysql.dll and remove the ; in the beginning.
Step 4 : Save and Restart You Apache HTTP Server. (On Windows this usually done via a UI)
That's it :)
If you get errors about missing php_mysql.dll you'll probably need to download this file from either the php.net site or the pecl.php.net. (Please be causius about where you get it from)
More info on PHP: Installation of extensions on Windows - Manual
There must be some syntax error. Copy/paste this code and see if it works:
<?php
$link = mysql_connect('localhost', 'root', '');
if (!$link) {
die('Could not connect:' . mysql_error());
}
echo 'Connected successfully';
?
I had the same error message. It turns out I was using the msql_connect() function instead of mysql_connect().

Upgrading Mongodb from 3.4 to 3.6

I am trying to upgrade my single node mongodb cluster from 3.4 to 3.6.
Everything is ok but I am not able to change feature compatibility to 3.6.
When I try-
db.adminCommand( { setFeatureCompatibilityVersion:"'3.6'" } )
I get an error saying -
{
"ok" : 0,
"errmsg" : "Invalid command argument. Expected '3.4' or '3.2', found '3.6' in: { setFeatureCompatibilityVersion: \"'3.6'\" }. See http://dochub.mongodb.org/core/3.4-feature-compatibility.",
"code" : 2,
"codeName" : "BadValue"
}
you can try to follow the instructions on this site Upgrade a Standalone to 3.6
and if you use Ubunt OS, try this:
Step 1: Stop the old Mongod server
run “sudo systemctl stop mongod” and MongoDB will be stopped.
Step 2: Import the MongoDB public key
Run “sudo apt-key adv –keyserver hkp://keyserver.ubuntu.com:80 –recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5” and the key is imported for you!
Step 3: Update the list file for apt/MongoDB
To remove the old list run “sudo rm /etc/apt/sources.list.d/mongodb-org-3.4.list”
Now add the new one with “echo “deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse” | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list”
Run “sudo apt-get update” to update apt’s lists.
Step 4: Upgrade the MongoDB install
The easiest way to do this is to run “sudo apt-get upgrade -y” which will make apt update all the out of date packages in your system. Fun!
If it asks to replace the file at /etc/mongod.conf just say no to keep your settings as they are.
Step 5: Start MongoDB
Run “sudo systemctl start mongod” and we are up and running. It’s as easy as that!
It seems like what you posted has an error with double and single quotes (making the error message you posted make sense :-) ).
db.adminCommand( { setFeatureCompatibilityVersion:"'3.6'" } )
It should have been:
db.adminCommand( { setFeatureCompatibilityVersion:"3.6" } )
In addition, you may want to learn more about the "FCV" from these instructions.
For some reason my db version was not updated, may be some dependencies got messed up. I uninstalled current installation with purge option and reinstalled mongodb and it fixed the issue. Don't forget to create backup for config file if you are using purge option.
As official definition: It enables or disables the features that persist data incompatible with earlier versions(*means lower versions than your current one) of MongoDB. So for example, if I got mongo3.6 then I have to worry about the previous versions, not the current. Are you trying to set compatibility for the same version on itself? The error also suggests your system require to map the previous versions only. i.e. version lower than your current installed one.

Magento upgrade 1.3.2.1 to 1.7.0.2

So, I'm upgrading a Magento install from 1.3.2.1 to 1.7.0.2. But I get the following error when I try to convert the database to the new format.
a:5:{i:0;s:239:"Error in file: "/home/user/public_html/app/code/core/Mage/Customer/sql/customer_setup/mysql4-upgrade-1.4.0.0.7-1.4.0.0.8.php" - SQLSTATE[HY000]: General error: 1005 Can't create table 'user_new.customer_form_attribute' (errno: 150)";i:1;s:994:"#0 /home/user/public_html/app/code/core/Mage/Core/Model/Resource/Setup.php(645): Mage::exception('Mage_Core', 'Error in file: ...')
#1 /home/user/public_html/app/code/core/Mage/Core/Model/Resource/Setup.php(437): Mage_Core_Model_Resource_Setup->_modifyResourceDb('upgrade', '1.4.0.0.7', '1.6.2.0.1')
#2 /home/user/public_html/app/code/core/Mage/Core/Model/Resource/Setup.php(320): Mage_Core_Model_Resource_Setup->_upgradeResourceDb('1.4.0.0.7', '1.6.2.0.1')
#3 /home/user/public_html/app/code/core/Mage/Core/Model/Resource/Setup.php(235): Mage_Core_Model_Resource_Setup->applyUpdates()
#4 /home/user/public_html/app/code/core/Mage/Core/Model/App.php(417): Mage_Core_Model_Resource_Setup::applyAllUpdates()
#5 /home/user/public_html/app/code/core/Mage/Core/Model/App.php(343): Mage_Core_Model_App->_initModules()
#6 /home/user/public_html/app/Mage.php(683): Mage_Core_Model_App->run(Array)
#7 /home/user/public_html/index.php(87): Mage::run('', 'store')
#8 {main}";s:3:"url";s:1:"/";s:11:"script_name";s:10:"/index.php";s:4:"skin";s:7:"default";}
Anybody who have fixed this problem? Google don't give me any answers only people who have the same problem.
The tables in Magento 1.3 are MyISAM and later are converted to InnoDB. Now the 150 error message you are getting is related to FKs:
If MySQL reports an error number 1005 from a CREATE TABLE statement,
and the error message refers to error 150, table creation failed
because a foreign key constraint was not correctly formed. Similarly,
if an ALTER TABLE fails and it refers to error 150, that means a
foreign key definition would be incorrectly formed for the altered
table. To display a detailed explanation of the most recent InnoDB
foreign key error in the server, issue SHOW ENGINE INNODB STATUS.
Source
It is a long way to upgrade Magento from 1.3.2.1 to 1.7.0.2. Errors are almost always happen. You didn't mentioned the way how you plan to upgrade, it plays a vital role in this question. Definitely, it is safer to move step by step 1.3 to 1.4 to 1.5 to 1.6 to 1.7.
Have you made a backup for you data? If yes, it is better to start it all from the very beginning.
Minor problems here are inevitable, especially, if you have really old version
of Magento that you would like to upgrade.
Here is the standard procedure when getting Magento up to date. It is just for you to see, because you can select another way to update the store.
1) Know what are you facing with:
Check google if there is something special about upgrading your specific version of Magento to the newest one.
If nothing else, you will be prepared with issues that you will need to solve.
2) Backup your files
We usually do it from CLI like this:
tar -cvvzf your_site_directory.tar.gz your_site_directory/ 2>error.log
3) Backup your database
You can also do it from CLI like this:
mysqldump -u THIS_IS_YOUR_USERNAME_FOR_DB -h localhost -pTHIS_IS_YOUR_USERNAME_FOR_DB my_database_name | gzip -9 > my_database_name.sql.gz
4) Copy those files to the new location
In case you need to move files between 2 servers, easiest way I can think of in CLI would be this:
scp /path_to_some_file/your_site_directory.tar.gz user#REMOTE_SERVER_ADDRESS:/some_dir_on_remote_server
You can do the same with your backup-ed database
5) Now it is time to import database into new created one:
a) Extract my_database_name.sql.gz
b) mysql –verbose –user=THIS_IS_YOUR_USERNAME –password=THIS_IS_YOUR_PASSWORD newly_created_db < my_database_name.sql
6) Now extract the files this way:
tar -xvvzf your_site_directory.tar.gz
This will extract all files to the current directory
7) Edit db table core_config_data and set new secure/unsecure URLs of your site
8) Disable cache from admin.
9) Delete cache and session directories located here:
/var/cache
/var/session
rm /your_path_to/var/session -R
rm /your_path_to/var/cache -R
10) Execute “clean” bash script located in /downloader/pearlib directory
a) Run chmod +x clean to be able to execute this script
b) ./clean to execute script
11) Finally go to Magento connect manager from your Magento admin
Paste this extension to upgrade Magento: magento-core/Mage_All_Latest
After this is done, you should have new Magento, however if there was some custom coding, you should really know what is going on with your code.
12) All that left is to test it and move those files on production server.