cakephp / cakephp/phinx

Datetime2 column type not supported in SQL Server

Open
#510 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
PHP
Stars
4.5k
Forks
884
PR merge metrics
No merged PRs in 30d

Description

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;

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in SqlServerAdapter::getPhinxType around lines 965–968 and inspect how SQL Server column types are mapped. Verify that datetime2(6) is recognized during a column rename without the unsupported-type exception; the issue does not name a test file, so use the existing SQL Server adapter coverage if available.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, sql
Domain
database
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.