skip to Main Content

As the title says, I clones a rails API. I tried to follow the steps in this article from point 2 onwards https://dev.to/w3ndo/a-checklist-for-setting-up-a-cloned-rails-application-locally-5468 but I keep getting the same error from db:setup onwards.

enter image description here

Please help!

I have tried googling the answer and phoning a friend.

I have tried rails db:setup, rails db:seed, rails db:create, rails db:migrate.

Update: So I found I was getting this error because the db owner was listed as the original owner in the repo but when I typed psql in terminal and located the db, the owner was listed as me.

I was able to change this using PGadmin 4 and type in the original owner as the db owner.

3

Answers


  1. Chosen as BEST ANSWER

    Update

    Thank you for the help. I was able to find out as my partner had created the backend, the issue was arising because the owners of the database didn't match when I cloned his repo.


  2. You want to initialize the postgres db, which doesn’t quite come for free. I recommend using sqlite3 until you need a production db. If the clone calls for PG, then:

    1. (user) $ sudo su - postgres
    2. (postgres) $ createuser --interactive
    3. (local) $ sudo systemctl restart postgresql
    4. (local) $ bundle exec rails db:create:all

    $ pg_isready tells you at a glance if posgtres server/cluster is online.

    $ pg_isready
    /tmp:5432 - accepting connections
    

    If it gets frustrating, change the config/database.yml to the default version, remove pg gem if possible, add sqlite3. Then simple rake db:migrate after creating or adding an [environment].sqlite3 file to db/

    #   gem install sqlite3
    #
    #   Ensure the SQLite 3 gem is defined in your Gemfile
    #   gem 'sqlite3'
    #
    default: &default
      adapter: sqlite3
      pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
      timeout: 5000
    
    development:
      <<: *default
      database: db/development.sqlite3
    
    # Warning: The database defined as "test" will be erased and
    # re-generated from your development database when you run "rake".
    # Do not set this db to the same as development or production.
    test:
      <<: *default
      database: db/test.sqlite3
    
    production:
      <<: *default
      database: db/production.sqlite3
    
    
    
    
    Login or Signup to reply.
  3. So I found I was getting this error because the db owner was listed as the original owner in the repo but when I typed psql in terminal and located the db, the owner was listed as me.

    I was able to change this using PGadmin 4 and type in the original owner as the db owner.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search