fractaledmind / activerecord-enhancedsqlite3-adapter

ActiveRecord adapter for SQLite that enhances the default. Back-ports generated column support, deferred foreign key support, custom foreign key support, improved default configuration, and adds support for pragma tuning and extension loading
MIT License
123 stars 4 forks source link

Unable to run db:migrate #14

Open matthewblott opened 4 months ago

matthewblott commented 4 months ago

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 commented 4 months ago

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

matthewblott commented 4 months ago

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

wdiechmann commented 4 months ago

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 commented 4 months ago

I am traveling now, but pushed this commit from my phone: https://github.com/fractaledmind/activerecord-enhancedsqlite3-adapter/commit/4a25e0e8f930e3dd69648fa7b17715a99a782f45

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

wdiechmann commented 4 months ago

Impressive! (Like the implementations)

Thx a bunch, Walther

Den 25. apr. 2024 kl. 12.18 skrev Stephen Margheim @.***>:

I am traveling now, but pushed this commit from my phone: 4a25e0e https://github.com/fractaledmind/activerecord-enhancedsqlite3-adapter/commit/4a25e0e8f930e3dd69648fa7b17715a99a782f45 I will release a new version once I get settled. Thanks for reporting the bug

— Reply to this email directly, view it on GitHub https://github.com/fractaledmind/activerecord-enhancedsqlite3-adapter/issues/14#issuecomment-2076848195, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABPFXOWBUNPA5JNUL65WX3Y7DKBHAVCNFSM6AAAAABGXLGJA6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANZWHA2DQMJZGU. You are receiving this because you commented.

wdiechmann commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

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 commented 3 months ago

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!

❤️