setName('migrate:mp-phone')
->setDescription('Add phone & pwd_hash columns to mp_user table (run once)');
}
protected function execute(Input $input, Output $output): int
{
$conn = (string) config('database.default');
$cfg = config('database.connections.' . $conn);
$prefix = (string) ($cfg['prefix'] ?? '');
$table = $prefix . 'mp_user';
try {
$cols = Db::query('SHOW COLUMNS FROM `' . $table . "` LIKE 'phone'");
if (!empty($cols)) {
$output->writeln('Column phone already exists on ' . $table . ', skipped.');
return 0;
}
} catch (Throwable $e) {
$output->writeln('' . $e->getMessage() . '');
return 1;
}
$sql = <<writeln('OK: phone & pwd_hash added to ' . $table . '');
} catch (Throwable $e) {
$output->writeln('' . $e->getMessage() . '');
$output->writeln('You can also run SQL manually: database/patch_mp_user_phone.sql');
return 1;
}
return 0;
}
}