代码之家  ›  专栏  ›  技术社区  ›  glebm

PostgreSQL+Rails城市文本

  •  2
  • glebm  · 技术社区  · 15 年前

    我正试图转移到heroku,它使用postgresql 8.4,它有一个citext列类型,这是很好的,因为该应用程序是为mysql编写的。

    有没有什么方法可以使用:citext和rails(这样如果迁移在mysql上运行,citext就只使用string/text?

    我找到了这张票,但它似乎暂时不会成为铁路的一部分: https://rails.lighthouseapp.com/projects/8994/tickets/3174-add-support-for-postgresql-citext-column-type

    3 回复  |  直到 10 年前
        1
  •  3
  •   glebm    10 年前

    轨道4.2 +

    rails 4.2对 citext 列类型。

    扶手<4.2

    如果您使用的是rails<4.2,则可以尝试使用 activerecord-postgresql-citext 宝石。

    这允许您编写如下迁移:

    def up
      enable_extension("citext")                   
    
      create_table :models, :force => true do |t|  
        t.citext :name                             
        t.timestamps                               
      end                                          
    end
    
        2
  •  1
  •   Ollimac    10 年前

    只是为了记录。似乎rails 4.2对此有本机支持。

    在PostgreSQL适配器中添加了对citext列类型的支持。

    http://guides.rubyonrails.org/4_2_release_notes.html

        3
  •  0
  •   oldergod    12 年前

    我敢肯定rails的数据类型词汇表是有限的。您可能需要使用好的老式sql来处理任何其他类型。

    推荐文章