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
# Roll up hourly rows older than 14 days (dry run)
$ wp top10 db rollup --dry-run
Namespace: WebberZone\Top_Ten\Pro\CLI
Since: 4.3.0
Source: includes/pro/cli/class-database-command.php line 39
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: 64
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: 108
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: 157
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=
| Type | Name | Description |
|---|---|---|
array |
$args |
Command arguments. |
array |
$assoc_args |
Command associative arguments. |
Returns: void
rollup()
Collapse old hourly daily rows into one row per post and calendar date.
OPTIONS
[–before=
[–force] : Skip the confirmation required for this data-changing operation.
[–dry-run] : Show exact row counts before and after the rollup without writing data.
[–network] : Roll up daily rows for all sites in the network.
[–blog-id=
EXAMPLES
wp top10 db rollup --dry-run
wp top10 db rollup --before=30 --dry-run
wp top10 db rollup --before=14 --force
wp top10 db rollup --network --dry-run
Since: 4.5.0
Line: 318
public function rollup( 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=
| 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: 533
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=
| 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=
| Type | Name | Description |
|---|---|---|
array |
$args |
Command arguments. |
array |
$assoc_args |
Command associative arguments. |
Returns: void