We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Problem with FULLTEXT indexes

Using Phalcon Devtools 2.0.7 with MySql adapter. MySql Server version: 5.7.9.

I have a table with this definition:

+-----------------+------------------+------+----------+---------+----------------+
| Field           | Type             | Null | Key      | Default | Extra          |
+-----------------+------------------+------+----------+---------+----------------+
| search_index_id | int(10) unsigned | NO   | PRI      | NULL    | auto_increment |
| origin_table    | varchar(255)     | NO   | MUL      | NULL    |                |
| origin_id       | int(11)          | NO   | MUL      | NULL    |                |
| search_text     | text             | NO   | FULLTEXT | NULL    |                |
+-----------------+------------------+------+----------+---------+----------------+

search_text has a FULLTEXT index.

Running:

phalcon migration generate --config='.phalcon/config.ini' --migrations='migrations'

generates this migration Class:

/* ... */

new Column(
    'search_text',
    array(
        'type' => Column::TYPE_TEXT,
        'notNull' => true,
        'size' => 1,
        'after' => 'origin_id'
    )
)

/* ... */

'indexes' => array(
    new Index('PRIMARY', array('search_index_id'), null),
    new Index('origin_id', array('origin_id'), null),
    new Index('origin_table', array('origin_table'), null),
    new Index('search_text', array('search_text'), null)
),

/* ... */

The Index for search_text must be a FULLTEXT type index, not a default one (the code says null as the third parameter of new Index()). This causes an error when running the migration on other working copies:

BLOB/TEXT column 'search_text' used in key specification without a key length

I fixed this by altering the migration Class definition replacing null with FULLTEXT, but actually this is definitely a bug.

I created an issue on GitHub: https://github.com/phalcon/phalcon-devtools/issues/585



12.9k
edited Jan '16

Phalcon 2.0.9 fails as well, as it generates a migration with null instead of FULLTEXT as index type for FULLTEXT columns.