New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hstore extension not being dumped to structure.sql #51
Comments
hmm... i don't know that the schema dump is really responsible for creating And ya this isn't really apartment related, it's more to do with pg, hstore In a related note though, I don't think we've talked with anyone who has Brad Robertson | http://twitter.com/influitive | http://facebook.com/influitive On Mon, May 20, 2013 at 8:39 AM, Jonas Bruun Nielsen <
|
Thanks for your feedback, Brad. It makes sense, that it's not an apartment issue. But I think it would be good with a note to the hstore installatiion guidelines. Because the extension is installed in the hstore schema, Maybe I'm misunderstanding something, but I don't understand how you can have a working test environment with that configuration. Is schema.rb that different? Btw, the reason our sql dump works with apartment is because of we only require one tenant in test env. |
If anyone else are experiencing these problems I did not find a proper solution. 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 |
Interesting, I have the opposite problem :) |
btw Rails 4 now directly supports extensions and it's dumped to the schema by default. I'm going to close this out as it's not really Apartment related anyway |
I ran into this with Rails 5.2. I'm not sure why The author of logidze helped me out with a PR in a minimal reproduction app: The files |
I believe you can create extensions yourself by adding the following to |
Hi guys
I'm not sure if this is specific for the apartment gem, but there seem to be a bug with dumping the hstore extension to structure.sql. I've followed the guidelines on how to setup hstore in an hstore-specific schema, but are having trouble preparing the test database. The problem is that structure.sql is missing
CREATE EXTENSION HSTORE SCHEMA hstore
. It does, however, contain the hstore schema and the table with the hstore column.Apartment configuration:
database.yml:
$ rake apartment:migrate
succeeds as usual in development.But,
$ rake db:structure:dump
only dumbs the hstore schema and table with hstore column, not the extension:Naturally, this causes
$ rake db:test:prepare
to fail.Is the setup guide in the readme incomplete? And how can I make the dump include the extension so that the test db can be prepared?
Thanks!
The text was updated successfully, but these errors were encountered: