

-- Record the migration as applied so a future `php artisan migrate` skips it
-- instead of failing on "table already exists". The derived table is required:
-- MySQL will not read from `migrations` in a subquery of its own INSERT.
INSERT INTO `migrations` (`migration`, `batch`)
SELECT '2019_12_14_000001_create_personal_access_tokens_table',
       COALESCE(MAX(`batch`), 0) + 1
FROM (SELECT `batch` FROM `migrations`) AS existing
WHERE NOT EXISTS (
  SELECT 1 FROM (SELECT `migration` FROM `migrations`) AS dup
  WHERE dup.`migration` = '2019_12_14_000001_create_personal_access_tokens_table'
);
