yiisoft/yii2 · error · yii\base\NotSupportedException
yii\db\cubrid\QueryBuilder::addCheck is not supported by CUB
Error message
yii\db\cubrid\QueryBuilder::addCheck is not supported by CUBRID.
What it means
yii\db\cubrid\QueryBuilder::addCheck() (framework/db/cubrid/QueryBuilder.php:204) throws NotSupportedException unconditionally — the CUBRID query builder provides no implementation for adding CHECK constraints. Any call path reaching it (yii\db\Command::addCheck(), or $this->addCheck() inside a migration) fails by design, reporting that the operation is unavailable on this DBMS driver.
Source
Thrown at framework/db/cubrid/QueryBuilder.php:204
{
/** @var Schema $schema */
$schema = $this->db->getSchema();
foreach ($schema->getTableUniques($table) as $unique) {
if ($unique->name === $name) {
return $this->dropUnique($name, $table);
}
}
return 'DROP INDEX ' . $this->db->quoteTableName($name) . ' ON ' . $this->db->quoteTableName($table);
}
/**
* {@inheritdoc}
* @throws NotSupportedException this is not supported by CUBRID.
*/
public function addCheck($name, $table, $expression)
{
throw new NotSupportedException(__METHOD__ . ' is not supported by CUBRID.');
}
/**
* {@inheritdoc}
* @throws NotSupportedException this is not supported by CUBRID.
*/
public function dropCheck($name, $table)
{
throw new NotSupportedException(__METHOD__ . ' is not supported by CUBRID.');
}
/**
* {@inheritdoc}
* @since 2.0.8
*/
public function addCommentOnColumn($table, $column, $comment)
{
$definition = $this->getColumnDefinition($table, $column);View on GitHub (pinned to 66f00d18a2)
Solutions
- Guard the migration by driver: if ($this->db->driverName !== 'cubrid') { $this->addCheck(...); }
- Catch yii\db\NotSupportedException around the call and log/skip when check constraints are optional
- If the constraint is mandatory on CUBRID, enforce it in model validation or raw SQL appropriate to your CUBRID version
Example fix
// before
$this->addCheck('chk_price', 'product', 'price >= 0'); // throws NotSupportedException on CUBRID
// after
if ($this->db->driverName !== 'cubrid') {
$this->addCheck('chk_price', 'product', 'price >= 0');
} Defensive patterns
Strategy: try-catch
Validate before calling
if ($this->db->driverName !== 'cubrid') {
$this->addCheck('chk_price', 'product', 'price >= 0');
} Try / catch
try {
$this->addCheck('chk_price', 'product', 'price >= 0');
} catch (\yii\db\NotSupportedException $e) {
// driver cannot add CHECK constraints — skip or enforce in model rules
\Yii::info($e->getMessage(), __METHOD__);
} Prevention
- Branch migrations on $this->db->driverName for driver-specific schema operations
- Keep a per-driver capability map when supporting multiple DBMSs
- Prefer enforcing optional business constraints in model rules when a target driver lacks support
When it happens
Trigger: A migration written against MySQL/PostgreSQL calls $this->addCheck('chk_price','product','price >= 0') while the component's connection is CUBRID; shared migration templates that always add check constraints.
Common situations: Multi-database applications reusing one migration set across drivers; CI matrices running the same migrations on several DBMSs; Yii's CUBRID driver is community-maintained and implements fewer schema operations than mysql/pgsql.
Related errors
- yii\db\cubrid\QueryBuilder::dropCheck is not supported by CU
- CUBRID does not support check constraints.
- Unable to find column '$column' in table '$table'.
- CUBRID does not support default value constraints.
- Oracle does not support ON UPDATE clause.
AI-assisted analysis of yiisoft/yii2@66f00d18a2 (2026-08-17).
Data as JSON: /api/errors/baec0b4c11f4d91b.
Report an issue: GitHub.