Wiki for user example code #60

Closed
turadg opened this Issue Feb 2, 2013 · 2 comments

Comments

Projects
None yet
2 participants
Contributor

turadg commented Feb 2, 2013

I wanted to contribute this example of how to migrate to using PG arrays, but the wiki on this project is disabled. I don't think it's worth adding to the README, but I think it would be handy others.

In this case, it converts an integer array that was represented as a space-delimited string, "1 2 3", to a native Integer array, {1 2 3}.

class AddLinkedArticleIdsToLinkSet < ActiveRecord::Migration
  def change
    add_column :link_sets, :linked_article_ids, :integer, :array => true, :default => []
    execute <<-eos
    UPDATE link_sets
    SET linked_article_ids = cast (string_to_array(linked_articles_string, ' ') as integer[])
    eos
  end
end
Contributor

danmcclain commented Feb 2, 2013

I've actually been giving some thought to the documentation for postres_ext recently. I'm leaning towards having a doc directory in the repository, as opposed to the wiki, because then the docs will be version controlled and match the different tags of the repo. With the wiki, it would be harder to look up the docs for any older versions of the gem. This would be something that would end up in that docs directory.

Contributor

danmcclain commented Feb 15, 2013

@turadg - I have added a docs folder to the repo, this would make sense in there. If you make a PR, I'll pull it in

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment