Skip to content
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

Unable to run db:migrate #14

Open
matthewblott opened this issue Apr 24, 2024 · 10 comments
Open

Unable to run db:migrate #14

matthewblott opened this issue Apr 24, 2024 · 10 comments

Comments

@matthewblott
Copy link

As the title says, I receive the following in the error log whenever I attempt to run db:migrate:

ActiveRecord::StatementInvalid: SQLite3::ReadOnlyException: attempt to write a readonly database 

My database.yml is setup as follows:

default: &default
  adapter: sqlite3
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  timeout: 5000

development:
  reader:
    <<: *default
    readonly: true
    database: storage/development.sqlite3
  writer:
    <<: *default
    pool: 1
    database: storage/development.sqlite3

The test and production databases are setup accordingly but have been left out for brevity. I was largely following the guide found here. Thanks in advance :-)

@fractaledmind
Copy link
Owner

Try swapping the order that you define the reader and writer pools. AR treats the first defined config as the default.

@matthewblott
Copy link
Author

@fractaledmind Yep, that seems to do the trick. You can close, thanks :-)

@wdiechmann
Copy link

hi Stephen - sent you an email - before I thought of going here

- my bad!

I'm on the activerecord-enhancedsqlite3-adapter-oid (not planning on going into rehab anytime soon) 😆

So - could I ask of you to do a 0.6.1 that does exactly that - flips the order - my migrations are 🤮 too

@fractaledmind
Copy link
Owner

I am traveling now, but pushed this commit from my phone: 4a25e0e

I will release a new version once I get settled. Thanks for reporting the bug

@wdiechmann
Copy link

wdiechmann commented Apr 25, 2024 via email

@wdiechmann
Copy link

oh - and btw - your "hot fix" - addressing the 'writer' in the CLI does not work - at least not 'with me at the wheel'

rails db:migrate:writer

@wdiechmann
Copy link

I removed the gem and "redid" my incantations ( bundle add activerecord-enhancedsqlite3-adapter) but my gem stayed at 0.6.0 and my rails db:migrate kept barfing -

- however, doing a bundle open x, patching the x's and o's by hand, closing everything and having a go at it again, says: all lights are blazing green
😄

so - I guess when all the traveling is a wrap - and your bandwidth is a tad bit more than a virtual keyboard on your Nokia 2110 you will inch the version minor and mint a fresh gem for the treasure troves to keep
😍

and a huge thank you again!

@wdiechmann
Copy link

hmm - this won't let go
💇

?1 bellis % rails db:rollback
bin/rails aborted!
You're using a multiple database application. To use `db:rollback` you must run the namespaced task with a VERSION. Available tasks are db:rollback:writer og db:rollback:reader.
Tasks: TOP => db:rollback
(See full trace by running task with --trace)
?1 bellis % rails db:rollback:writer
Unrecognized command "db:rollback:writer" (Rails::Command::UnrecognizedCommandError)
Did you mean?  db:rollback

(and it's with the config.enhanced_sqlite3.isolate_connection_pools = true )

I'll squelch my trompet for now and let you get back to the drawing board - give me a ping when/if you'd like me to take this for a spin
😃

@wdiechmann
Copy link

I'll squelch my trompet for now and let you get back to the drawing board - give me a ping when/if you'd like me to take this for a spin 😃

enough with the squelch -- it's a wrap! I must have smoked some bad sh** (rollbacks works flawless when addressing the writer) or what-not, in any case: the activerecord-enhanced_sqlite3_adapter is a win!

❤️

@mtimofiiv
Copy link

For those getting this issue - what fixed this for me was deleting the config/schema.rb file and re-running the migrations via bin/rails db:migrate:writer. Worked okay for my development and test dbs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants