Description
Squasher compresses old migrations in a Rails application. If you work on a big project with lots of migrations, every rake db:migrate might take a few seconds, or creating of a new database might take a few minutes. That's because Rails loads all those migration files. Squasher removes all the migrations and creates a single migration with the final database state of the specified date (the new migration will look like a schema).
Squasher alternatives and similar gems
Based on the "Database Tools" category.
Alternatively, view Squasher alternatives based on common mentions on social networks and blogs.
-
Database Cleaner
Strategies for cleaning databases in Ruby. Can be used to ensure a clean state for testing. -
Active Record Doctor
Identify database issues before they hit production. -
Lol DBA
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. -
Foreigner
Adds foreign key helpers to migrations and correctly dumps foreign keys to schema.rb -
Seed Fu
Advanced seed data handling for Rails, combining the best practices of several methods together. -
Seedbank
Seedbank gives your seed data a little structure. Create seeds for each environment, share seeds between environments and specify dependencies to load your seeds in order. All nicely integrated with simple rake tasks. -
DatabaseConsistency
The tool to avoid various issues due to inconsistencies and inefficiencies between a database schema and application models. -
SchemaPlus
SchemaPlus provides a collection of enhancements and extensions to ActiveRecord -
Polo
Polo travels through your database and creates sample snapshots so you can work with real world data in development. -
Upsert
Upsert on MySQL, PostgreSQL, and SQLite3. Transparently creates functions (UDF) for MySQL and PostgreSQL; on SQLite3, uses INSERT OR IGNORE. -
OnlineMigrations
Catch unsafe PostgreSQL migrations in development and run them easier in production (code helpers for table/column renaming, changing column type, adding columns with default, background migrations, etc). -
FastPage
Blazing fast pagination for ActiveRecord with deferred joins ⚡️ -
QueryTrack
Find time-consuming database queries for ActiveRecord-based Rails Apps -
Ruby Whatsapp SDK
A lightweight, efficient Ruby gem for interacting with Whatsapp Cloud API. -
Ruby PG Extras
Ruby PostgreSQL database performance insights. Locks, index usage, buffer cache hit ratios, vacuum stats and more. -
ocran
Turn ruby files into .exe files on windows (supported safe fork of ocran) -
PgDriveBackup
Simple solution to make encrypted with ccrypt PostgreSQL backups and storing on Google Drive API -
Perfect Shape
Perfect Shape is a collection of geometric algorithms that are mostly useful for GUI manipulation like checking containment of a point in popular geometric shapes such as rectangle, square, arc, circle, polygon, and paths containing lines, quadratic bézier curves, and cubic bezier curves. Also, some general math algorithms like IEEE-754 Remainder. -
Slack Smart Bot
Create a Slack bot that is smart and so easy to expand, create new bots on demand, run ruby code on chat, create shortcuts... The main scope of this gem is to be used internally in the company so teams can create team channels with their own bot to help them on their daily work, almost everything is suitable to be automated!! slack-smart-bot can create bots on demand, create shortcuts, run ruby code... just on a chat channel. You can access it just from your mobile phone if you want and run those tests you forgot to run, get the results, restart a server... no limits. -
ActiveRecord Setops
Union, Intersect, and Difference set operations for ActiveRecord (also, SQL's UnionAll). -
PgDice
Postgres partitioning built on top of https://github.com/ankane/pgslice -
ActiveRecord::DataIntegrity
Check data integrity for your ActiveRecord models -
Rapidity
Simple but fast Redis-backed distributed rate limiter. Allows you to specify time interval and count within to limit distributed operations. -
bundler-download
Bundler plugin for auto-downloading specified extra files after gem install -
PRY-BYETYPO 👋
A Pry plugin that captures exceptions that may arise from typos and deduces the correct command.
PopRuby: Clothing and Accessories for Ruby Developers
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of Squasher or a related project?
README
Squasher
Squasher compresses old ActiveRecord migrations. If you work on a big project with lots of migrations, every rake db:migrate
might take a few seconds, or creating of a new database might take a few minutes. That's because ActiveRecord loads all those migration files. Squasher removes all the migrations and creates a single migration with the final database state of the specified date (the new migration will look like a schema).
Attention
Prior to 0.6.2 squasher could damage your real data as generate "force" tables. Please upgrade to 0.6.2+ & manually clean "force" tag from the init migration
Installation
You don't have to add it into your Gemfile. Just a standalone installation:
$ gem install squasher
@note if you use Rbenv don't forget to run rbenv rehash
.
If you want to share it with your rails/sinatra/etc app add the below:
# Yep, the missing group in most Gemfiles where all utilities should be!
group :tools do
gem 'squasher', '>= 0.6.0'
gem 'capistrano'
gem 'rubocop'
end
Don't forget to run bundle
.
To integrate squasher
with your app even more do the below:
$ bundle binstub squasher
$ # and you have a runner inside the `bin` folder
$ bin/squasher
Usage
@note stop all preloading systems if there are present (spring, zeus, etc)
Suppose your application was created a few years ago. %app_root%/db/migrate
folder looks like this:
2012...._first_migration.rb
2012...._another_migration.rb
# and a lot of other files
2013...._adding_model_foo.rb
# few years later
2016...._removing_model_foo.rb
# and so on
Storing these atomic changes over time is painful and useless. It's time to archive this history. Once you install the gem you can run the squasher
command. For example, you want to compress all migrations which were created prior to the year 2017:
$ squasher 2017 # rails 3 & 4
$ squasher 2017 -m 5.0 # rails 5+
You can tell squasher
a more detailed date, for example:
$ squasher 2016/12 # prior to December 2016
$ squasher 2016/12/19 # prior to 19 December 2016
Options
Run squasher -h
or just squasher
to see how you can use squasher:
- in sql schema rails app
- in rails 5+ app
- inside an engine
- in "dry" mode
- in "reuse" mode
Requirements
It works and was tested on Ruby 2.0+ and ActiveRecord 3.1+. It also requires a valid development configuration in config/database.yml
.
If an old migration inserted data (created ActiveRecord model records) you will lose this code in the squashed migration, BUT squasher
will ask you to leave a tmp database which will have all data that was inserted while migrating. Using this database you could add that data as another migration, or into config/seed.rb
(the expected place for this stuff).
Changelog
All changes are located in [the changelog file](CHANGELOG.md) with contribution notes
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request