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

doctrine:schema:update return a lot of NOT NULL queries #9109

Closed
kuzmany opened this issue Aug 19, 2020 · 4 comments
Closed

doctrine:schema:update return a lot of NOT NULL queries #9109

kuzmany opened this issue Aug 19, 2020 · 4 comments
Labels
bug Issues or PR's relating to bugs needs-triage For new issues/PRs that need to be triaged

Comments

@kuzmany
Copy link
Member

kuzmany commented Aug 19, 2020

Bug Description

The more details the better...

After upgrade to M3 `doctrine:schema:update --dump-sql return a lot of queries.
I know there were some issues related to doctrine/dbal for MariaDB 10.2 doctrine/dbal#2825, but we use MySql 5.7
I found a lot of solutions doctrine/orm#6790 like change/remove server_version from dbal configuration, or update doctrine/dbal in composer. Didn't help.
Anybody have some experience?

 ```

ALTER TABLE oauth2_accesstokens CHANGE client_id client_id INT UNSIGNED NOT NULL, CHANGE user_id user_id INT UNSIGNED NOT NULL, CHANGE token token VARCHAR(191) NOT NULL, CHANGE scope scope VARCHAR(191) DEFAULT NULL;
ALTER TABLE oauth2_clients CHANGE id id INT UNSIGNED AUTO_INCREMENT NOT NULL, CHANGE name name VARCHAR(191) NOT NULL, CHANGE random_id random_id VARCHAR(191) NOT NULL, CHANGE secret secret VARCHAR(191) NOT NULL;
ALTER TABLE oauth2_user_client_xref CHANGE client_id client_id INT UNSIGNED NOT NULL, CHANGE user_id user_id INT UNSIGNED NOT NULL;
ALTER TABLE oauth2_refreshtokens CHANGE client_id client_id INT UNSIGNED NOT NULL, CHANGE user_id user_id INT UNSIGNED NOT NULL, CHANGE token token VARCHAR(191) NOT NULL, CHANGE scope scope VARCHAR(191) DEFAULT NULL;
ALTER TABLE oauth2_authcodes CHANGE client_id client_id INT UNSIGNED NOT NULL, CHANGE user_id user_id INT UNSIGNED NOT NULL, CHANGE token token VARCHAR(191) NOT NULL, CHANGE scope scope VARCHAR(191) DEFAULT NULL;
ALTER TABLE oauth1_nonces CHANGE nonce nonce VARCHAR(191) NOT NULL, CHANGE timestamp timestamp VARCHAR(191) NOT NULL;
ALTER TABLE oauth1_access_tokens CHANGE consumer_id consumer_id INT UNSIGNED NOT NULL, CHANGE user_id user_id INT UNSIGNED NOT NULL, CHANGE token token VARCHAR(191) NOT NULL, CHANGE secret secret VARCHAR(191) NOT NULL;
ALTER TABLE oauth1_request_tokens CHANGE consumer_id consumer_id INT UNSIGNED NOT NULL, CHANGE user_id user_id INT UNSIGNED DEFAULT NULL, CHANGE token token VARCHAR(191) NOT NULL, CHANGE secret secret VARCHAR(191) NOT NULL, CHANGE verifier verifier VARCHAR(191) NOT NULL;
ALTER TABLE oauth1_consumers CHANGE id id INT UNSIGNED AUTO_INCREMENT NOT NULL, CHANGE name name VARCHAR(191) NOT NULL, CHANGE consumer_key consumer_key VARCHAR(191) NOT NULL, CHANGE consumer_secret consumer_secret VARCHAR(191) NOT NULL, CHANGE callback callback VARCHAR(191) NOT NULL;
ALTER TABLE assets CHANGE id id INT UNSIGNED AUTO_INCREMENT NOT NULL, CHANGE category_id category_id INT UNSIGNED DEFAULT NULL, CHANGE created_by_user created_by_user VARCHAR(191) DEFAULT NULL, CHANGE modified_by_user modified_by_user VARCHAR(191) DEFAULT NULL, CHANGE checked_out_by_user checked_out_by_user VARCHAR(191) DEFAULT NULL, CHANGE title title VARCHAR(191) NOT NULL, CHANGE alias alias VARCHAR(191) NOT NULL, CHANGE storage_location storage_location VARCHAR(191) DEFAULT NULL, CHANGE path path VARCHAR(191) DEFAULT NULL, CHANGE remote_path remote_path VARCHAR(191) DEFAULT NULL, CHANGE original_file_name original_file_name VARCHAR(191) DEFAULT NULL, CHANGE lang lang VARCHAR(191) NOT NULL, CHANGE extension extension VARCHAR(191) DEFAULT NULL, CHANGE mime mime VARCHAR(191) DEFAULT NULL;
ALTER TABLE asset_downloads CHANGE id id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, CHANGE asset_id asset_id INT UNSIGNED DEFAULT NULL, CHANGE ip_id ip_id INT UNSIGNED NOT NULL, CHANGE lead_id lead_id BIGINT UNSIGNED DEFAULT NULL, CHANGE email_id email_id INT UNSIGNED DEFAULT NULL, CHANGE tracking_id tracking_id VARCHAR(191) NOT NULL, CHANGE source source VARCHAR(191) DEFAULT NULL;
ALTER TABLE campaigns CHANGE id id INT UNSIGNED AUTO_INCREMENT NOT NULL, CHANGE category_id category_id INT UNSIGNED DEFAULT NULL, CHANGE created_by_user created_by_user VARCHAR(191) DEFAULT NULL, CHANGE modified_by_user modified_by_user VARCHAR(191) DEFAULT NULL, CHANGE checked_out_by_user checked_out_by_user VARCHAR(191) DEFAULT NULL, CHANGE name name VARCHAR(191) NOT NULL, CHANGE allow_restart allow_restart INT NOT NULL;
ALTER TABLE campaign_leadlist_xref CHANGE campaign_id campaign_id INT UNSIGNED NOT NULL, CHANGE leadlist_id leadlist_id INT UNSIGNED NOT NULL;
ALTER TABLE campaign_form_xref CHANGE campaign_id campaign_id INT UNSIGNED NOT NULL, CHANGE form_id form_id INT UNSIGNED NOT NULL;
ALTER TABLE campaign_events CHANGE id id INT UNSIGNED AUTO_INCREMENT NOT NULL, CHANGE campaign_id campaign_id INT UNSIGNED NOT NULL, CHANGE parent_id parent_id INT UNSIGNED DEFAULT NULL, CHANGE name name VARCHAR(191) NOT NULL, CHANGE decision_path decision_path VARCHAR(191) DEFAULT NULL, CHANGE temp_id temp_id VARCHAR(191) DEFAULT NULL, CHANGE channel channel VARCHAR(191) DEFAULT NULL;
ALTER TABLE campaign_leads CHANGE campaign_id campaign_id INT UNSIGNED NOT NULL, CHANGE lead_id lead_id BIGINT UNSIGNED NOT NULL;
ALTER TABLE campaign_lead_event_log CHANGE id id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, CHANGE event_id event_id INT UNSIGNED NOT NULL, CHANGE lead_id lead_id BIGINT UNSIGNED NOT NULL, CHANGE campaign_id campaign_id INT UNSIGNED DEFAULT NULL, CHANGE ip_id ip_id INT UNSIGNED DEFAULT NULL, CHANGE channel channel VARCHAR(191) DEFAULT NULL;
ALTER TABLE campaign_lead_event_failed_log CHANGE log_id log_id BIGINT UNSIGNED NOT NULL;
ALTER TABLE categories CHANGE id id INT UNSIGNED AUTO_INCREMENT NOT NULL, CHANGE created_by_user created_by_user VARCHAR(191) DEFAULT NULL, CHANGE modified_by_user modified_by_user VARCHAR(191) DEFAULT NULL, CHANGE checked_out_by_user checked_out_by_user VARCHAR(191) DEFAULT NULL, CHANGE title title VARCHAR(191) NOT NULL, CHANGE alias alias VARCHAR(191) NOT NULL;




| Q   | A
| --- | ---
| Mautic version | 
| PHP version | 
| Browser | 

### Steps to reproduce
1. 
2. 
 
### Log errors


[//]: # ( Invisible comment:
Please check for related errors in the latest log file in [mautic root]/app/log/ and/or the web server's logs and post them here. Be sure to remove sensitive information if applicable. )
@kuzmany kuzmany added bug Issues or PR's relating to bugs needs-triage For new issues/PRs that need to be triaged labels Aug 19, 2020
@kuzmany kuzmany changed the title doctrine schema update return a lot of NOT NULL queries doctrine:schema:update return a lot of NOT NULL queries Aug 19, 2020
@escopecz
Copy link
Sponsor Member

Do you remember #8349?

@kuzmany
Copy link
Member Author

kuzmany commented Aug 20, 2020

And there is any solution to switch it? Or just manually change collumns encoding?

@escopecz
Copy link
Sponsor Member

We decided to leave the migration because it's close to impossible to do it for larger databases. MySql 8 can do it much faster, but most of users aren't using v8 yet. So you fixed it only for new installations.

For upgrades I can see are 2 options:

  1. Drop all constraints and keys, update the columns and recreate the constraints and keys.
  2. Create new database schema and migrate all data into it.

@kuzmany
Copy link
Member Author

kuzmany commented Aug 20, 2020

Thank you for your experiences.
I'll close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues or PR's relating to bugs needs-triage For new issues/PRs that need to be triaged
Projects
None yet
Development

No branches or pull requests

2 participants