Skip to content

[Proposal] Default value for Timestamp columns #369

@driesvints

Description

@driesvints

I posted a question at #368 a bit earlier that I should have investigated more before posting. Sorry for that.

But one question regarding this still remains: apparently you can't set a default value of CURRENT_TIMESTAMP at this point for timestamp columns because setting a default value through the DB scheme creator is currently hardcoded with single quotes around the values.

/**
 * Get the SQL for a default column modifier.
 *
 * @param  Illuminate\Database\Schema\Blueprint  $blueprint
 * @param  Illuminate\Support\Fluent  $column
 * @return string|null
 */
protected function modifyDefault(Blueprint $blueprint, Fluent $column)
{
    if ( ! is_null($column->default))
    {
        return " default '".$this->getDefaultValue($column->default)."'";
    }
}

Because of this you can't set default SQL constant values like CURRENT_TIMESTAMP because default 'CURRENT_TIMESTAMP' will return a syntax error for your SQL query.

Can this perhaps be reviewed so you can set SQL constants as default values?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions