diff --git a/en/appendices/5-2-migration-guide.rst b/en/appendices/5-2-migration-guide.rst index 3a56d401e6..69a6d9760b 100644 --- a/en/appendices/5-2-migration-guide.rst +++ b/en/appendices/5-2-migration-guide.rst @@ -17,6 +17,12 @@ Behavior Changes New Features ============ +Console +------- + +- The ``cake counter_cache`` command was added. This command can be used to + regenerate counters for models that use ``CounterCacheBehavior``. + ORM --- diff --git a/en/console-commands.rst b/en/console-commands.rst index 77c0a10c8b..c40f966c9c 100644 --- a/en/console-commands.rst +++ b/en/console-commands.rst @@ -145,6 +145,7 @@ CakePHP Provided Commands console-commands/cache console-commands/completion + console-commands/counter-cache console-commands/i18n console-commands/plugin console-commands/schema-cache diff --git a/en/console-commands/counter-cache.rst b/en/console-commands/counter-cache.rst new file mode 100644 index 0000000000..cc50932bcf --- /dev/null +++ b/en/console-commands/counter-cache.rst @@ -0,0 +1,24 @@ +CounterCache Tool +################# + +The CounterCacheCommand provides a CLI tool for rebuilding the counter caches +in your application and plugin models. It can be used in maintenance and +recovery operations, or to populate new counter caches added to your +application. + +.. code-block:: console + + bin/cake counter_cache --assoc Comments Articles + +This would rebuild the ``Comments`` related counters on the ``Articles`` table. +For very large tables you may need to rebuild counters in batches. You can use +the ``--limit`` and ``--page`` options to incrementally rebuild counter state. + +.. code-block:: console + + bin/cake counter_cache --assoc Comments --limit 100 --page 2 Articles + +When ``limit`` and ``page`` are used, records will be ordered by the table's +primary key. + +.. versionadded:: 5.2.0