Skip to content

creation of a PGArray column in a migration not documented #476

Closed
pvh opened this Issue May 2, 2012 · 6 comments

3 participants

@pvh
pvh commented May 2, 2012

I'd like to create an array of text in a column via a migration. I know how to do this via direct SQL, but I can't intuit how to do it with the migration dsl.

Sequel.migration do
  change do
    create_table :once do
      column 'signature', :bytea
      column 'arguments', :array_text # this part is where i am confused :)
    end
  end
end
@jeremyevans
Owner

Use of database specific types is documented: http://sequel.rubyforge.org/rdoc/files/doc/schema_modification_rdoc.html

You want:

column :arguments, 'text[]'

@jeremyevans jeremyevans closed this May 2, 2012
@pvh
pvh commented May 2, 2012

I would definitely suggest documenting this on the array plugin doc! It wasn't obvious to an inexperienced user such as myself.

@jeremyevans
Owner

I don't have a problem doing that. Can you submit a pull request with the documentation added?

@ordinaryzelig ordinaryzelig added a commit to ordinaryzelig/sequel that referenced this issue Nov 28, 2013
@ordinaryzelig ordinaryzelig Add ref on how to add pg_array column 3b3b6c3
@agirorn
agirorn commented Jan 18, 2015

Sorry this just dose not clear things up at all.
Shouldn't there just be a code block in the docs with a concrete example?

@jeremyevans
Owner

The schema modification guide makes it fairly clear how to use the type name verbatim. The only trouble I could see if you didn't know the type name for array type you wanted to use.

Providing concrete examples for every possible case would make the documentation even more voluminous than it already is. The user who originally had this issue thought linking to the schema modification guide was the correct way to document it, and I agree. That being said, if you think that is insufficient, please send a pull request with a documentation update.

@agirorn
agirorn commented Jan 18, 2015

You're probably right regarding the correct way to document this feature.

I'm leaving this small code block on how to define PostgreSql Arrays for those like my that don't get this right away.

Sequel.migration do
  change do
    create_table :once do
      column 'signature', :bytea
      column 'arguments', 'text[]' # PostgreSql Array
    end
  end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.