Skip to content


Subversion checkout URL

You can clone with
Download ZIP


added index flags to schema table #308

merged 1 commit into from

5 participants


This would allow, for example, to create some fulltext indexes with the MysqlPlatform, by passing the "fulltext" flag.



thank you for creating this pull request. I have automatically opened an issue
on our Jira Bug Tracker for you. See the issue link:

We use Jira to track the state of pull requests and the versions they got
included in.


@bamarni: does this make sense. for example PostgreSQL allows us to define a function call or constrains when creating an index, if we want to support this we will have to add yet another parameter to those functions.. Wouldn't it be better to add support for raw index definition right now? (Just like it's with the columns definition, where you have to specify the rest of the declaration)


@mvrhov : I understand your concern, personally my goal is to define a fulltext index on an entity mapping, I was planning to then submit a PR to the ORM in order to leverage those "flags" in the different drivers (see for an example).

Then wether it should be abstracted or through database-specific raw definition is not for me to judge, as a side note, this is currently already implemented in the MysqlPlatform (, but not leveraged at the Schema Table level.

@beberlei what do you think?


PostgreSQL allows me to do something like that:

  • expression index:
    CREATE INDEX test1_lower_col1_idx ON test1 (lower(col1));
    CREATE INDEX people_names ON people ((first_name || ' ' || last_name));

  • partial index:
    CREATE INDEX orders_unbilled_index ON orders (order_nr) WHERE billed is not true;

IMO, the "raw" index definition where you specify everything right of CREATE INDEX test1_lower_col1_idx ON would be better.


I don't really know the internals but I guess then doctrine wouldn't be able to do schema diff for those raw indexes? It'd be something you'll have to keep in mind and handle manually on involved machines in multiple situations (structure changes during development, production database upgrades) while currently I'm only relying on doctrine self-upgrading tools (doctrine:schema:update and doctrine migrations).

So imo it is much more robust to have flags, usually it'd pretty simple to handle, in my use case here it's only 1 keyword to add.


@mvrhov as the Index class already has a concept of flags, it makes sense to expose them in the Schema too IMO

@beberlei beberlei merged commit 4b1ad76 into doctrine:master

1 check passed

Details default The Travis build passed

We can always refactor towards "indexDefintion" later

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 20, 2013
  1. @bamarni
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 4 deletions.
  1. +6 −4 lib/Doctrine/DBAL/Schema/Table.php
10 lib/Doctrine/DBAL/Schema/Table.php
@@ -146,9 +146,10 @@ public function setPrimaryKey(array $columns, $indexName = false)
* @param array $columnNames
* @param string $indexName
+ * @param array $flags
* @return Table
- public function addIndex(array $columnNames, $indexName = null)
+ public function addIndex(array $columnNames, $indexName = null, array $flags = array())
if($indexName == null) {
$indexName = $this->_generateIdentifierName(
@@ -156,7 +157,7 @@ public function addIndex(array $columnNames, $indexName = null)
- return $this->_createIndex($columnNames, $indexName, false, false);
+ return $this->_createIndex($columnNames, $indexName, false, false, $flags);
@@ -226,9 +227,10 @@ public function columnsAreIndexed(array $columnsNames)
* @param string $indexName
* @param bool $isUnique
* @param bool $isPrimary
+ * @param array $flags
* @return Table
- private function _createIndex(array $columnNames, $indexName, $isUnique, $isPrimary)
+ private function _createIndex(array $columnNames, $indexName, $isUnique, $isPrimary, array $flags = array())
if (preg_match('(([^a-zA-Z0-9_]+))', $indexName)) {
throw SchemaException::indexNameInvalid($indexName);
@@ -243,7 +245,7 @@ private function _createIndex(array $columnNames, $indexName, $isUnique, $isPrim
throw SchemaException::columnDoesNotExist($columnName, $this->_name);
- $this->_addIndex(new Index($indexName, $columnNames, $isUnique, $isPrimary));
+ $this->_addIndex(new Index($indexName, $columnNames, $isUnique, $isPrimary, $flags));
return $this;
Something went wrong with that request. Please try again.