Skip to content

Unable to seed rows using CURRENT_TIMESTAMP #2297

@phrfpeixoto

Description

@phrfpeixoto

Hello, I'm trying to write a simple seeder:

class MySeeder extends AbstractSeed
{
    public function run(): void
    {
        $data = [
            [
                'user_name' => 'Administrator',
                'user_creation' => 'CURRENT_TIMESTAMP',
            ]
        ];
        $table = $this->table('users');
        $table->insert($data)->saveData();
    }
}

Executing this seeder fails:

[PDOException (22007)]
  SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: 'CURRENT_TIMESTAMP' for column 'user_creation' at row 1

I explored the code a bit, and tried using Literal and Expression, but got the same result.
Is there a way to achieve this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions