GithubHelp home page GithubHelp logo

Comments (8)

timuckun avatar timuckun commented on June 13, 2024

I have upgraded postgres.app and still no joy. db:structure:dump does not create an entry for the hstore

from activerecord-postgres-hstore.

timuckun avatar timuckun commented on June 13, 2024

Could this be because the table and the extension were created inside of a schema?

from activerecord-postgres-hstore.

diogob avatar diogob commented on June 13, 2024

could you post the exact error message?

from activerecord-postgres-hstore.

danmelnick avatar danmelnick commented on June 13, 2024

Having the same issue here. It seems that something about db:test:prepare is overwriting the availability of the extension.

If I go into my test db and run:

CREATE EXTENSION hstore;

I can see it was created properly by running SELECT * FROM pg_available_extensions;

But if I rerun rake db:test:prepare, it blows up with a type "hstore" does not exist error.

Then if I go back into the test db, the extension is no longer active.

from activerecord-postgres-hstore.

danmelnick avatar danmelnick commented on June 13, 2024

Followup: for me, I think this is an issue with pg_dump not including extensions in the structure.sql. So when it loads that in for tests, the extension isn't there.

Since I'm using the activerecord-postgis-adapter which overrides the db:structure:dump task, I'm going to follow up there and see if there's something going on.

from activerecord-postgres-hstore.

timuckun avatar timuckun commented on June 13, 2024

Hi Everybody.

In my case this was because I had created the extension in a different schema. I changed my migration to read like this.

class SetupHstore < ActiveRecord::Migration
  @current_search_path =  Rails.configuration.database_configuration[Rails.env]['schema_search_path']
  def self.up

    execute " set search_path = public; CREATE EXTENSION IF NOT EXISTS hstore; set search_path= #{@current_search_path}"
  end

  def self.down
    execute "set search_path = public;DROP EXTENSION IF EXISTS hstore;set search_path= #{@current_search_path}"
  end
end

This seems to solve the problem for me.

from activerecord-postgres-hstore.

timuckun avatar timuckun commented on June 13, 2024

@diogob You may want to make sure the generator switches to the public schema before it creates the extension by default.

BTW the code I posted fails if there is no search path defined so it has to be made a little more robust.

from activerecord-postgres-hstore.

diogob avatar diogob commented on June 13, 2024

Thanks for the heads up, I'll use the SCHEMA clause in the CREATE EXTENSION.

from activerecord-postgres-hstore.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.