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
Some unexpected type changes occurs when trying to rename a column with one of the following types:
Schema::create('bars', function (Blueprint$table) {
$table->mediumInteger('foo');
});
Schema::table('bars', function (Blueprint$table) {
$table->renameColumn('foo', 'bar'); // changes the name but also changes its type to INT
});
I just tested MySQL, but I believe there are similar issues on other databases.
Some modifiers are also get removed when renaming a column like useCurrentOnUpdate and invisible. I didn't check all of them.
The nullable modifier compiles to default null when renaming. I'm not sure if there is a difference between INT NULL and INT DEFAULT NULL on MySQL. Also when using nullable()->default(4) modifiers together, we expect INT NULL DEFAULT 4 but we get INT DEFAULT 4 instead.
Renaming all spatial column types (geometry, point, lineString, polygon, geometryCollection, multiPoint, multiLineString and multiPolygon) throws an exception.
Obviously all dependent column types like unsignedMediumInteger, unsignedTinyInteger, mediumIncrements, tinyIncrements etc. have the same problem.
Conclusion
I tried to list all issues of renameColumn, but some of these are also apply to modifying columns using change and some other unexpected behavior occurs when using change. I tried to fix some of them (#44101, #41320 and #43541) but still have issues like #44912. I wish we could get rid of doctrine/dbal and do column renaming and modifying natively (on Laravel 10 maybe?) or via a new Laravel first-party package, specially with many deprecations on upcoming doctrine/dbal v4: https://github.com/doctrine/dbal/blob/4.0.x/UPGRADE.md
Steps To Reproduce:
Rename a column with one of types listed above.
You may use the following test to reproduce the issue;
I feel your pain but I don't feel we're responsible here as DBAL is the package we use to handle these. Like you said it would be better if we could rely on native renaming but as said on the PR that would lead to breaking changes? I'm sorry but I don't think we can do anything ourselves here specifically.
Description:
Some unexpected type changes occurs when trying to rename a column with one of the following types:
timestamp('foo', 2)
TIMESTAMP(2)
DATETIME
mediumInteger('foo')
MEDIUMINT
INT
tinyInteger('foo')
TINYINT
TINYINT(1)
dateTime('foo', 2)
DATETIME(2)
DATETIME
time('foo', 2)
TIME(2)
TIME
year('foo')
YEAR
DATE
double('foo')
DOUBLE(8, 2)
DOUBLE PRECISION
float('foo')
DOUBLE(8, 2)
DOUBLE PRECISION
set('foo', ['bar', 'qux'])
SET('bar', 'qux')
LONGTEXT COMMENT '(DC2Type:simple_array)'
enum('foo', ['bar', 'qux'])
ENUM('bar', 'qux')
VARCHAR(255)
Additional notes:
useCurrentOnUpdate
andinvisible
. I didn't check all of them.nullable
modifier compiles todefault null
when renaming. I'm not sure if there is a difference betweenINT NULL
andINT DEFAULT NULL
on MySQL. Also when usingnullable()->default(4)
modifiers together, we expectINT NULL DEFAULT 4
but we getINT DEFAULT 4
instead.geometry
,point
,lineString
,polygon
,geometryCollection
,multiPoint
,multiLineString
andmultiPolygon
) throws an exception.unsignedMediumInteger
,unsignedTinyInteger
,mediumIncrements
,tinyIncrements
etc. have the same problem.Conclusion
I tried to list all issues of
renameColumn
, but some of these are also apply to modifying columns usingchange
and some other unexpected behavior occurs when usingchange
. I tried to fix some of them (#44101, #41320 and #43541) but still have issues like #44912. I wish we could get rid ofdoctrine/dbal
and do column renaming and modifying natively (on Laravel 10 maybe?) or via a new Laravel first-party package, specially with many deprecations on upcomingdoctrine/dbal
v4: https://github.com/doctrine/dbal/blob/4.0.x/UPGRADE.mdSteps To Reproduce:
You may use the following test to reproduce the issue;
The text was updated successfully, but these errors were encountered: