Update on Linux

Version Date Notes By
0.1 2022-05-04 Initial release BRB

Preparing the update

Before starting the update in the client's side, you must first tag each module, including the backend and frontend. Before tagging backend, make sure that there are no translations that have not yet been merged into the backend.

  1. Connect to the translations machine and check if there's any new translations.
cd /var/www/translations-back.wemake.pt
git status
git add translation_files
git commit -m "Updated translations"
git pull
git push
  1. Tag backend, frontend and each module. You can follow the previous guide for module tagging.

  2. After tagging everything, go to https://gitlab.wemake.pt/wemake/services/satis and run the pipeline in "CI/CD » Pipelines". This is important because it's what is going to be used by composer later in the client's side.

  3. Go to frontend folder. Delete dist/ and export/ folders. In the console, run the following command: gulp export. In the file explorer, go to the frontend/export/ folder and zip everything except the env.js file.

Client's side

Backup

  1. Go to application's backend.

cd /var/www/html/sgi-back.wemake.pt/

  1. Stop all services of the application.
php artisan down
sudo supervisorctl

If the only services running are the ones related to the application: stop all

If there are services related to other applications: stop "services-names"

After that, exit supervisorctl: exit

  1. Backup database.

If you have DBeaver configured with the client's database, you can back up the database with it. Otherwise, go to .env in the backend and get the database credentials.

After getting those credentials, use the following command:

mysqldump -u username -p DBname > filename.sql

  1. Backup project.

Go to project folder (should show both backend and frontend folders).

zip -9r --symlinks sgi-yearmmdd.zip backend frontend


Update backend

  1. Check if there's any changed files locally.

git status

If there's more files changed than just composer.json and composer.lock, check with colleagues (mainly FPA) to know why and whether it's okay to ignore those changes.

  1. Get client's installed modules.

In case you don't already know what modules the client has and what to include in the composer require command, then you can check it by viewing the composer.json file.

git diff composer.json

Copy each wemake/sgi-module_name to somewhere like a .txt file.

  1. Discard composer's differences from remote branch and get the latest release.
git checkout composer.*
git pull
composer install
  1. Install the latest versions of each module.

composer require wemake/sgi-module-name wemake/sgi-module2-name

In some cases, you may need to specify the path for composer or use a specific php version or even alter the memory limit to be able to install all the modules necessary. Here's an example:

php8.1 -d memory_limit=-1 /usr/local/bin/composer require wemake/sgi-module-name

  1. Check the differences between the files .env and .env.example.

Update the version field to the latest tag.

If the client does not yet have the Laravel Activity Logger, make sure to have the following line in .env like this:

ACTIVITY_LOGGER_ENABLED=false

  1. Clear artisan services and packages files and optimize composer's autoload files.
php artisan clear-compiled
composer dumpautoload -o
  1. Run migrations.

Execute core migration and each module's migrations: php artisan migrate

Execute translations' migrations. php artisan reseed

  1. Clear caches.
php artisan clear-all
redis-cli flushall


Update frontend

  1. Move your exported frontend export.zip to the client's server.

Get the frontend export.zip from your frontend/export and send it to the client's server. This can be done via Filezilla.

  1. Remove unnecessary files from client's current frontend folder.

Most of the times, just keep the env.js file, but some clients may need to keep other files.

rm -rf !(env.js) -> removes all files and folders except env.js

  1. Unzip the export to the frontend folder.
cd /path/to/frontend
unzip /path/to/export.zip -d .
  1. Check the differences between env.js and your latest env.example.js.

Update the version field to the latest frontend tag.


Start up services again

  1. Go to the backend and start artisan.
cd /path/to/backend
php artisan up
  1. Restart supervisor's services.
sudo supervisorctl
start all


Test the application

  1. Test normal exports like PDF, Excel.

  2. Test uploading files, usually you can do so while creating a document.

  3. Test email by going to "Administration » General » Mail settings » Test". Put your own personal email and test it.

Finally, update the installation files and email the client to let them know that the update is concluded.