Skip to content

Commit

Permalink
Fix Update from the CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
M0rgan01 committed Feb 26, 2025
1 parent f4d6aaa commit cf45f24
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 63 deletions.
108 changes: 54 additions & 54 deletions basics/keeping-up-to-date/update/upgrade-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,33 +32,33 @@ parameters, it displays the available commands and associated general options.

Example of `bin/console` command execution:

```shell
```text
$ php bin/console
Usage:
command [options] [arguments]

command [options] [arguments]
Options:
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Available commands:
help Displays help for a command
list List commands
help Displays help for a command
list List commands
backup
backup:create Create backup.
backup:list List existing backups.
backup:restore Restore your store.
backup:delete Remove a backup not anymore needed.
backup:create Create backup.
backup:list List existing backups.
backup:restore Restore your store.
backup:delete Remove a backup not anymore needed.
update
update:check-new-version Display the version the shop can update to.
update:check-requirements Check all prerequisites for an update.
update:start Update your store.
update:check-new-version Display the version the shop can update to.
update:check-requirements Check all prerequisites for an update.
update:start Update your store.
```

### List command
Expand All @@ -67,21 +67,21 @@ This command lists the Update Assistant CLI commands.

Example of list command execution:

```shell
```text
$ php bin/console list
Available commands:
help Displays help for a command
list List commands
help Displays help for a command
list List commands
backup
backup:create Create backup.
backup:list List existing backups.
backup:restore Restore your store.
backup:delete Remove a backup not anymore needed.
backup:create Create backup.
backup:list List existing backups.
backup:restore Restore your store.
backup:delete Remove a backup not anymore needed.
update
update:check-new-version Display the version the shop can update to.
update:check-requirements Check all prerequisites for an update.
update:start Update your store.
update:check-new-version Display the version the shop can update to.
update:check-requirements Check all prerequisites for an update.
update:start Update your store.
```

### Help command
Expand All @@ -91,7 +91,7 @@ Console component's built-in global options, and is therefore available for all

Example of help command execution:

```shell
```text
$ php bin/console backup:list help [command]
```

Expand All @@ -116,7 +116,7 @@ The Update Assistant CLI includes 4 commands dedicated to backup management:
The `backup:create` command is used to create a backup of your PrestaShop store. These backup files are stored in the
`/your-admin-directory/autoupgrade/backup` folder on your server.

```shell
```text
$ php bin/console backup:create help
backup:create: create a PrestaShop store backup
Expand Down Expand Up @@ -145,7 +145,7 @@ file. You must specify the location (`--from-config-file=.../folder1/configfile`

Example of `backup:create` command execution:

```shell
```text
$ php bin/console backup:create admin123 --include-images=1
Your files, database, and images will be backed up.
Starting backup...
Expand All @@ -155,7 +155,7 @@ Starting backup...

The `backup:list` command lists the backups available for your PrestaShop store.

```shell
```text
$ php bin/console backup:list help
backup:list: list all available backups for the store
Expand All @@ -174,7 +174,7 @@ The `[ADMIN_DIR]` argument is mandatory and is used to target the correct resour

Example of the `backup:list` command execution:

```shell
```text
$ php bin/console backup:list admin123
------------------+---------------+-----------------------------------------+
| Date | Version | File name |
Expand All @@ -188,7 +188,7 @@ $ php bin/console backup:list admin123
The `backup:restore` command is used to restore your PrestaShop store from backup files in the
`/your-admin-directory/autoupgrade/backup` folder on your server.

```shell
```text
$ php bin/console backup:restore help
backup:restore: restore the store to a previous state from a backup file
Expand All @@ -209,26 +209,26 @@ The `[BACKUP_NAME]` argument is intended to target the backup file (file_name) t

Example of `backup:restore` command execution:

```shell
```text
$ php bin/console backup:restore admin123 autoupgrade_save_8.1.6_15/07/2024_8:00
The restoration of your store is complete
```

This command also supports the “interactive mode”, which provides you with a contextual action, such as:

```shell
```text
$ php bin/console backup:restore admin123
Please select your backup:
[0] Date: 12/19/24 10:48:43, Version: 8.1.5, File name: V8.1.5_20241219-104843-XXX
[1] Date: 12/19/24 09:44:50, Version: 8.1.5, File name: V8.1.5_20241219-094450-XXX
[2] Exit the process
[0] Date: 12/19/24 10:48:43, Version: 8.1.5, File name: V8.1.5_20241219-104843-XXX
[1] Date: 12/19/24 09:44:50, Version: 8.1.5, File name: V8.1.5_20241219-094450-XXX
[2] Exit the process
```

### backup:delete command

The `backup:delete` command is used to delete a backup file from your PrestaShop store.

```shell
```text
$ php bin/console backup:delete help
backup:delete: delete a store backup file
Expand All @@ -249,19 +249,19 @@ The `[BACKUP_NAME]` argument is intended to target the backup file (file_name) t

Example of `backup:delete` command execution:

```shell
```text
$ php bin/console backup:delete admin123 autoupgrade_save_8.1.6_15/07/2024_8:00
The backup file has been successfully deleted
```

This command also supports the “interactive mode”, which provides you with a contextual action, such as:

```shell
```text
$ php bin/console backup:delete admin123
Please select your backup:
[0] Date: 12/19/24 10:48:43, Version: 8.1.5, File name: V8.1.5_20241219-104843-XXX
[1] Date: 12/19/24 09:44:50, Version: 8.1.5, File name: V8.1.5_20241219-094450-XXX
[2] Exit the process
[0] Date: 12/19/24 10:48:43, Version: 8.1.5, File name: V8.1.5_20241219-104843-XXX
[1] Date: 12/19/24 09:44:50, Version: 8.1.5, File name: V8.1.5_20241219-094450-XXX
[2] Exit the process
```

## Update commands
Expand All @@ -276,7 +276,7 @@ The Update Assistant CLI includes 3 commands dedicated to updates:

The `update:check-new-version` command is used to check whether new updates are available for your store.

```shell
```text
$ php bin/console update:check-new-version help
update:check-new-version: list PrestaShop updates available for the store
Expand All @@ -295,7 +295,7 @@ The `[ADMIN_DIR]` argument is mandatory and is used to target the correct resour

Example of the `update:check-new-version` command execution:

```shell
```text
$ php bin/console update:check-new-version admin123
-----------+----------+-------+---------------------------------------------------------------------------+
| Version | Channel | Type | Information |
Expand All @@ -317,7 +317,7 @@ $ php bin/console update:check-new-version admin123
The `update:check-requirements` command is used to check that your store meets the technical requirements before
updating.

```shell
```text
$ php bin/console update:check-requirements help
update:check-requirements: check if the store is compatible with the update requirements.
Expand Down Expand Up @@ -351,18 +351,18 @@ recent version of PrestaShop compatible with the PHP version of your server.

Example of execution of the `update:check-requirements` command, if all prerequisites have been successfully met:

```shell
```text
$ php bin/console update:check-requirements admin123
Checking requirements...
✓ The requirements check is complete, you can update your store to this version of PrestaShop.
```

Example of execution of the `update:check-requirements` command, if some prerequisites are not met:

```shell
```text
$ php bin/console update:check-requirements admin123
Checking requirements...
X PHP\'s "Safe mode" needs to be disabled.
X PHP's "Safe mode" needs to be disabled.
X Maintenance mode needs to be enabled. Enable maintenance mode and add your maintenance IP in Shop parameters > General > Maintenance.
⚠ Your current version of the module is out of date. Update now Modules > Module Manager > Updates
```
Expand All @@ -371,7 +371,7 @@ X Maintenance mode needs to be enabled. Enable maintenance mode and add your mai

The `update:start` command is used to update your PrestaShop store.

```shell
```text
$ php bin/console update:start help
update:start: launch a store update.
Expand Down Expand Up @@ -410,7 +410,7 @@ version of PrestaShop compatible with the PHP version of your server.

Example of `update:start` command execution:

```shell
```text
$ php bin/console update:start admin123
Starting update...
Destination version: 9.0.0
Expand Down
23 changes: 14 additions & 9 deletions development/database/structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ weight: 4

### Global definition

The database structure of PrestaShop can be found in `install/data/db_structure.sql` ([8.0.x releases example](https://github.com/PrestaShop/PrestaShop/blob/8.0.x/install-dev/data/db_structure.sql)).
The database structure of PrestaShop can be found in `install/data/db_structure.sql` ([9.0.x releases example](https://github.com/PrestaShop/PrestaShop/blob/9.0.x/install-dev/data/db_structure.sql)).

It is used one time, during the installation of PrestaShop.
It contains the structure of almost all tables. If a table needs to be added or
Expand Down Expand Up @@ -40,26 +40,31 @@ Another file is being used to load data during the install process: `install/dat
Once PrestaShop is installed, the default structure and content files we saw are not used anymore.

If a new release of PrestaShop must bring changes to the existing database, an update file must be created along the `db_structure.sql` update.
This SQL file will be stored in the [auto upgrade](https://github.com/PrestaShop/autoupgrade/tree/dev/upgrade/sql) module in the folder `/upgrade/sql/`.
This SQL file will be stored in the [Update Assistant](https://github.com/PrestaShop/autoupgrade/tree/dev/upgrade/sql) module in the folder `/upgrade/sql/`.

Its name is the PrestaShop version on which the change will be applied.

For instance, here is the file *[8.0.0.sql](https://github.com/PrestaShop/autoupgrade/blob/dev/upgrade/sql/8.0.0.sql)*, used by stores updating to 8.0.0 or later:
For instance, here is the file *[9.0.0.sql](https://github.com/PrestaShop/autoupgrade/blob/dev/upgrade/sql/9.0.0.sql)*,
used by stores updating to 9.0.0 or later:

```sql
[...]
SET SESSION sql_mode='';
SET NAMES 'utf8mb4';

DROP TABLE IF EXISTS `PREFIX_referrer`;
DROP TABLE IF EXISTS `PREFIX_referrer_cache`;
DROP TABLE IF EXISTS `PREFIX_referrer_shop`;
INSERT INTO `PREFIX_configuration` (`name`, `value`, `date_add`, `date_upd`) VALUES
('PS_DEBUG_COOKIE_NAME', '', NOW(), NOW()),
('PS_DEBUG_COOKIE_VALUE', '', NOW(), NOW()),
('PS_SEPARATOR_FILE_MANAGER_SQL', ';', NOW(), NOW()),
('PS_PRODUCT_BREADCRUMB_CATEGORY', 'default', NOW(), NOW()),
('PS_SEARCH_FUZZY_MAX_DIFFERENCE', 5, NOW(), NOW())
;
[...]
/* PHP:ps_800_add_security_tab(); */;
[...]
```

In there we can read the SQL queries to execute when updating to 8.0.0.
In there we can read the SQL queries to execute when updating to .0.0.
Each of them alters the structure and/or modify the existing data.
In case you have complex algorithms to run, you can call PHP code with the
`PHP:` keyword.
Expand All @@ -68,11 +73,11 @@ To make the code callable, a dedicated file has to be created in
`/upgrade/php/` with a function in it. This file and function must have
the same name as we saw in the SQL update file.

If we reuse the previous example, we will find the corresponding file *[/upgrade/php/ps_800_add_security_tab.php](https://github.com/PrestaShop/autoupgrade/blob/dev/upgrade/php/ps_800_add_security_tab.php)*:
If we reuse the previous example, we will find the corresponding file *[/upgrade/php/ps_900_set_url_lang_prefix.php](https://github.com/PrestaShop/autoupgrade/blob/dev/upgrade/php/ps_900_set_url_lang_prefix.php)*:

```php
<?php
function ps_800_add_security_tab()
function ps_900_set_url_lang_prefix()
{
// Code inserting or updating values in database
[...]
Expand Down

0 comments on commit cf45f24

Please sign in to comment.