File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,11 +26,35 @@ Useful also with platforms like Heroku (due to their ephemeral file system).
2626- Change Active Storage service in * config/environments/development.rb* to: ` config.active_storage.service = :db `
2727- Add to * config/storage.yml* :
2828
29- ```
29+ ``` yml
3030db :
3131 service : DB
3232` ` `
3333
34+ If there is a need to support a separate database connection for storing the ` ActiveStorageDB` files:
35+
36+ 1. Add a separate database configuration for the environment (this one is just an example)
37+
38+ ` ` ` yml
39+ attachments:
40+ database: attachments
41+ pool: 5
42+ username: root
43+ migrations_paths: config/attachments_migrate
44+ ` ` `
45+
46+ 2. Create a separate initializer file in `config/initializera/active_storage_db.rb` to set the database :
47+
48+ ` ` ` rb
49+ # app/overrides/models/active_storage_db/application_record_override.rb
50+ ActiveStorageDB::ApplicationRecord.class_eval do
51+ connects_to database: { reading: :attachments, writing: :attachments }
52+ end
53+ ` ` `
54+
55+ 3. Move the `ActiveStorageDB` related migrations to a configured storage migrations path
56+ 4. Create the database and execute the migrations
57+
3458# # Misc
3559
3660Some utility tasks are available :
You can’t perform that action at this time.
0 commit comments