You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This gem only implements the bare minimum database rake tasks to get started:
db:migrate (implicit create)
db:drop
linking of everything to db:prepare
There are many more rake tasks that this gem will need to implement. This issue is meant to track the overall work, since I imagine the list will not get completed in a single PR (and may never get completed, let's be honest).
An open question for me is whether Rails could be presenting rake tasks so that gems can more easily override them. I've got a branch (TODO) that wraps up the tasks in this gem in PORO, and that's a pattern that I think might be more easily extensible if it was adopted upstream.
Here are the full set of database rake tasks implemented by Rails as of ~v8.0, along with some notes on how they're implemented and my thoughts on whether we need to implement it or not.
[~] db:_dump
forwards to "db:schema:dump"
[~] db:_dump:__dbname__
created by ActiveRecord::Tasks::DatabaseTasks.for_each(databases)
forwards to "db:schema:dump:dbname"
db:abort_if_pending_migrations
uses DatabaseTasks.with_temporary_pool_for_each to iterate over db configs
db:abort_if_pending_migrations:__dbname__
created by ActiveRecord::Tasks::DatabaseTasks.for_each(databases)
implemented with ActiveRecord::Tasks::DatabaseTasks.with_temporary_pool_for_each(env: Rails.env, name: name)
db:charset
only seems to work against "primary"
error caused by nil returned from configs_for(env_name: env_name, name: db_name)
maybe we don't need to support this immediately?
db:check_protected_environments
loops over configs_for(env_name: environment)
we probably do not want or need to check all of the tenant databases. maybe check just the first tenant?
db:collation
only seems to work against "primary"
error caused by nil returned from configs_for(env_name: env_name, name: db_name)
maybe we don't need to support this immediately?
db:create
forwards to ActiveRecord::Tasks::DatabaseTasks.create_current
db:create:all
forwards to ActiveRecord::Tasks::DatabaseTasks.create_all
db:create:__dbname__
created by ActiveRecord::Tasks::DatabaseTasks.for_each(databases)
implemented with ActiveRecord::Base.configurations.configs_for(env_name: Rails.env, name: name)
db:drop
forwards to "db:drop:_unsafe"
db:drop:_unsafe
forwards to ActiveRecord::Tasks::DatabaseTasks.drop_current
db:drop:all
forwards to ActiveRecord::Tasks::DatabaseTasks.drop_all
db:drop:__dbname__
created by ActiveRecord::Tasks::DatabaseTasks.for_each(databases)
implemented with ActiveRecord::Base.configurations.configs_for(env_name: Rails.env, name: name)
[~] db:encryption:init
orthogonal to tenanting
db:environment:set
uses ActiveRecord::Tasks::DatabaseTasks.migration_connection_pool which raises NoTenantError if tenanted is primary
[~] db:fixtures:identify
orthogonal to tenanting
db:fixtures:load
I think the current behavior is the desired behavior: use ARTENANT (fallback to default tenant) as the target database
This gem only implements the bare minimum database rake tasks to get started:
There are many more rake tasks that this gem will need to implement. This issue is meant to track the overall work, since I imagine the list will not get completed in a single PR (and may never get completed, let's be honest).
An open question for me is whether Rails could be presenting rake tasks so that gems can more easily override them. I've got a branch (TODO) that wraps up the tasks in this gem in PORO, and that's a pattern that I think might be more easily extensible if it was adopted upstream.
Here are the full set of database rake tasks implemented by Rails as of ~v8.0, along with some notes on how they're implemented and my thoughts on whether we need to implement it or not.
db:_dumpdb:_dump:__dbname__db:abort_if_pending_migrationsdb:abort_if_pending_migrations:__dbname__db:charsetdb:check_protected_environmentsdb:collationdb:createdb:create:alldb:create:__dbname__db:dropdb:drop:_unsafedb:drop:alldb:drop:__dbname__db:encryption:initdb:environment:setdb:fixtures:identifydb:fixtures:loaddb:forwardwith support for STEPdb:load_configdb:migratewith support for VERSION and SCOPEdb:migrate:downwith support for VERSIONdb:migrate:down:__dbname__db:migrate:__dbname__db:migrate:redowith support for STEP and VERSIONdb:migrate:redo:__dbname__db:migrate:resetdb:migrate:statusdb:migrate:status:__dbname__db:migrate:upwith support for VERSIONdb:migrate:up:__dbname__db:preparedb:purge(see Known Issues below)db:purge:all(see Known Issues below)db:resetdb:reset:alldb:reset:__dbname__db:rollbackwith support for STEPdb:rollback:__dbname__db:schema:cache:cleardb:schema:cache:dumpdb:schema:dumpdb:schema:dump:__dbname__db:schema:loaddb:schema:load:__dbname__db:seeddb:seed:replantdb:setupdb:setup:alldb:setup:__dbname__db:test:load_schemadb:test:load_schema:__dbname__db:test:preparedb:test:prepare:__dbname__db:test:purgedb:test:purge:__dbname__db:truncate_alldb:versiondb:version:__dbname__