Version control for custom modules

Hello here,
I know, this question have been posted several times (Best Practices :: SuiteCRM Documentation, "best practice" in deploying customized SuiteCRM using version control system, Version control and deployment practices for SugarCRM | That which inspires awe, https://web.archive.org/web/20181012115432/https://shanedowling.com/sugarcrm-git-version-control-strategy) but I whish to have an updated answer for 2024: is it possible to have a workflow such: “local machine development → push to my gitlab instance → deploy do production with CI/CD pipiline” for a custom module, and particulary when SQL fields add/remove are involved.

If I add a field through module Studio, the only way I have to “push it” on my staging instance or production instance is to export the customisations and then import the .zip file on all needed instances.
I wish to do it directly with git(lab).

I’ve tried to copy the modified files on another instance, do a quick & repair but this do not trigger the SQL migrations in the database.
Regarding the content of the zip files, where there is no specific SQL commands, it means that id could be possible to call an action or a command to do like the admin GUI (I mean, theorically).

Is there a way to this? Or is the GUI mandatory? Also, if you have another deployment workflow I woulf be happy to hear about it.
Thank you all

cpol0

I don’t know the answer, but I see that the v8 installer runs a few scripts (called migrations, if I am not mistaken) maybe you can find out how that works, it should be possible to add you own.

Tell us if you discover anything useful :slight_smile:

Have a look at the commands listed with

php bin/console

Hi pgr, thanks for your reply.
Yes I saw symfony migrations, but I do not want to “go against” the legacy behavior. There is already the builder to configure properly verything and code to manage schema migrations and so on (through module loader), I don’t wand to add an extra layer here but only have a smoother gitlab workflow.
Of course, I’ve also look for the symfony console first.

So, I did some debug,and the situation is currently:

  • SQL scheme migrations are managed by the ModuleInstaller class, and especially the install_custom_fields method called by install().
  • There is no console command to call this method, only GUI available. So you have to deploy packages manually when you add/remove some fields in the SQL database (or develop your own command, I didn’t look this right now). Consequence: no full CI/CD gitlab pipeline possible… (but continue to read, there are some good news bellow :slightly_smiling_face: )

For the git strategy, there are 2 cases that do not involves the same process:

  • you do “SQL modifications or related to” (fields, layouts, relationships, etc…)
  • you do not do “SQL modifications or related to”: hooks, controllers, etc…

No SQL modifs

This will probably be more than 99% of your code changes. You can track your changes, and deploy it like you want. It’s just a file like in another Web project. CI/CD is possible as usual! :information_source:

SQL modifs

You want to modify things related to fields, layouts, relationships, vardefs and metadata will be updated in the process.

I’ve found 2 solutions that seems to work:

:warning: Disclaimer: because I’m a beginner in suiteCRM, I do not envisage to edit filed that th GUI can do for me (and without errors). It could change in the future.

Studio strategy

Developer’s computer

After have created your package & module with the package builder, you do personnalization with studio only. You track 2 things:

  • public/legacy/custom/modules/<your-module>: this is the diff generated by studio. It allows for others member of the team to review the changes, and if they checkout the merge request they would be able to get studio in the same state than yours
  • public/legacy/custom/modulebuilder/packages: well, you want also to track the zip file of the changes when you publish it.

Server

You have to be careful with update because there is potentially 2 step:

  • push your new files (non SQL related) to the server
  • don’t forget to install the new module upgrade if new SQL fields are involved
  • In the module loader, you have 1 module diff per update

:question: At this point my question is: how do peoples who sell plugins to their customers? When they ship an upgrade, they need to have everything encapsulate in the same zip files. How the zip file is built? Via module builder?

Module Builder strategy

Developer’s computer

After have created your package & module with the package builder, you do further personnalization still with the module builder. You never use Studio and you track 2 things:

  • public/legacy/modules/<your-module>: the code of the module
  • public/legacy/custom/modulebuilder/: this is the code generated by the builder + you want also to track the zip file of the module when you publish it.

Server

You have to be careful with update because there is potentially 2 step:

  • push your new files (non SQL related) to the server
  • don’t forget to install the new package version if new SQL fields are involved
  • SQL schema migrations are managed if you apply a rebuild & repair at this point
  • In the module loader, you have 1 full package per modification

:question: Based on the previous question, what is stategy that modules’s developer ususally do? Do they ship a new module version that erase completely the old one?
And I’m not sure about the best strategy to follow. Should we use studio for updates, or is it also OK to use module builder?
I’ve found a @pgr answer here Code changed after deploy in module builder - #3 by pgr but I’m not sure I have a clear view about pros/cons of each solution.

Thanks
cpol0