Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax error or access violation: 1064 with mariaDB driver #59

Open
mrvnklm opened this issue Dec 20, 2024 · 0 comments
Open

Syntax error or access violation: 1064 with mariaDB driver #59

mrvnklm opened this issue Dec 20, 2024 · 0 comments

Comments

@mrvnklm
Copy link

mrvnklm commented Dec 20, 2024

  2024_12_20_063222_create_tracked_jobs_table ......................................................... 1.87ms FAIL

   Illuminate\Database\QueryException 

  SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'after `name`, `attempts` int not null default '1' after `status`, `output` js...' at line 1 (Connection: mariadb, SQL: create table `tracked_jobs` (`id` bigint unsigned not null auto_increment primary key, `trackable_id` varchar(255) null, `trackable_type` varchar(255) null, `name` varchar(255) not null, `status` varchar(255) null, `job_id` varchar(255) null after `name`, `attempts` int not null default '1' after `status`, `output` json null, `started_at` timestamp null, `finished_at` timestamp null, `created_at` timestamp null, `updated_at` timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:825
    821▕                     $this->getName(), $query, $this->prepareBindings($bindings), $e
    822▕                 );
    823▕             }
    824▕ 
  ➜ 825▕             throw new QueryException(
    826▕                 $this->getName(), $query, $this->prepareBindings($bindings), $e
    827▕             );
    828▕         }
    829▕     }

      +9 vendor frames 

  10  database/migrations/2024_12_20_063222_create_tracked_jobs_table.php:20
      Illuminate\Support\Facades\Facade::__callStatic("create")
      +26 vendor frames 

  37  artisan:13
      Illuminate\Foundation\Application::handleCommand(Object(Symfony\Component\Console\Input\ArgvInput))

removing ->after(...), from job_id' and attempts does fix the issue:

<?php

declare(strict_types=1);

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    private string $table_name;
    private bool $usingUuid;

    public function __construct()
    {
        $this->table_name = config('trackable-jobs.tables.tracked_jobs', 'tracked_jobs');
        $this->usingUuid = config('trackable-jobs.using_uuid', false);
    }

    public function up(): void
    {
        Schema::create($this->table_name, function (Blueprint $table) {
            $this->usingUuid
                ? $table->uuid()->primary()
                : $table->id();
            $table->string('trackable_id')->index()->nullable();
            $table->string('trackable_type')->index()->nullable();
            $table->string('name');
            $table->string('status')->nullable();
            $table->string('job_id')->nullable();
            $table->integer('attempts')->default(1);
            $table->json('output')->nullable();
            $table->timestamp('started_at')->nullable();
            $table->timestamp('finished_at')->nullable();
            $table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists($this->table_name);
    }
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant