Database_Command
Database management commands for Top 10.
EXAMPLES
# Show status of all four Top 10 tables
$ wp top10 db status
# Create any missing tables
$ wp top10 db create-tables
# Prune old data (dry run)
$ wp top10 db prune --dry-run
Namespace: WebberZone\Top_Ten\Pro\CLI
Since: 4.3.0
Source: includes/cli/class-database-command.php line 35
Extends: Base_Command
Methods
status()
Show database status for all four Top 10 tables.
OPTIONS
[—format=
[—network] : Show status for all sites in the network.
[—blog-id=
EXAMPLES
wp top10 db status
wp top10 db status --format=json
wp top10 db status --network
Line: 60
public function status( array $args, array $assoc_args ): void;
| Type | Name | Description |
|---|---|---|
array | $args | Command arguments. |
array | $assoc_args | Command associative arguments. |
Returns: void
create_tables()
Create any missing Top 10 tables using dbDelta.
OPTIONS
[—dry-run] : Show what would be created without making changes.
[—network] : Create tables for all sites in the network.
[—blog-id=
EXAMPLES
wp top10 db create-tables
wp top10 db create-tables --dry-run
wp top10 db create-tables --network
Line: 104
public function create_tables( array $args, array $assoc_args ): void;
| Type | Name | Description |
|---|---|---|
array | $args | Command arguments. |
array | $assoc_args | Command associative arguments. |
Returns: void
update_tables()
Apply schema upgrades via dbDelta (same as plugin activation).
OPTIONS
[—dry-run] : Show what would happen without making changes.
[—network] : Apply schema upgrades for all sites in the network.
[—blog-id=
EXAMPLES
wp top10 db update-tables
wp top10 db update-tables --dry-run
wp top10 db update-tables --network
Line: 153
public function update_tables( array $args, array $assoc_args ): void;
| Type | Name | Description |
|---|---|---|
array | $args | Command arguments. |
array | $assoc_args | Command associative arguments. |
Returns: void
recreate_tables()
Recreate Top 10 tables with optional backup.
OPTIONS
[—table=
] : Which table(s) to recreate: overall, daily, funnel, log, all. Default: all.[—no-backup] : Skip creating a backup table before recreating.
[—force] : Skip interactive confirmation.
[—dry-run] : Show what would happen without making changes.
[—network] : Recreate tables for all sites in the network.
[—blog-id=
EXAMPLES
wp top10 db recreate-tables
wp top10 db recreate-tables --table=daily --no-backup
wp top10 db recreate-tables --table=funnel --force
wp top10 db recreate-tables --table=log --force
wp top10 db recreate-tables --force --dry-run
wp top10 db recreate-tables --network
Line: 214
public function recreate_tables( array $args, array $assoc_args ): void;
| Type | Name | Description |
|---|---|---|
array | $args | Command arguments. |
array | $assoc_args | Command associative arguments. |
Returns: void
prune()
Prune old rows from the daily and/or visits log table.
OPTIONS
[—days=
[—log-days=
[—table=
] : Which table to prune: daily, log, all. Default: all.[—batch-size=
[—force] : Skip interactive confirmation.
[—dry-run] : Show counts without deleting.
[—network] : Prune for all sites in the network.
[—blog-id=
EXAMPLES
wp top10 db prune
wp top10 db prune --days=90 --table=daily --dry-run
wp top10 db prune --log-days=7 --table=log --force
wp top10 db prune --network
Line: 321
public function prune( array $args, array $assoc_args ): void;
| Type | Name | Description |
|---|---|---|
array | $args | Command arguments. |
array | $assoc_args | Command associative arguments. |
Returns: void
aggregate()
Force-drain the visits funnel into the log and count tables.
OPTIONS
[—batch-size=
[—dry-run] : Show how many funnel rows would be aggregated without processing them.
[—network] : Run aggregation for all sites in the network.
[—blog-id=
EXAMPLES
wp top10 db aggregate
wp top10 db aggregate --batch-size=5000
wp top10 db aggregate --dry-run
Line: 439
public function aggregate( array $args, array $assoc_args ): void;
| Type | Name | Description |
|---|---|---|
array | $args | Command arguments. |
array | $assoc_args | Command associative arguments. |
Returns: void
truncate()
Truncate one or more Top 10 tables.
OPTIONS
[—table=
] : Which table to truncate: overall, daily, log, funnel, all. Default: all.[—force] : Skip interactive confirmation.
[—dry-run] : Show what would be truncated without making changes.
[—network] : Truncate tables for all sites in the network.
[—blog-id=
EXAMPLES
wp top10 db truncate --table=funnel --force
wp top10 db truncate --table=all --dry-run
wp top10 db truncate --network --force
Line: 501
public function truncate( array $args, array $assoc_args ): void;
| Type | Name | Description |
|---|---|---|
array | $args | Command arguments. |
array | $assoc_args | Command associative arguments. |
Returns: void
cleanup_orphans()
Remove count rows for posts that no longer exist.
OPTIONS
[—table=
] : Which table to clean: overall, daily, all. Default: all.[—batch-size=
[—force] : Skip interactive confirmation.
[—dry-run] : Count orphan rows without deleting.
[—network] : Run for all sites in the network.
[—blog-id=
EXAMPLES
wp top10 db cleanup-orphans --dry-run
wp top10 db cleanup-orphans --table=overall --force
Line: 584
public function cleanup_orphans( array $args, array $assoc_args ): void;
| Type | Name | Description |
|---|---|---|
array | $args | Command arguments. |
array | $assoc_args | Command associative arguments. |
Returns: void