Error Code(0): Error: Duplicate column name 'username'
Error No: 1060
ALTER TABLE `oc_api` CHANGE `name` `username` VARCHAR(64) NOT NULL in /home/rnpgkvks/public_html/system/library/db/mysqli.php on line 40
Don´t know what to do or what database it refers to
The Error said itself, you have a duplicate column name 'username' in your db.Kalena wrote: ↑Fri Aug 14, 2020 11:44 pmUpgrading to oc-3.0.3.6 and get this message:
Error Code(0): Error: Duplicate column name 'username'
Error No: 1060
ALTER TABLE `oc_api` CHANGE `name` `username` VARCHAR(64) NOT NULL in /home/rnpgkvks/public_html/system/library/db/mysqli.php on line 40
Don´t know what to do or what database it refers to
double confirm with your database that why you have it twice, which extension is creating it.
try to disable all the install extension one by one and see if it is been resolved.
it is always advisable to backup your db first and the website before making any changes.
Got a burning question at 3 AM that even Google shrugs at? There’s a not-so-secret inbox that might just have your answer: khnaz35@gmail.com
Breathe in some nature while you're at it. It’s cheaper than therapy.
Feel free to sling a bear my way via PayPal @ khnaz35@gmail.com
I disabled all extensions and Journal theme and I am getting
Code: Select all
Error Code(0): Error: Duplicate column name 'username'
Error No: 1060
ALTER TABLE `oc_api` CHANGE `name` `username` VARCHAR(64) NOT NULL in /home/XXXXX/public_html/v3/system/library/db/mysqli.php on line 40
thank you in advance for your help.
You have the answer already...
Upgrading process is not made 100% correctly.weborder wrote: ↑Fri Sep 25, 2020 11:51 amCode: Select all
Duplicate column name 'username' in oc_api`
For 2.x
Beefore upgrade, delete from database oc_api table.
To fix you can delete oc_api table and recreate from opencart sql database or you can delete one of username field from oc_api.
Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer
Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces
“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.
Example:
When you try to upgrade from 2.3.0.2 to 3.0.3.6.. username is added in database because is in opencart.sql table.
Then SQL command not work because is already an username.
Code: Select all
$query = $this->db->query("SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = '" . DB_DATABASE . "' AND TABLE_NAME = '" . DB_PREFIX . "api' AND COLUMN_NAME = 'name'");
if ($query->num_rows) {
$this->db->query("ALTER TABLE `" . DB_PREFIX . "api` CHANGE `name` `username` VARCHAR(64) NOT NULL");
}
Fix2: Added delete command before ALTER to delete username then name will be renamed in username and data will be kept (api id, key...)
So in the end upgrade process (upgrade controller) should ignore entire opencart.sql database and use only commands from upgrade models.
Example
Code: Select all
if $clean_install
$database_file = opencart.sql
else
$dabase_file = execute all commands from upgrade models and ignore opencart.sql
endif
Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer
Users browsing this forum: No registered users and 7 guests