在我的公司,我们希望重命名我们的主要模型之一,以消除概念的模糊性。对于大多数相关模型,这个过程很简单,但我们有一个存储我们的日志,并且由于它的大小,它在PostgreSQL中进行了分区。以下迁移很可能不会在生产中工作,即使它确实如此,它也是一个不完整的解决方案:
public function rules()
{
return [
[['ingredients'], 'required'],
['ingredients', 'checkIsArray']
];
}
public function checkIsArray($attribute, $params)
{
if (empty($this->ingredients)) {
$this->addError($attribute, "config cannot be empty");
}
elseif (count($this->ingredients)>5) {
$this->addError($attribute, "Choose more");
}
elseif (count($params)<2) {
$this->addError($attribute, "Choose less");
}
}
有人知道如何解决这种情况吗?