emteknetnz/silverstripe-varchar-polyfill

Polyfill for pre CMS 5.4 for DBClassNameVarchar

Installs: 13

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:silverstripe-vendormodule

1.0.2 2024-09-12 01:18 UTC

This package is auto-updated.

Last update: 2024-09-12 01:20:45 UTC


README

This module provides a polyfill for DBClassNameVarchar which is not available before silverstripe/framework 5.4.0 and was added in this pull-request.

This module works on Silverstripe 4 and 5.

This functionality this provides is described here.

When upgrading to CMS 6, and also optionally 5.4, you should uninstall this module and instead use the DBClassNameVarchar class provided in silverstripe/framework.

Installation

composer require emteknetnz/silverstripe-varchar-polyfill

Before installing this module, it it's recommended that you first validate that ALTER TABLE queries are a significant bottleneck when running dev/build. You can use emteknetnz/silverstripe-dev-build-benchark to help with this.

Configuration

Add the following configuration to your project to enable the polyfill:

SilverStripe\ORM\DataObject:
  fixed_fields:
    ClassName: DBClassNameVarcharPolyfill

SilverStripe\ORM\FieldType\DBPolymorphicForeignKey:
  composite_db:
    Class: "DBClassNameVarcharPolyfill('SilverStripe\\ORM\\DataObject', ['index' => false])"

Warning

After updating this config all necessary ALTER TABLE queries to change ClassName columns from enum to varchar will be run on the next dev/build, which can take a long time on large databases. Keep this in mind in particular when deploying to production.