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

Update database 1.7.x #1932

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
32 changes: 6 additions & 26 deletions development/database/structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,20 @@ These files are used during the PrestaShop installation as well.

Another file is being used to load data during the install process: `install/data/db_data.sql`. Some versions of PrestaShop do not use it so you might not always find it in the ZIP archive.

## Structure and content upgrades
## Structure and content updates

### Defining changes

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
upgrade file must be created along the `db_structure.sql` update. This SQL
update file must be created along the `db_structure.sql` update. This SQL
file will be stored in the folder `/install/upgrade/sql/`.

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

For instance, here is the file *[1.7.8.0.sql](https://github.com/PrestaShop/PrestaShop/blob/1.7.8.0/install-dev/upgrade/sql/1.7.8.0.sql)*,
used by shops upgrading to 1.7.8.0 or later:
For instance, here is the file *[1.7.8.0.sql](https://github.com/PrestaShop/PrestaShop/blob/1.7.8.0/install-dev/upgrade/sql/1.7.8.0.sql)*, used by stores updating to 1.7.8.0 or later:

```sql
[...]
Expand All @@ -56,14 +55,14 @@ UPDATE `PREFIX_product` SET `product_type` = "virtual" WHERE `is_virtual` = 1;
/* PHP:ps_1780_add_feature_flag_tab(); */;
```

In there we can read the SQL queries to execute when upgrading to 1.7.8.0.
In there we can read the SQL queries to execute when updating to 1.7.8.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.

To make the code callable, a dedicated file has to be created in
`/install/upgrade/php/` with a function in it. This file and function must have
the same name as we saw in the SQL upgrade file.
the same name as we saw in the SQL update file.

If we reuse the previous example, we will find the corresponding file *[/install/upgrade/php/ps_1780_add_feature_flag_tab.php](https://github.com/PrestaShop/PrestaShop/blob/1.7.8.0/install-dev/upgrade/php/ps_1780_add_feature_flag_tab.php)*:

Expand All @@ -81,23 +80,4 @@ consider it was run without failure.

### Applying changes

Applying the changes on your database can be done:

* by reinstalling the shop
* from a previous version of PrestaShop, by copying the new files and calling
the PHP script `install/upgrade/upgrade.php`

PrestaShop lists the upgrade files waiting to be applied, by selecting the names
fitting between the configuration property `PS_VERSION_DB` and the constant
`_PS_INSTALL_VERSION_` defined in `install/install_version.php`.

In the top of this page, we talked about entities being managed only by
Doctrine. Applying the changes on the database is done with the following command:

```
php bin/console prestashop:schema:update-without-foreign
```

{{% notice note %}}
Use `php app/console` instead of `php bin/console` for versions prior to {{< minver v="1.7.4" >}}
{{% /notice %}}
Applying the changes is covered in [the update page]({{< ref "/1.7/basics/keeping-up-to-date/update" >}}).
Loading