Spring isn't reloading when database is changed from SQLite to Postgress

Open
#507 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
38/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
postgresql, rails, ruby, sqlite
Domain
databases, tooling

Research direction

Start with the reported databases.yml change and reproduce it through rails console, comparing behavior before and after running spring stop. Check how Spring handles configuration changes while rails db:migrate and db:create still work. Done means changing from SQLite to PostgreSQL no longer leaves the console using the old connection, or the required reset behavior is clearly documented.

Written by the indexing model from the issue text.

Description

bug

So I'm working on my first rails 5 application. I got rails 5 installed, and then ran rails server to make sure everything was working correctly.

Then I started working on creating record. I changed databases.yml to point to postgress, created and ran migrations. Then jumped into rails console to create some records. Then I get the error that it can't find the tables.

I kinda bashed my head on this for a while. Until I tried Record.connection in the rails console to find out that it's trying to load these tables using SQLite.

Then I figured out what spring is, and how to reset it. I ran "spring stop" and tried creating the records again and it was now finally talking to postgress. So I'm guessing spring didn't notice the database change, and just kept on running thinking that SQLite was fine and dandy. Oddly enough rails db:migrate and db:create all worked fine.

Many novices might run into the same issue. And not knowing what spring is might make it a lot more difficult to get into rails. :/

Dominant language
Ruby
Stars
2.8k
Forks
342
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rails/spring

All issues in rails/spring

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.