Backfill contact addresses (label=HomeAddress)
SQLSTATE[42000]: Syntax error or access violation: 1142 SELECT command denied to user 'grease_crmapp'@'localhost' for table `elyx_my_gd`.`gd_contacts` (Connection: mysql, SQL: select * from `elyx_my_gd`.`gd_contacts` where `id` = 6 limit 1)
Illuminate\Database\Connection->runQueryCallback(string, array, object(Closure))Illuminate\Database\Connection->run(string, array, object(Closure))Illuminate\Database\Connection->select(string, array, boolean)Illuminate\Database\Query\Builder->runSelect()Illuminate\Database\Query\Builder->Illuminate\Database\Query\{closure}()Illuminate\Database\Query\Builder->onceWithColumns(array, object(Closure))Illuminate\Database\Query\Builder->get(array)Illuminate\Database\Concerns\BuildsQueries->first()scripts/backfill-contact-addresses.php4647 if ($legacyId > 0) {48 $legacy = DB::connection('mysql')49 ->table($legacyDb . '.gd_contacts')50 ->where('id', $legacyId)51 ->first();52 }5354 if (!$legacy && $email !== '') {55 $legacy = DB::connection('mysql')56 ->table($legacyDb . '.gd_contacts')57 ->where('email', $email)58 ->first();59 }6061 if (!$legacy) {62 $skipped++;63Illuminate\Database\Concerns\BuildsQueries->orderedChunkById(integer, object(Closure), string, string)Illuminate\Database\Concerns\BuildsQueries->chunkById(integer, object(Closure))scripts/backfill-contact-addresses.php2829DB::connection('mysql')30 ->table('contacts')31 ->select(['id', 'email', $hasLegacyId ? 'legacy_id' : DB::raw('NULL as legacy_id')])32 ->orderBy('id')33 ->chunkById(500, function ($rows) use (34 $legacyDb, $newDb, $label,35 &$total, &$inserted, &$updated, &$skipped, $hasLegacyId36 ) {37 foreach ($rows as $c) {38 $total++;3940 $contactId = (int) $c->id;41 $legacyId = $hasLegacyId ? (int) ($c->legacy_id ?? 0) : 0;42 $email = trim((string) ($c->email ?? ''));4344 // Find legacy contact row45select column_name as `name`, data_type as `type_name`, column_type as `type`, collation_name as `collation`, is_nullable as `nullable`, column_default as `default`, column_comment as `comment`, generation_expression as `expression`, extra as `extra` from information_schema.columns where table_schema = schema() and table_name = 'contacts' order by ordinal_position ascselect `id`, `email`, `legacy_id` from `contacts` where `id` is not null order by `id` asc limit 500