Skip to content

Commit 34492af

Browse files
committed
Create hstore extension when building PostgreSQL databases.
1 parent 122f6de commit 34492af

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

activerecord/Rakefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,16 @@ namespace :postgresql do
114114
config = ARTest.config['connections']['postgresql']
115115
%x( createdb -E UTF8 #{config['arunit']['database']} )
116116
%x( createdb -E UTF8 #{config['arunit2']['database']} )
117+
118+
# prepare hstore
119+
version = %x( createdb --version ).strip.gsub(/(.*)(\d\.\d\.\d)$/, "\\2")
120+
%w(arunit arunit2).each do |db|
121+
if version < "9.1.0"
122+
puts "Please prepare hstore data type. See http://www.postgresql.org/docs/9.0/static/hstore.html"
123+
else
124+
%x( psql #{config[db]['database']} -c "CREATE EXTENSION hstore;" )
125+
end
126+
end
117127
end
118128

119129
desc 'Drop the PostgreSQL test databases'

guides/source/contributing_to_ruby_on_rails.textile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ $ rake postgresql:build_databases
190190

191191
NOTE: Using the rake task to create the test databases ensures they have the correct character set and collation.
192192

193+
NOTE: You'll see the following warning (or localized warning) during activating HStore extension in PostgreSQL 9.1.x or earlier: "WARNING: => is deprecated as an operator".
194+
193195
If you’re using another database, check the files under +activerecord/test/connections+ for default connection information. You can edit these files to provide different credentials on your machine if you must, but obviously you should not push any such changes back to Rails.
194196

195197
You can now run the tests as you did for +sqlite3+. The tasks are respectively

0 commit comments

Comments
 (0)