Skip to content

M260619000001AddTargetingToAbExperiments ​

Rasuvaeff\Yii3AbTestingDb\Migration\M260619000001AddTargetingToAbExperiments

Class · rasuvaeff/yii3-ab-testing-db · Source

Adds optional targeting column to the experiments table.

The column stores a JSON-encoded targeting rule tree or NULL (no targeting). Supported rule types: environment, attribute, and, or.

Example values:

json
{"type":"environment","values":["production","staging"]}
{"type":"attribute","attribute":"plan","value":"pro"}
{"type":"and","rules":[...]}
{"type":"or","rules":[...]}

NULL means all subjects are eligible (legacy behaviour).

The column carries no explicit DEFAULT NULL. NULL is already the implicit default of a nullable column on every driver, and yiisoft/db-mysql renders the parsed raw default as the quoted string 'NULL' — which MySQL then rejects on a TEXT column with error 1101.

Takes the SAME AbExperimentsTableName as the create migration: in 1.x both hard-coded their own default, so a configured table got CREATEd under the custom name while this ALTER went to ab_experiments — or failed.

Constructor ​

php
new M260619000001AddTargetingToAbExperiments(
    AbExperimentsTableName $table = new AbExperimentsTableName(),
)

Methods ​

up() ​

php
up(Yiisoft\Db\Migration\MigrationBuilder $b): void

down() ​

php
down(Yiisoft\Db\Migration\MigrationBuilder $b): void