Skip to content

Instantly share code, notes, and snippets.

@prathamesh-sonpatki
Created December 29, 2013 09:40
Show Gist options
  • Select an option

  • Save prathamesh-sonpatki/8168908 to your computer and use it in GitHub Desktop.

Select an option

Save prathamesh-sonpatki/8168908 to your computer and use it in GitHub Desktop.
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', '4.0.2'
gem 'arel'
gem 'pg'
GEMFILE
system 'bundle'
end
require 'bundler'
Bundler.setup(:default)
require 'active_record'
#require 'minitest/autorun'
require 'logger'
# This connection will do for database-independent bug reports.
ActiveRecord::Base.establish_connection(adapter: 'postgresql', database: 'rails_test')
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Schema.define do
create_table :users do |t|
t.string :hstore_test
end
end
class HstoreTest < ActiveRecord::Migration
def change
change_table :users do |t|
t.hstore :hstore_test, null: false, default: {}
end
end
end
HstoreTest.new.change
# -- create_table(:users)
# D, [2013-12-29T15:08:58.175459 #29519] DEBUG -- : (467.3ms) CREATE TABLE "users" ("id" serial primary key, "hstore_test" character varying(255))
# -> 0.4766s
# -- change_table(:users)
# D, [2013-12-29T15:08:58.177064 #29519] DEBUG -- : (0.8ms) ALTER TABLE "users" ADD COLUMN "hstore_test" hstore DEFAULT '' NOT NULL
# E, [2013-12-29T15:08:58.177194 #29519] ERROR -- : PG::UndefinedObject: ERROR: type "hstore" does not exist
# LINE 1: ALTER TABLE "users" ADD COLUMN "hstore_test" hstore DEFAULT ...
@prathamesh-sonpatki
Copy link
Author

Tested on Rails 4.0.2

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