-
-
Notifications
You must be signed in to change notification settings - Fork 31
Open
Labels
status:to be verifiedNeeds to be reproduced and validated.Needs to be reproduced and validated.
Description
No duplicates 🥲.
- I have searched for a similar issue in our bug tracker and didn't find any solutions.
Describe the bug
Trying to execute migration with default value set as Fragment
$table
->addColumn('ttl', 'timestamp', [
'nullable' => true,
'default' => new Fragment('ADDTIME(`Date`, \'2:00:00\')'),
]);causes exception DateTimeImmutable::__construct(): Failed to parse time string (addtime(`Date`,'2:00:00')) at position 0 (a): The timezone could not be found in the database.
Full backtrace:
Exception: DateTimeImmutable::__construct(): Failed to parse time string (addtime(`Date`,'2:00:00')) at position 0 (a): The timezone could not be found in the database in ~/vendor/cycle/database/src/Schema/AbstractColumn.php:754
Stack trace:
#0 ~/vendor/cycle/database/src/Schema/AbstractColumn.php(754): DateTimeImmutable->__construct()
#1 ~/vendor/cycle/database/src/Driver/MySQL/Schema/MySQLColumn.php(372): Cycle\Database\Schema\AbstractColumn->formatDatetime()
#2 ~/vendor/cycle/database/src/Schema/AbstractColumn.php(370): Cycle\Database\Driver\MySQL\Schema\MySQLColumn->formatDatetime()
#3 ~/vendor/cycle/database/src/Schema/AbstractColumn.php(666): Cycle\Database\Schema\AbstractColumn->getDefaultValue()
#4 ~/vendor/cycle/database/src/Driver/MySQL/Schema/MySQLColumn.php(299): Cycle\Database\Schema\AbstractColumn->compare()
#5 ~/vendor/cycle/database/src/Schema/Comparator.php(108): Cycle\Database\Driver\MySQL\Schema\MySQLColumn->compare()
#6 ~/vendor/cycle/database/src/Schema/AbstractTable.php(705): Cycle\Database\Schema\Comparator->alteredColumns()
#7 ~/vendor/cycle/database/src/Schema/AbstractTable.php(619): Cycle\Database\Schema\AbstractTable->normalizeSchema()
#8 ~/vendor/cycle/migrations/src/Operation/Table/Update.php(28): Cycle\Database\Schema\AbstractTable->save()
#9 ~/vendor/cycle/migrations/src/Capsule.php(69): Cycle\Migrations\Operation\Table\Update->execute()
#10 ~/vendor/cycle/migrations/src/TableBlueprint.php(243): Cycle\Migrations\Capsule->execute()
#11 ~/vendor/cycle/migrations/src/TableBlueprint.php(197): Cycle\Migrations\TableBlueprint->execute()
#12 ~/schema/inv/20231013.155347_0_inv.ip_ipmi_role.php(32): Cycle\Migrations\TableBlueprint->update()
#13 ~/dev/seeding-executor.php(73): ~\Migrations\inv\migrationclass->up()
#14 ~/vendor/cycle/database/src/Database.php(188): ~\Migrations\{closure}()
#15 ~/dev/seeding-executor.php(74): Cycle\Database\Database->transaction()
#16 {main}
Is this a regression?
Not that I know.
To Reproduce
class MigrationClass extends Migration {
/**
* Create tables, add columns or insert data here
*/
public function up() {
$this->table('table_a')
->addColumn('ttl', 'timestamp', [
'nullable' => true,
'default' => new Fragment('ADDTIME(`Date`, \'2:00:00\')'),
])
->update();
}
/**
* Drop created, columns and etc here
*/
public function down() {
$this->table('table_a')
->dropColumn('ttl')
->update();
}
}Expected behaviour
A column should be added with default value set to +2 hours from time of row creation.
Media prove
No response
Database
MySQL
Your environment
- OS: CentOs Stream
- PHP 8.0.30
- cycle/migrations 3.1.0
- cycle/database 2.7.0
Additional context
No response
Metadata
Metadata
Assignees
Labels
status:to be verifiedNeeds to be reproduced and validated.Needs to be reproduced and validated.
Type
Projects
Status
Todo