GeneratePublicIdsCommand
extends Command
in package
GeneratePublicIds Command
Generates public IDs for existing records in tables that have the public_id column but haven't had IDs generated yet.
Usage: bin/cake generate_public_ids members bin/cake generate_public_ids --all
Table of Contents
Methods
- execute() : int|null
- Execute command
- _findTablesWithPublicId() : array<string|int, string>
- Find all tables that have a public_id column
- _generatePublicIdsForTable() : int
- Generate public IDs for a specific table
- _generateUniquePublicId() : string
- Generate unique public ID
- buildOptionParser() : ConsoleOptionParser
- Hook method for defining this command's option parser.
Methods
execute()
Execute command
public
execute(Arguments $args, ConsoleIo $io) : int|null
Parameters
- $args : Arguments
-
Arguments
- $io : ConsoleIo
-
Console IO
Return values
int|null —Exit code
_findTablesWithPublicId()
Find all tables that have a public_id column
protected
_findTablesWithPublicId(Connection $connection, string $field) : array<string|int, string>
Parameters
- $connection : Connection
-
Database connection
- $field : string
-
Field name
Return values
array<string|int, string> —Table names
_generatePublicIdsForTable()
Generate public IDs for a specific table
protected
_generatePublicIdsForTable(Connection $connection, string $table, string $field, int $length, bool $dryRun, ConsoleIo $io) : int
Parameters
- $connection : Connection
-
Database connection
- $table : string
-
Table name
- $field : string
-
Field name
- $length : int
-
ID length
- $dryRun : bool
-
Dry run flag
- $io : ConsoleIo
-
Console IO
Return values
int —Number of records processed
_generateUniquePublicId()
Generate unique public ID
protected
_generateUniquePublicId(Connection $connection, string $table, string $field, int $length, string $charset, int $charsetLength) : string
Parameters
- $connection : Connection
-
Database connection
- $table : string
-
Table name
- $field : string
-
Field name
- $length : int
-
ID length
- $charset : string
-
Character set
- $charsetLength : int
-
Charset length
Return values
string —Generated public ID
buildOptionParser()
Hook method for defining this command's option parser.
protected
buildOptionParser(ConsoleOptionParser $parser) : ConsoleOptionParser
Parameters
- $parser : ConsoleOptionParser
-
The parser to be defined