Skip to content

RFC - Aligning abstract types with cakephp #825

Open
@markstory

Description

@markstory

Currently migrations supports the phinx abstract type set in migration files. The driver adapters in migrations (previously phinx) can translate between the abstract types that phinx uses and the concrete dialect specific types.

I would like to align migrations with the cakephp/database conventions. Currently there are several types that exist in migrations that do not exist in cakephp e.g mediumblob, set, and enum. And other types that exist in cakephp that migrations does not directly support eg. timestampfractional.

These differences could result in some minor breaking changes as the semantics of existing migrations would change.

Types missing in CakePHP

MySQL

  • enum
  • set
  • year
  • json

The following types can be shimmed with length:

  • tinyblob
  • mediumblob
  • longblob
  • mediuminteger

Postgres

  • jsonb
  • cidr
  • inet
  • macaddr
  • interval

Sqlserver

  • filestream

Handling length based aliases

The blob/integer aliases seem simple enough to shim with a compatibility layer when running migrations. However, during schema reflection these types would be reflected as binary with lengths (as they do in CakePHP today).

Proposed deprecations/removals

  • Deprecate support for enum, and set types in migrations. Migrations using these types will emit deprecations in migrations 4.7. We have historically avoided supporting ENUM in cakephp because of the footgun they create for applications down the road. Instead we recommend folks use varchar columns with mapped types.
  • Deprecate support for inet, macaddr, interval types in postgres. These types are not portable between database dialects and don't currently have support in cakephp.
  • Deprecate support for filestream type in Sqlserver.
  • Deprecate the AdapterInterface::PHINX_TYPE_* constants. Instead we can use the cakephp ones.
  • Align with cakephp on datetime and timestamp types. This will result in different types being used in migration and dump files.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions