Created
March 21, 2014 13:15
-
-
Save maciejkowalski/9685944 to your computer and use it in GitHub Desktop.
Add PostgreSQL Hstore extension to structure.sql (HACK
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :db do | |
namespace :structure do | |
task :add_hstore_extension do | |
puts "HACK! Adding `CREATE EXTENSION hstore SCHEMA hstore;` to structure.sql (see db_strucute_dump.rake)" | |
structure_dump = Rails.root + "db/structure.sql" | |
new_structure_dump = Rails.root + "db/new_structure.sql" | |
new_file = File.open(new_structure_dump, 'w') | |
existing = File.open(structure_dump) | |
existing.each do |line| | |
new_file << line | |
if line == "CREATE SCHEMA hstore;\n" | |
new_file << "CREATE EXTENSION hstore SCHEMA hstore;" | |
end | |
end | |
existing.close | |
new_file.close | |
FileUtils.mv(new_structure_dump, structure_dump) | |
end | |
end | |
end | |
Rake::Task["db:structure:dump"].enhance do | |
Rake::Task["db:structure:add_hstore_extension"].invoke | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
influitive/apartment#51 (comment)