Skip to content

Use ActiveRecord::Tasks::DatabaseTasks directly in geo rake tasks

What does this MR do?

Instead of relying on the db: tasks, implement them our self using ActiveRecord::Tasks::DatabaseTasks.

Basically this is mostly copied from activerecord/lib/active_record/railties/databases.rake.

Why was this MR needed?

To make the rake geo:db:migrate on a secondary (from Omnibus) work again.

Screenshots

❯ be rake -T | grep geo
rake geo:db:create                                            # Creates the Geo tracking database from config/database_geo.yml for the current RAILS_ENV
rake geo:db:drop                                              # Drops the Geo tracking database from config/database_geo.yml for the current RAILS_ENV
rake geo:db:migrate                                           # Migrate the Geo tracking database (options: VERSION=x, VERBOSE=false, SCOPE=blog)
rake geo:db:migrate:down                                      # Runs the "down" for a given migration VERSION
rake geo:db:migrate:redo                                      # Rollbacks the database one migration and re migrate up (options: STEP=x, VERSION=x)
rake geo:db:migrate:status                                    # Display status of migrations
rake geo:db:migrate:up                                        # Runs the "up" for a given migration VERSION
rake geo:db:reset                                             # Drops and recreates the database from db/geo/schema.rb for the current environment and loads the seeds
rake geo:db:rollback                                          # Rolls the schema back to the previous version (specify steps w/ STEP=n)
rake geo:db:schema:dump                                       # Create a db/geo/schema.rb file that is portable against any DB supported by AR
rake geo:db:schema:load                                       # Load a schema.rb file into the database
rake geo:db:seed                                              # Load the seed data from db/geo/seeds.rb
rake geo:db:setup                                             # Create the Geo tracking database, load the schema, and initialize with the seed data
rake geo:db:show_encryption_key                               # Display database encryption key
rake geo:db:test:prepare                                      # Check for pending migrations and load the test schema
rake geo:db:version                                           # Retrieves the current schema version number
rake geo:set_primary_node                                     # Make this node the Geo primary

Does this MR meet the acceptance criteria?

What are the relevant issue numbers?

gitlab-org/gitlab-ee#3543

Edited by Toon Claes

Merge request reports