This project is archived and is in readonly mode.

#6073 ✓stale
Robert Sosinski

Postgresql tsvector datatype not recognized in schema.rb

Reported by Robert Sosinski | November 27th, 2010 @ 01:51 AM

Postgresql now supports full-text search via the tsvector datatype. However, tsvector is not currently known to the the PostgresqlAdapter. As such, when migrations are run schema.rb replaces table definitions with an undefined datatype error.

Attached is a patch which gives ActiveRecord knowledge of tsvector. With this patch, tsvector attributes can be added via migrations while also keeping the table definition intact in schema.rb.

Comments and changes to this ticket

  • Robert Sosinski

    Robert Sosinski November 27th, 2010 @ 02:49 AM

    Attaching updated patch. PostgreSQLColumn#simplified_type should probably specify tsvector as a :tsvector, not a :string.

  • Robert Sosinski

    Robert Sosinski November 27th, 2010 @ 03:13 AM

    Some more info about this. So, ActiveRecord seems to cast tsvector to a String when read from a record. ALso, if migrations define tsvectors as type tsvector in schema.rb, rails errors out during rake db:test:prepare. Interested if the migration should then just define a tevector as a String in schema.rb then?

    Interested in hearing any ideas.


  • rails

    rails March 1st, 2011 @ 12:00 AM

    • State changed from “new” to “open”

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

  • rails

    rails March 1st, 2011 @ 12:00 AM

    • State changed from “open” to “stale”
  • Gavin Brock
  • Scott Lowe

    Scott Lowe April 25th, 2011 @ 09:37 PM

    • Assigned user set to “Aaron Patterson”

    I've written some simple tests to support the PostgreSQL tsvector data type patch for #6073.

    Writing these tests has raised some questions. Whilst we can now schema dump without fear, is the data type useful on it's own? I can't think of a case where I would use the tsvector type without a trigger and of course that is not something that is presently supported in the schema DSL (or perhaps I've missed something?).

    I've attached a patch which includes Robert Sosinski's patch and my tests.

  • Scott Lowe

    Scott Lowe April 25th, 2011 @ 09:49 PM

    • Assigned user cleared.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>

Referenced by