spatie / laravel-activitylog

Log activity inside your Laravel app

Home Page:https://docs.spatie.be/laravel-activitylog

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SQLSTATE[01000]: Warning: 1265 Data truncated for column 'subject_id'

salahhusa9 opened this issue · comments

Describe the bug
SQLSTATE[01000]: Warning: 1265 Data truncated for column 'subject_id' at row 1,

To Reproduce
Things needed to reproduce the error.
seed

$project = Project::create([
            'title' => 'Project 1',
            'description' => 'Project 1 description',
            'budget' => 10,
            'release_date' => now()->addDays(10),
            'status' => ProjectStatusEnum::pending->value,
            'payment_status' => ProjectPaymentStatusEnum::pending->value,
            'freelancer_id' => 1,
            'customer_id' => 2,
        ]);

        $project->targets()->create([
            'title' => 'Target 1',
            'details' => 'Target 1 details',
            'user_id' => 2,
            'duedate' => now()->addDays(5),
            'budget' => 5,
            'status' => ProjectTargetStatusEnum::pending->value,
            'payment_status' => ProjectTargetPaymentStatusEnum::pending->value,
        ]);

        $project->targets()->create([
            'title' => 'Target 2',
            'details' => 'Target 2 details',
            'user_id' => 2,
            'duedate' => now()->addDays(9),
            'budget' => 5,
            'status' => ProjectTargetStatusEnum::pending->value,
            'payment_status' => ProjectTargetPaymentStatusEnum::pending->value,
        ]);

Model: normal

Expected behavior
seed this data

Screenshots

Versions (please complete the following information)

  • PHP: 8.1.2
  • Database: 10.4.22-MariaDB
  • Laravel: 9.38.0
  • Package: 4.7.2

Additional context
I need to seed this data and i Log Activity in Project and ProjectTarget model

Exception

  Illuminate\Database\QueryException 

  SQLSTATE[01000]: Warning: 1265 Data truncated for column 'subject_id'

Stack Trace

\vendor\laravel\framework\src\Illuminate\Database\Connection.php:760
    756▕         // If an exception occurs when attempting to run a query, we'll format the error
    757▕         // message to include the bindings with SQL, which will make this exception a
    758▕         // lot more helpful to the developer instead of just the database's errors.
    759▕         catch (Exception $e) {
  ➜ 760▕             throw new QueryException(
    761▕                 $query, $this->prepareBindings($bindings), $e
    763▕         }
    764▕     }

this issue happened to me too but the issue on my side was because i was using uuid as my id it would be amazing if this issue can be fixed

to be exact my issue was Warning: 1265 Data truncated for column 'subject_id' at row 1

If UUIDs are used as PK all FK columns should also be changed to UUIDs - otherwise it can't work. Using inconsistent key types across an application makes things a lot harder.
To do so you can publish and update the migrations.

This issue is stale because it has been open 21 days with no activity. Remove stale label or comment or this will be closed in 7 days