jackc / surus

PostgreSQL extensions for ActiveRecord
MIT License
395 stars 35 forks source link

Is there migration support for the json data type? #5

Closed vjpr closed 11 years ago

vjpr commented 11 years ago

i.e. t.json :json_blob

jackc commented 11 years ago

You can now on master. Added in 31f89c7b28916444e90c6a299fecdbf7f87b96e0

vjpr commented 11 years ago

Fantastic!

On Fri, Jun 21, 2013 at 1:31 AM, Jack Christensen notifications@github.comwrote:

You can now on master. Added in 31f89c7https://github.com/JackC/surus/commit/31f89c7b28916444e90c6a299fecdbf7f87b96e0

— Reply to this email directly or view it on GitHubhttps://github.com/JackC/surus/issues/5#issuecomment-19761097 .

vjpr commented 11 years ago

Couldn't get it to work

undefined method `json' for #<ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::TableDefinition:0x007fdfee0fe080>

Using like this:

class Initial < ActiveRecord::Migration

  def change

    create_table :users, :id => false do |t|
      t.uuid :id, :primary_key => true
      t.string :name
      t.string :email
      t.string :password
      t.string :salt
      t.json :fb
      t.string :fb_id
      t.timestamps
    end

end
jackc commented 11 years ago

Are you using github as your gem source? It's not in a released gem yet.

i.e. Your Gemfile should have this line in it:

gem 'surus', github: 'JackC/surus'

I just tested it and it works for me:

Migration:

class AddDocToUsers < ActiveRecord::Migration
  def change
    add_column :users, :doc, :json
  end
end

Execution:

jack@hk-47~/dev/surus_test_3_2_13$ rake db:migrate
==  AddDocToUsers: migrating ==================================================
-- add_column(:users, :doc, :json)
   -> 0.0008s
==  AddDocToUsers: migrated (0.0009s) =========================================
vjpr commented 11 years ago

Yep I have gem 'surus', :github => 'JackC/surus', :branch => 'master'

Using surus (0.4.1) from git://github.com/JackC/surus.git (at master)

Did you test it with the block version migration?

On Fri, Jun 21, 2013 at 1:57 AM, Jack Christensen notifications@github.comwrote:

Are you using github as your gem source? It's not in a released gem yet.

i.e. Your Gemfile should have this line in it:

gem 'surus', github: 'JackC/surus'

I just tested it and it works for me:

Migration:

class AddDocToUsers < ActiveRecord::Migration def change add_column :users, :doc, :json end end

Execution:

jack@hk-47~/dev/surus_test_3_2_13$ rake db:migrate == AddDocToUsers: migrating ================================================== -- add_column(:users, :doc, :json) -> 0.0008s == AddDocToUsers: migrated (0.0009s) =========================================

— Reply to this email directly or view it on GitHubhttps://github.com/JackC/surus/issues/5#issuecomment-19762788 .

vjpr commented 11 years ago

Okay just tested.

add_column :users, :doc, :json works

t.json doesn't.

And schema.rb doesn't work

# Could not dump table "users" because of following StandardError
#   Unknown type 'json' for column 'fb'
jackc commented 11 years ago

I just pushed an update to master. bundle update surus and try again.