You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We're in the process of migrating our database migrations into phinx.
Our tables all use binary(16) as datatype for the Primary Key column.
To generate that value we set the default for the primary key to unhex(replace(uuid(),'-','')).
How would I be able to set that particular default using Phinx?
'PDOException: SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'RoleID' in /vendor/robmorgan/phinx/src/Phinx/Db/Adapter/PdoAdapter.php:198'
Also tried 'default' => 'unhex(replace(uuid(),"-",""))',. Same error.
Any suggestions?
Thanks!
The text was updated successfully, but these errors were encountered:
Hey deeuromark, appreciate your answer. But it doesn't cover my question.
This works in phinx:
'default' => 'current_timestamp()'
But I want this to work:
'default' => 'unhex(replace(uuid(),"-",""))'
I would like to end up with the following MySQL scheme: CREATE TABLE Roles ( RoleID binary(16) NOT NULL DEFAULT unhex(replace(uuid(),'-','')), Name varchar(45) NOT NULL, MenuItemID binary(16) DEFAULT NULL COMMENT 'render=translate', LastModified timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), LastModifiedByID binary(16) NOT NULL, PRIMARY KEY (RoleID), UNIQUE KEY IdxName (Name) );
If this is currently not possible in Phinx then would you accept a feature in the form of a pull request?
Hi guys,
We're in the process of migrating our database migrations into phinx.
Our tables all use binary(16) as datatype for the Primary Key column.
To generate that value we set the default for the primary key to
unhex(replace(uuid(),'-',''))
.How would I be able to set that particular default using Phinx?
I tried the following (migration generated by https://github.com/odan/phinx-migrations-generator):
This results in:
'PDOException: SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'RoleID' in /vendor/robmorgan/phinx/src/Phinx/Db/Adapter/PdoAdapter.php:198'
Also tried
'default' => 'unhex(replace(uuid(),"-",""))',
. Same error.Any suggestions?
Thanks!
The text was updated successfully, but these errors were encountered: