Describe the bug
When running the migrate:generate command the resulting migration code does not generate the correct code.
To Reproduce
Steps to reproduce the behavior:
Create table date_test:
CREATE TABLE `date_test` (
`id` int NOT NULL AUTO_INCREMENT,
`updated_datetime_2` datetime(2) DEFAULT CURRENT_TIMESTAMP(2) ON UPDATE CURRENT_TIMESTAMP(2),
PRIMARY KEY (`id`)
) ENGINE=InnoDB;
Run php artisan migrate:generate
Open resulting migration file to find the following code:
public function up(): void
{
Schema::create('date_test', function (Blueprint $table) {
$table->integer('id', true);
$table->dateTime('updated_datetime_2', 2)->nullable()->default('CURRENT_TIMESTAMP(2)');
});
}
Expected behavior
I would expect the updated_datetime_2 field to use the useCurrentOnUpdate method and the useCurrent() method to achieve the defaults for this field.
Describe the bug When running the migrate:generate command the resulting migration code does not generate the correct code.
To Reproduce Steps to reproduce the behavior:
Run
php artisan migrate:generate
Open resulting migration file to find the following code:
Expected behavior I would expect the updated_datetime_2 field to use the useCurrentOnUpdate method and the useCurrent() method to achieve the defaults for this field.
Details (please complete the following information):
Additional context The generated code attempts to put everything as a string, into the default function. This creates a syntax error.