Commit cfaa5f12 authored by zYne's avatar zYne

--no commit message

--no commit message
parent 23025b58
......@@ -180,7 +180,19 @@ class Doctrine_Export_Sqlite extends Doctrine_Export
}
$name = $this->conn->quoteIdentifier($name, true);
$query[] = 'CREATE TABLE ' . $name . ' (' . $queryFields . ')';
$sql = 'CREATE TABLE ' . $name . ' (' . $queryFields . ')';
if ($check = $this->getCheckDeclaration($fields)) {
$sql .= ', ' . $check;
}
if (isset($options['checks']) && $check = $this->getCheckDeclaration($options['checks'])) {
$sql .= ', ' . $check;
}
$sql .= ')';
$query[] = $sql;
if (isset($options['indexes']) && ! empty($options['indexes'])) {
foreach ($options['indexes'] as $index => $definition) {
......
......@@ -121,7 +121,9 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
*
* -- foreignKeys the foreign keys of this table
*
* -- collation
* -- checks the check constraints of this table, eg. 'price > dicounted_price'
*
* -- collation collation attribute
*
* -- indexes the index definitions of this table
*
......@@ -468,6 +470,23 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
{
$this->options['foreignKeys'][] = $definition;
}
/**
* addCheckConstraint
*
* adds a check constraint to this table
*
* @return void
*/
public function addCheckConstraint($definition, $name)
{
if (is_string($name)) {
$this->options['checks'][$name] = $definition;
} else {
$this->options['checks'][] = $definition;
}
return $this;
}
/**
* addIndex
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment