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

FIX #7828 - Robo tasks for common actions that are performed in Repair Administration module #7829

Merged

Conversation

@Abuelodelanada
Copy link
Contributor

Abuelodelanada commented Sep 7, 2019

Description

This PR fixes #7828
Sometimes it is very useful to perform some actions in SuiteCRM through the command line.

Motivation and Context

With the passage of time we have been adding habitual tasks to an immense Makefile. But since SuiteCRM has RoboTask, we can migrate those tasks to RoboTask.
The tasks that we add in this PR, are the first ones that we have migrated from our Makefile to Robo.

We added 3 tasks:

Repair database

This task synchronize database with vardefs

$ ./vendor/bin/robo repair:database  
➜  Repairing database...
➜  Database synchronized with vardefs!
➜  Executed queries: 3

You can use the argument no-execute to not execute and show the queries in stdout

$ ./vendor/bin/robo repair:database --no-execute                                                                  
➜  Repairing database...
➜  Execute the following queries 3 in order to get database synchronized with vardefs
/* Table : users */
/*COLUMNS*/
/* INDEXES */
/*INDEX MISMATCH WITH DATABASE - idx_user_name -  ROW <name> idx_user_name <type> index <fields>[0] => 'user_name'  [1] => 'is_group'  [2] => 'status'  [3] => 'last_name'  [4] => 'first_name'  [5] => 'id'  */
/* VARDEF - idx_user_name -  ROW<name> idx_user_name <type> index <fields>[0] => 'user_name'  [1] => 'is_group'  [2] => 'status'  [3] => 'last_name (30)'  [4] => 'first_name (30)'  [5] => 'id'  */
ALTER TABLE users   DROP INDEX idx_user_name,  ADD INDEX idx_user_name (user_name,is_group,status,last_name (30),first_name (30),id)
/* Table : users */
/*COLUMNS*/
/* INDEXES */
/*INDEX MISMATCH WITH DATABASE - idx_user_name -  ROW <name> idx_user_name <type> index <fields>[0] => 'user_name'  [1] => 'is_group'  [2] => 'status'  [3] => 'last_name'  [4] => 'first_name'  [5] => 'id'  */
/* VARDEF - idx_user_name -  ROW<name> idx_user_name <type> index <fields>[0] => 'user_name'  [1] => 'is_group'  [2] => 'status'  [3] => 'last_name (30)'  [4] => 'first_name (30)'  [5] => 'id'  */
ALTER TABLE users   DROP INDEX idx_user_name,  ADD INDEX idx_user_name (user_name,is_group,status,last_name (30),first_name (30),id)
/* Table : users */
/*COLUMNS*/
/* INDEXES */
/*INDEX MISMATCH WITH DATABASE - idx_user_name -  ROW <name> idx_user_name <type> index <fields>[0] => 'user_name'  [1] => 'is_group'  [2] => 'status'  [3] => 'last_name'  [4] => 'first_name'  [5] => 'id'  */
/* VARDEF - idx_user_name -  ROW<name> idx_user_name <type> index <fields>[0] => 'user_name'  [1] => 'is_group'  [2] => 'status'  [3] => 'last_name (30)'  [4] => 'first_name (30)'  [5] => 'id'  */
ALTER TABLE users   DROP INDEX idx_user_name,  ADD INDEX idx_user_name (user_name,is_group,status,last_name (30),first_name (30),id)

Rebuild Extensions

$  ./vendor/bin/robo repair:rebuild-extensions                                                                     ✭
➜  Rebuilding Extensions...
➜  Extensions rebuilt! 

You can use the argument show-output to see what the task is rebuilding

$  ./vendor/bin/robo repair:rebuild-extensions --show-output                                              
➜  Rebuilding Extensions...
LBL_MI_REBUILDING Include...<br>LBL_MI_REBUILDING Language...en_us<br>LBL_MI_REBUILDING ActionViewMap...<br>LBL_MI_REBUILDING ActionFileMap...<br>LBL_MI_REBUILDING ActionReMap...<br>LBL_MI_REBUILDING Administration...<br>LBL_MI_REBUILDING EntryPointRegistry...<br>LBL_MI_REBUILDING Extensions...<br>LBL_MI_REBUILDING FileAccessControlMap...<br>LBL_MI_REBUILDING Layoutdefs...<br>LBL_MI_REBUILDING GlobalLinks...<br>LBL_MI_REBUILDING LogicHooks...<br>LBL_MI_REBUILDING Menus...<br>LBL_MI_REBUILDING Include...<br>LBL_MI_REBUILDING ScheduledTasks...<br>LBL_MI_REBUILDING UserPage...<br>LBL_MI_REBUILDING Utils...<br>LBL_MI_REBUILDING Vardefs...<br>LBL_MI_REBUILDING JSGroupings...<br>LBL_MI_REBUILDING Actions...<br>LBL_MI_REBUILDING DC Actions...<br>LBL_MI_REBUILDING RelationshipsLBL_MI_REBUILDING TableDictionary...<br>
➜  Extensions rebuilt!

Rebuild Relationships

$  ./vendor/bin/robo repair:rebuild-relationships                                                                  ✭
➜  Rebuilding Relationships...
➜  Relationships rebuilt!

You can use the argument --show-output

$  ./vendor/bin/robo repair:rebuild-relationships --show-output                                           
➜  Rebuilding Relationships...
acl_actions...<br>acl_roles...<br>relationships...<br>leads...<br>cases...<br>bugs...<br>users...<br>campaign_log...<br>project...<br>project_task...<br>campaigns...<br>prospect_lists...<br>prospects...<br>email_marketing...<br>campaign_trkrs...<br>releases...<br>emailman...<br>schedulers...<br>job_queue...<br>contacts...<br>accounts...<br>opportunities...<br>email_templates...<br>notes...<br>calls...<br>emails...<br>meetings...<br>tasks...<br>users...<br>users...<br>currencies...<br>tracker...<br>import_maps...<br>users_last_import...<br>config...<br>upgrade_history...<br>vcals...<br>alerts...<br>roles...<br>documents...<br>document_revisions...<br>fields_meta_data...<br>inbound_email...<br>saved_search...<br>user_preferences...<br>...<br>email_addresses...<br>emails_text...<br>spots...<br>aobh_businesshours...<br>sugarfeed...<br>eapm...<br>oauth_consumer...<br>oauth_tokens...<br>am_projecttemplates...<br>am_tasktemplates...<br>favorites...<br>aok_knowledge_base_categories...<br>aok_knowledgebase...<br>reminders...<br>reminders_invitees...<br>fp_events...<br>fp_event_locations...<br>aod_indexevent...<br>aod_index...<br>aop_case_events...<br>aop_case_updates...<br>aor_reports...<br>aor_fields...<br>aor_charts...<br>aor_conditions...<br>aor_scheduled_reports...<br>aos_contracts...<br>aos_invoices...<br>aos_pdf_templates...<br>aos_product_categories...<br>aos_products...<br>aos_products_quotes...<br>aos_line_item_groups...<br>aos_quotes...<br>aow_actions...<br>aow_workflow...<br>aow_processed...<br>aow_conditions...<br>jjwg_maps...<br>jjwg_markers...<br>jjwg_areas...<br>jjwg_address_cache...<br>calls_reschedule...<br>securitygroups...<br>outbound_email...<br>templatesectionline...<br>oauth2tokens...<br>oauth2clients...<br>surveyresponses...<br>surveys...<br>surveyquestionresponses...<br>surveyquestions...<br>surveyquestionoptions...<br>accounts_bugs...<br>accounts_cases...<br>accounts_contacts...<br>accounts_opportunities...<br>calls_contacts...<br>calls_users...<br>calls_leads...<br>cases_bugs...<br>contacts_bugs...<br>contacts_cases...<br>contacts_users...<br>custom_fields...<br>email_addresses...<br>EmailAddress...<br>emails_email_addr_rel...<br>email_addr_bean_rel...<br>emails_beans...<br>emails_text...<br>folders...<br>folders_subscriptions...<br>folders_rel...<br>meetings_contacts...<br>meetings_users...<br>meetings_leads...<br>opportunities_contacts...<br>users_feeds...<br>users_password_link...<br>prospect_list_campaigns...<br>prospect_lists_prospects...<br>roles_modules...<br>roles_users...<br>OutboundEmail...<br>AddressBook...<br>projects_bugs...<br>projects_cases...<br>projects_products...<br>projects_accounts...<br>projects_contacts...<br>projects_opportunities...<br>acl_roles_actions...<br>acl_roles_users...<br>InboundEmail_autoreply...<br>InboundEmail_cacheTimestamp...<br>email_cache...<br>email_marketing_prospect_lists...<br>UserSignature...<br>linked_documents...<br>documents_accounts...<br>documents_contacts...<br>documents_opportunities...<br>documents_cases...<br>documents_bugs...<br>oauth_nonce...<br>cron_remove_documents...<br>aok_knowledgebase_categories...<br>am_projecttemplates_project_1...<br>am_projecttemplates_contacts_1...<br>am_projecttemplates_users_1...<br>am_tasktemplates_am_projecttemplates...<br>aos_contracts_documents...<br>aos_quotes_aos_contracts...<br>aos_quotes_aos_invoices...<br>aos_quotes_project...<br>aow_processed_aow_actions...<br>fp_event_locations_fp_events_1...<br>fp_events_contacts...<br>fp_events_fp_event_delegates_1...<br>fp_events_fp_event_locations_1...<br>fp_events_leads_1...<br>fp_events_prospects_1...<br>jjwg_maps_jjwg_areas...<br>jjwg_maps_jjwg_markers...<br>project_contacts_1...<br>project_users_1...<br>securitygroups_acl_roles...<br>securitygroups_default...<br>securitygroups_records...<br>securitygroups_users...<br>surveyquestionoptions_surveyquestionresponses...<br>
➜  Relationships rebuilded!

How To Test This

Just execute the command mentioned above ;-)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Final checklist

  • My code follows the code style of this project found here.
  • My change requires a change to the documentation.
  • I have read the How to Contribute guidelines.
@codecov-io

This comment has been minimized.

Copy link

codecov-io commented Sep 7, 2019

Codecov Report

Merging #7829 into hotfix-7.10.x will increase coverage by 0.01%.
The diff coverage is 0%.

Impacted file tree graph

@@                Coverage Diff                @@
##           hotfix-7.10.x    #7829      +/-   ##
=================================================
+ Coverage           7.27%    7.29%   +0.01%     
=================================================
  Files               3699     3702       +3     
  Lines             386144   386186      +42     
=================================================
+ Hits               28089    28158      +69     
+ Misses            358055   358028      -27
Impacted Files Coverage Δ
lib/Robo/Plugin/Commands/RepairCommands.php 0% <0%> (ø)
modules/InboundEmail/InboundEmail.php 43.88% <0%> (-0.68%) ⬇️
include/SugarPHPMailer.php 47.15% <0%> (-0.52%) ⬇️
include/SugarObjects/templates/company/Company.php 5.79% <0%> (-0.27%) ⬇️
modules/SugarFeed/SugarFeed.php 77.73% <0%> (-0.26%) ⬇️
include/SugarFields/Fields/File/SugarFieldFile.php 22.68% <0%> (-0.24%) ⬇️
include/database/MysqlManager.php 19.64% <0%> (-0.1%) ⬇️
include/phpmailer/class.phpmailer.php 28.4% <0%> (-0.07%) ⬇️
include/database/DBManager.php 28.2% <0%> (-0.06%) ⬇️
include/generic/SugarWidgets/SugarWidgetField.php 3.15% <0%> (-0.04%) ⬇️
... and 56 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 892c293...006af04. Read the comment docs.

@Abuelodelanada Abuelodelanada changed the title FIX #7828 - Robo tasks for common actions perform in Repair Administration module FIX #7828 - Robo tasks for common actions that are performed in Repair Administration module Sep 7, 2019
@salesagility salesagility deleted a comment Sep 7, 2019
@Mac-Rae

This comment has been minimized.

Copy link
Contributor

Mac-Rae commented Sep 9, 2019

This is great! Something that has been long needed. Only thing is obviously the name deviates from the ones in the user menu, Just want to know @Dillon-Brown opinion on this?

Other than that, Assessed 👍

@Mac-Rae Mac-Rae added the Assessed label Sep 9, 2019
@Abuelodelanada

This comment has been minimized.

Copy link
Contributor Author

Abuelodelanada commented Sep 9, 2019

In a later PR we should fix the internal functions... it's not so nice to see in command line <br> or untranslated labels:

➜  Rebuilding Extensions...
LBL_MI_REBUILDING Include...<br>LBL_MI_REBUILDING Language...en_us<br>
@salesagility salesagility deleted a comment Sep 9, 2019
lib/Robo/Plugin/Commands/RepairCommands.php Outdated Show resolved Hide resolved
lib/Robo/Plugin/Commands/RepairCommands.php Outdated Show resolved Hide resolved
lib/Robo/Plugin/Commands/RepairCommands.php Outdated Show resolved Hide resolved
lib/Robo/Plugin/Commands/RepairCommands.php Outdated Show resolved Hide resolved
lib/Robo/Plugin/Commands/RepairCommands.php Outdated Show resolved Hide resolved
lib/Robo/Plugin/Commands/RepairCommands.php Outdated Show resolved Hide resolved
lib/Robo/Plugin/Commands/RepairCommands.php Outdated Show resolved Hide resolved
lib/Robo/Plugin/Commands/RepairCommands.php Outdated Show resolved Hide resolved
lib/Robo/Plugin/Commands/RepairCommands.php Outdated Show resolved Hide resolved
lib/Robo/Plugin/Commands/RepairCommands.php Outdated Show resolved Hide resolved
@connorshea

This comment has been minimized.

Copy link
Contributor

connorshea commented Sep 18, 2019

Sorry I took awhile to get around to reviewing this 🙇

@salesagility salesagility deleted a comment Sep 19, 2019
Abuelodelanada and others added 8 commits Sep 19, 2019
Co-Authored-By: Connor Shea <connor.james.shea@gmail.com>
Co-Authored-By: Connor Shea <connor.james.shea@gmail.com>
Co-Authored-By: Connor Shea <connor.james.shea@gmail.com>
Co-Authored-By: Connor Shea <connor.james.shea@gmail.com>
Co-Authored-By: Connor Shea <connor.james.shea@gmail.com>
Co-Authored-By: Connor Shea <connor.james.shea@gmail.com>
Co-Authored-By: Connor Shea <connor.james.shea@gmail.com>
Co-Authored-By: Connor Shea <connor.james.shea@gmail.com>
@isleshocky77

This comment has been minimized.

Copy link
Contributor

isleshocky77 commented Sep 30, 2019

@pgorod Yeah, that was my point above. On the systems you can just plain do php, you would also be able to do ./vendor/bin/robo as it's using php from the environment. On the systems you couldn't do php, you would also have to do /usr/bin/php7.2/php ./vendor/bin/robo.

The situation above is nothing you can solve. It's how the system is setup. If php is in the PATH, then you can just call php. If it's not, you have to know where the php executable is.

You could go look at other more established projects and see what their directions to their users are for discovering the correct location of php and it's binary as well as checking if which php returns anything.

@code-ph0y code-ph0y dismissed their stale review Oct 3, 2019

Outdated

@code-ph0y code-ph0y removed the Assessed label Oct 3, 2019
Copy link
Contributor

Dillon-Brown left a comment

Left a few minor code cleanup comments but everything else seems fine. Tried it out too and everything seems to work as expected. Approved.

lib/Robo/Plugin/Commands/RepairCommands.php Outdated Show resolved Hide resolved
lib/Robo/Plugin/Commands/RepairCommands.php Outdated Show resolved Hide resolved
lib/Robo/Plugin/Commands/RepairCommands.php Outdated Show resolved Hide resolved
lib/Robo/Plugin/Commands/RepairCommands.php Outdated Show resolved Hide resolved
lib/Robo/Plugin/Commands/RepairCommands.php Outdated Show resolved Hide resolved
lib/Robo/Plugin/Commands/RepairCommands.php Outdated Show resolved Hide resolved
lib/Robo/Plugin/Commands/RepairCommands.php Outdated Show resolved Hide resolved
lib/Robo/Plugin/Commands/RepairCommands.php Outdated Show resolved Hide resolved
lib/Robo/Plugin/Commands/RepairCommands.php Outdated Show resolved Hide resolved
Co-Authored-By: Dillon Brown <26431166+Dillon-Brown@users.noreply.github.com>
Abuelodelanada and others added 6 commits Oct 3, 2019
Co-Authored-By: Dillon Brown <26431166+Dillon-Brown@users.noreply.github.com>
Co-Authored-By: Dillon Brown <26431166+Dillon-Brown@users.noreply.github.com>
Co-Authored-By: Dillon Brown <26431166+Dillon-Brown@users.noreply.github.com>
Co-Authored-By: Dillon Brown <26431166+Dillon-Brown@users.noreply.github.com>
Co-Authored-By: Dillon Brown <26431166+Dillon-Brown@users.noreply.github.com>
Co-Authored-By: Dillon Brown <26431166+Dillon-Brown@users.noreply.github.com>
@connorshea

This comment has been minimized.

Copy link
Contributor

connorshea commented Oct 3, 2019

We should probably squash this when we merge so it's not 37 commits on the hotfix-7.10.x branch.

@Dillon-Brown

This comment has been minimized.

Copy link
Contributor

Dillon-Brown commented Oct 3, 2019

We should probably squash this when we merge so it's not 37 commits on the hotfix-7.10.x branch.

Potentially, although it looks like we don't have squash commits actually enabled on the repo so it'd need done by the contributor's atm.

I would actually say that having more useful and "correct" commits is actually more valuable than reducing them though (Thinking specifically about atomic commits). It's probably something worth adding more detail to the "how to contribute section" in the docs but I'll need to look at improving my own admittedly quite bad git commits first :P.

@Abuelodelanada

This comment has been minimized.

Copy link
Contributor Author

Abuelodelanada commented Oct 3, 2019

Left a few minor code cleanup comments but everything else seems fine. Tried it out too and everything seems to work as expected. Approved.

Thank you very much @Dillon-Brown all cleanup done!

@Abuelodelanada

This comment has been minimized.

Copy link
Contributor Author

Abuelodelanada commented Oct 17, 2019

Hi @Dillon-Brown

Am I missing something to do with this PR?

@Dillon-Brown

This comment has been minimized.

Copy link
Contributor

Dillon-Brown commented Oct 17, 2019

@Abuelodelanada Nope, looks good to me, just needs assessed. I'll see if we can get this merged asap. Thanks.

@Mac-Rae

This comment has been minimized.

Copy link
Contributor

Mac-Rae commented Oct 17, 2019

Appears to be working fine, Approved & Merged 👍

@Mac-Rae Mac-Rae added Assessed and removed In Review labels Oct 17, 2019
@Mac-Rae Mac-Rae merged commit 354e8a4 into salesagility:hotfix-7.10.x Oct 17, 2019
3 of 5 checks passed
3 of 5 checks passed
Codacy/PR Quality Review Not up to standards. This pull request quality could be better.
Details
codecov/patch 0% of diff hit (target 7.27%)
Details
clahub All contributors have signed the Contributor License Agreement.
Details
codecov/project 7.29% (+0.01%) compared to 892c293
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@Abuelodelanada Abuelodelanada deleted the gcoop-libre:hotfix-7.10.x-roboutils branch Nov 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
10 participants
You can’t perform that action at this time.