{"record":{"id":"baec0b4c11f4d91b","repo":"yiisoft/yii2","slug":"yii-db-cubrid-querybuilder-addcheck-is-not-suppor","errorCode":null,"errorMessage":"yii\\db\\cubrid\\QueryBuilder::addCheck is not supported by CUBRID.","messagePattern":"yii\\\\db\\\\cubrid\\\\QueryBuilder::addCheck is not supported by CUBRID\\.","errorType":"exception","errorClass":"yii\\base\\NotSupportedException","httpStatus":null,"severity":"error","filePath":"framework/db/cubrid/QueryBuilder.php","lineNumber":204,"sourceCode":"    {\n        /** @var Schema $schema */\n        $schema = $this->db->getSchema();\n        foreach ($schema->getTableUniques($table) as $unique) {\n            if ($unique->name === $name) {\n                return $this->dropUnique($name, $table);\n            }\n        }\n\n        return 'DROP INDEX ' . $this->db->quoteTableName($name) . ' ON ' . $this->db->quoteTableName($table);\n    }\n\n    /**\n     * {@inheritdoc}\n     * @throws NotSupportedException this is not supported by CUBRID.\n     */\n    public function addCheck($name, $table, $expression)\n    {\n        throw new NotSupportedException(__METHOD__ . ' is not supported by CUBRID.');\n    }\n\n    /**\n     * {@inheritdoc}\n     * @throws NotSupportedException this is not supported by CUBRID.\n     */\n    public function dropCheck($name, $table)\n    {\n        throw new NotSupportedException(__METHOD__ . ' is not supported by CUBRID.');\n    }\n\n    /**\n     * {@inheritdoc}\n     * @since 2.0.8\n     */\n    public function addCommentOnColumn($table, $column, $comment)\n    {\n        $definition = $this->getColumnDefinition($table, $column);","sourceCodeStart":186,"sourceCodeEnd":222,"githubUrl":"https://github.com/yiisoft/yii2/blob/66f00d18a29b520f85e8e8f1e32d1e7e7b556cac/framework/db/cubrid/QueryBuilder.php#L186-L222","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\n$this->addCheck('chk_price', 'product', 'price >= 0'); // throws NotSupportedException on CUBRID\n\n// after\nif ($this->db->driverName !== 'cubrid') {\n    $this->addCheck('chk_price', 'product', 'price >= 0');\n}","handlingStrategy":"try-catch","validationCode":"if ($this->db->driverName !== 'cubrid') {\n    $this->addCheck('chk_price', 'product', 'price >= 0');\n}","typeGuard":null,"tryCatchPattern":"try {\n    $this->addCheck('chk_price', 'product', 'price >= 0');\n} catch (\\yii\\db\\NotSupportedException $e) {\n    // driver cannot add CHECK constraints — skip or enforce in model rules\n    \\Yii::info($e->getMessage(), __METHOD__);\n}","preventionTips":["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"],"tags":["yii2","cubrid","database","migration","check-constraint","not-supported"],"backgroundTag":"unsupported-database-feature","analyzedSha":"66f00d18a29b520f85e8e8f1e32d1e7e7b556cac","analyzedAt":"2026-08-17T05:17:23.470Z","schemaVersion":2},"datasetVersion":"2026-08-17T09:17:11.063Z"}