so that we can quickly switch the app between using the saas extension
and not. (Bundler will re-fetch the remote if the ref is not present.)
Also set the bundler config to auto-install missing dependencies.
ref: https://3.basecamp.com/2914079/buckets/37331921/messages/8422006338
The script takes advantage of the fact that we can bind to the
existing untenanted database by adding it explicitly (and temporarily)
as a readonly shard to the database.yml, and so in the script
with_original_db is connected to the original database.
storage/tenants/%{tenant}/ is now the root directory for all
state stored for a particular tenant, including active storage and the
database.
We leave the existing files and production database in place after the
migration, in case we need to roll back (by reverting the code and
config).
We also don't do a granular active storage blob copy, since the
attachments are mostly on Account (and not on Bubble). Instead we
hardlink the blobs on disk (so we don't take up additional space with
duplicates).
Finally, we're manually adding the kamal-proxy hosts to the deploy
file, so that we can generate letsencrypt certs for the
subdomains. This is only intended to be a short-term solution, we'll
want something like a wildcard cert before we go live.
That the ruby version is mostly shelling out is a hint that a shell language
might be a better choice. It's more direct, slightly faster, it sidesteps
chicken/egg problems when installing ruby, and writing things in bash is fun.
It's good to have an excuse to flex those shell muscles 💪