diff --git a/products/tools/cli/project-commands/mysql-dump.md b/products/tools/cli/project-commands/mysql-dump.md index 526bf897e..872b9f13e 100644 --- a/products/tools/cli/project-commands/mysql-dump.md +++ b/products/tools/cli/project-commands/mysql-dump.md @@ -109,3 +109,25 @@ dump: where: : 'id > 5' ``` + +## Limiting the number of rows + +Use the `--limit` flag to cap the number of rows exported for a table, for example to keep only the newest orders: + +```bash +shopware-cli project dump --limit order=100 +``` + +Tables referencing the limited table via foreign keys (including transitively) are filtered automatically, so they only contain rows belonging to the kept rows. A second limit on a table that is already filtered this way is rejected. When the limited table references itself (for example `product.parent_id`), the ancestors of the kept rows are exported too, so the dump stays importable. This requires the `CREATE` and `DROP` privileges, since the kept rows are frozen into staging tables. + +The same behavior can be configured persistently in `.shopware-project.yml`: + +```yaml +# .shopware-project.yml +dump: + limit: + : + rows: 100 + # Defaults to "created_at DESC" when the table has a created_at column + order_by: 'created_at DESC' +```