phinx icon indicating copy to clipboard operation
phinx copied to clipboard

Datetime2 column type not supported in SQL Server

Open billschaller opened this issue 9 years ago • 2 comments

Attempting to rename a column of type 'datetime2(6)' on SQL Server results in phinx complaining,

  [RuntimeException]
  The SqlServer type: "datetime2" is not supported

This is a pretty simple fix I think. In my case, I accomplished the migration by making the following modification in SqlServerAdapter::getPhinxType - line 965-968:

            case 'datetime':
+           case 'datetime2':
            case 'timestamp':
                return static::PHINX_TYPE_DATETIME;

billschaller avatar Mar 06 '15 16:03 billschaller

I think it would only take a small amount of additional work to fully support the datetime2 variable precision timestamp - specifying the length option to a datetime type might be a good strategy, even though the result would vary by platform.

billschaller avatar Mar 06 '15 16:03 billschaller

Anyone wants to make a PR here? Otherwise we close this as this is a very old ticket.

dereuromark avatar Feb 09 '23 09:02 dereuromark