protected static $_ownerAttribute = null;
protected $_syncDbSchema = true;
+ protected $_uniqueKeys = [];
protected $_baseController = CubistMagicController::class;
}
+
$table->setPrimaryKey([$this->primaryKey], 'pk_' . $this->table);
foreach ($this->_fields as $field) {
if ($field instanceof UnstoredField) {
$table->addColumn($fakeColumn, 'text', ['notnull' => false]);
}
+ foreach ($this->_uniqueKeys as $name => $columns) {
+ $table->addUniqueConstraint($columns, $name);
+ }
+
return $table;
}
return $saved;
}
+ public function addUniqueKey($fields, $name = null)
+ {
+ if (!is_array($fields)) {
+ $fields = [$fields];
+ }
+
+ $name = 'unique_' . join('_', $fields);
+ $this->_uniqueKeys[$name] = $fields;
+ }
+
/**
* @param $uploadedFile UploadedFile|\SplFileInfo
* @param $attribute string
stop_measure($measure_name);
return $res;
}
+
}