Skip to content
lol_dba is a small package of rake tasks that scan your application models and displays a list of columns that probably should be indexed. Also, it can generate .sql migration scripts.
Ruby
Branch: master
Clone or download

Latest commit

dependabot Bump actionpack from 6.0.2.2 to 6.0.3.1 (#116)
Bumps [actionpack](https://github.com/rails/rails) from 6.0.2.2 to 6.0.3.1.
- [Release notes](https://github.com/rails/rails/releases)
- [Changelog](https://github.com/rails/rails/blob/v6.0.3.1/actionpack/CHANGELOG.md)
- [Commits](rails/rails@v6.0.2.2...v6.0.3.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Latest commit 5f9064c May 26, 2020

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin rubocop fixes May 2, 2018
gemfiles 2.2.0 Mar 29, 2020
lib 2.2.0 Mar 29, 2020
spec Add support for Rails 6 (#114) Mar 29, 2020
.codeclimate.yml Remove git.legal Mar 29, 2020
.gitignore adding simplecov May 1, 2018
.rspec small improvements Aug 8, 2018
.rubocop.yml removing ruby version from rubocop May 4, 2018
.travis.yml Add support for Rails 6 (#114) Mar 29, 2020
Appraisals Add support for Rails 6 (#114) Mar 29, 2020
Gemfile improving dependency spec Apr 3, 2019
Gemfile.lock Bump activesupport from 6.0.2.2 to 6.0.3.1 (#117) May 26, 2020
README.md Add support for Rails 6 (#114) Mar 29, 2020
Rakefile Add support for Rails 6 (#114) Mar 29, 2020
lol_dba.gemspec Add support for Rails 6 (#114) Mar 29, 2020

README.md

lol_dba travis Maintainability Test Coverage

lol_dba is a small package of rake tasks that scan your application models and displays a list of columns that probably should be indexed. Also, it can generate .sql migration scripts.

Quick example

To use lol_dba in the easiest way possible you have to do two things:

gem install lol_dba

Then run one of the following commands...

To display a migration for adding/removing all necessary indexes based on associations:

lol_dba db:find_indexes

To generate .sql files for your migrations inside db/migrate_sql folder:

lol_dba db:migrate_sql # defaults to all migrations
lol_dba db:migrate_sql[pending] # only pending migrations
lol_dba db:migrate_sql[20120221205526] # generate sql only for migration 20120221205526

Not-so-quick example

If you want to use lol_dba with rake, you should do a few more steps:

Add lol_dba to your Gemfile

gem "lol_dba"

Run the install command

bundle install

Use it the same way you use other rake commands

rake db:find_indexes
rake db:migrate_sql # defaults to all migrations
rake db:migrate_sql[pending] # only pending migrations
rake db:migrate_sql[20120221205526] # generate sql only for migration 20120221205526

Compatibility

Compatible with Ruby 2.x and Rails 3.x, 4.x, 5.x, and 6.x.

About primary_key

The primary key is always indexed. This is generally true for all storage engines that at all supports indexes.

For this reason, we no longer suggest to add indexes to primary keys.

Tests

To run lol_dba tests, just clone the repo and run:

bundle install && rake

Contributors

Most of the initial code came from rails_indexes and migration_sql_generator. Other people helped as well.

License

Lol DBA is released under the MIT license.

You can’t perform that action at this time.