ActiveStorage with multiple DBs

Hello everyone!

we are looking into using packs/rails and packwerk gems to merge our two existing Rails app into a single app. Note, that this requires to use multiple databases - one for each app.

Everything works surprisingly well though, except ActiveStorage. We need to use a separate database and therefore separate ActiveStorage::Blob and ActiveStorage::Attachment models.

We were quite surprised to not find any built-in solutions in Rails for this kind of setup.

Existing discussion:

Note, that we would be able to re-implement our own upload/redirect/proxy controllers for our use cases. But, we need assistance/pointers how to handle the model layer.

Ideally, we would like to do has_one_attached :file, database: "secondary" or something similar.

Any help would be highly appreciated!