Automattic\WooCommerce\Database\Migrations
MetaToCustomTableMigrator::build_verification_query()
Generate query to fetch data from both source and destination tables. Use the results in verify_data to verify if data was migrated properly.
Method of the class: MetaToCustomTableMigrator{}
No Hooks.
Return
String
. SELECT statement.
Usage
// protected - for code of main (parent) or child class $result = $this->build_verification_query( $source_ids );
- $source_ids(array) (required)
- Array of IDs in source table.
MetaToCustomTableMigrator::build_verification_query() MetaToCustomTableMigrator::build verification query code WC 9.7.1
protected function build_verification_query( $source_ids ) { $source_table = $this->schema_config['source']['entity']['table_name']; $destination_table = $this->schema_config['destination']['table_name']; $destination_source_rel_column = $this->schema_config['destination']['source_rel_column']; $source_destination_rel_column = $this->schema_config['source']['entity']['destination_rel_column']; $source_destination_join_clause = "$destination_table ON $destination_table.$destination_source_rel_column = $source_table.$source_destination_rel_column"; $meta_select_clauses = array(); $source_select_clauses = array(); $destination_select_clauses = array(); foreach ( $this->core_column_mapping as $column_name => $schema ) { $source_select_column = isset( $schema['select_clause'] ) ? $schema['select_clause'] : "$source_table.$column_name"; $source_select_clauses[] = "$source_select_column as {$source_table}_{$column_name}"; $destination_select_clauses[] = "$destination_table.{$schema['destination']} as {$destination_table}_{$schema['destination']}"; } foreach ( $this->meta_column_mapping as $meta_key => $schema ) { $destination_select_clauses[] = "$destination_table.{$schema['destination']} as {$destination_table}_{$schema['destination']}"; } $select_clause = implode( ', ', array_merge( $source_select_clauses, $meta_select_clauses, $destination_select_clauses ) ); $where_clause = $this->get_where_clause_for_verification( $source_ids ); return " SELECT $select_clause FROM $source_table LEFT JOIN $source_destination_join_clause WHERE $where_clause "; }