Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup install then upgrade fails #61

Closed
adamj88 opened this issue Apr 6, 2017 · 7 comments
Closed

Setup install then upgrade fails #61

adamj88 opened this issue Apr 6, 2017 · 7 comments
Assignees
Milestone

Comments

@adamj88
Copy link
Contributor

adamj88 commented Apr 6, 2017

When creating a fresh install from a composer.json file with Magento & modules in and after running setup:install, when running setup:upgrade after this we're getting the following error:

Module 'bitExpert_ForceCustomerLogin':
Upgrading data... 

                                                                                                                                                                                                                                                                                                                                                                                                       
  [Zend_Db_Statement_Exception]                                                                                                                                                                                                                                                                                                                                                                        
  SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'Rest API' for key 'BITEXPERT_FORCELOGIN_WHITELIST_LABEL', query was: INSERT INTO `bitexpert_forcelogin_whitelist` (`store_id`,`label`,`url_rule`,`editable`) VALUES (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?)  
                                                                                                                                                                                                                                                                                                                                                                                                       




                                                                                                                                   
  [PDOException]                                                                                                                   
  SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'Rest API' for key 'BITEXPERT_FORCELOGIN_WHITELIST_LABEL'  
                                                                                                                                   


setup:upgrade [--keep-generated] [--magento-init-params="..."]
@der-workfloh
Copy link
Contributor

Hi @adamj88 ,

which version of the module do you use (or what does the composer.json entry look like)?

@adamj88
Copy link
Contributor Author

adamj88 commented Apr 6, 2017

Hi @websharp

Thanks for the reply, here's a more detailed explanation.

The module version is latest stable version: 1.3.1

Composer file looks similar to that generated from create-project on magento/project-community-edition, here's some steps to replicate:

Create mysql db forcelogintest

Create project

composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition forcelogintest

Add module

cd forcelogintest && composer require bitExpert/magento2-force-login:1.3.*

Add execute permissions on bin/magento

chmod u+x bin/magento

Install Magento

bin/magento setup:install \
 --db-name=forcelogintest \
 --db-host=localhost \
 --db-user=root \
 --db-password=root \
 --db-model=mysql4 \
 --db-engine=innodb \
 --db-init-statements="SET NAMES utf8;" \
 --cleanup-database \
 --admin-user=admin \
 --admin-password=password1234 \
 --admin-firstname=Admin \
 --admin-lastname=User \
 --admin-email=dummy@gmail.com \
 --backend-frontname=admin \
 --use-secure-admin=0 \
 --admin-use-security-key=1 \
 --base-url=http://local.forcelogintest.com/ \
 --base-url-secure=0 \
 --use-rewrites=1 \
 --session-save=files \
 --currency=GBP \
 --timezone=Europe/London \
 --skip-db-validation \
 --use-secure=0

Run setup upgrade after installation (or any time in the future)

bin/magento setup:upgrade

Fails with:

Module 'bitExpert_ForceCustomerLogin':
Upgrading data... 

                                                                                                                                                                                                                                                                                                                                                                                                       
  [Zend_Db_Statement_Exception]                                                                                                                                                                                                                                                                                                                                                                        
  SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'Rest API' for key 'BITEXPERT_FORCELOGIN_WHITELIST_LABEL', query was: INSERT INTO `bitexpert_forcelogin_whitelist` (`store_id`,`label`,`url_rule`,`editable`) VALUES (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?)  
                                                                                                                                                                                                                                                                                                                                                                                                       




                                                                                                                                   
  [PDOException]                                                                                                                   
  SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'Rest API' for key 'BITEXPERT_FORCELOGIN_WHITELIST_LABEL'  
                                                                                                                                   


setup:upgrade [--keep-generated] [--magento-init-params="..."]

@der-workfloh der-workfloh self-assigned this Apr 6, 2017
@der-workfloh
Copy link
Contributor

Hi @adamj88 ,

thank you for your explanation. I think we have to change the setup classes (UpgradeSchema.php) and split them (Install/Upgrade) to gain the required compatibility. For now as a workaround, you could try and delete the bitexpert_forcelogin_whitelist table after the installment, so the upgrade should run through.

@adamj88
Copy link
Contributor Author

adamj88 commented Apr 7, 2017

Hi @websharp

Sounds right, looks like when just using an upgrade script it's running on setup:install and setup:upgrade, without a check in place to see if this data already exists before adding the database table & columns.

Unfortunately for us this workaround isn't possible to implement on our CI.

I think this needs splitting into Setup/InstallSchema.php & Setup/UpgradeSchema.php - install responsible for scaffolding the table?

@der-workfloh
Copy link
Contributor

Hi @adamj88,

correct, the scaffolding part must be extracted from the current UpgradeSchema and placed into an InstallSchema. Happy if you want to give a pull request, else I will solve this in some time.

@adamj88
Copy link
Contributor Author

adamj88 commented Apr 10, 2017

Hi @websharp

I've opened a PR for this, I've tested this and it prevents the above issue from occurring.

Would it be possible for you to review this update? I've left Setup/UpgradeSchema.php in there incase you wanted to use it again in the future.

@der-workfloh der-workfloh added this to the 2.0 milestone Apr 10, 2017
@der-workfloh
Copy link
Contributor

Hi @adamj88,

I merged your PR (many thanks for that!) and published a second Release Candidate, so you could use the version 2.0.0-RC2, see https://github.com/bitExpert/magento2-force-login/releases/tag/v2.0.0-RC2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants