All Projects → jalkoby → Squasher

jalkoby / Squasher

Licence: mit
Squasher - squash your old migrations in a single command

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Squasher

Schemaspy
SchemaSpy code home
Stars: ✭ 2,027 (+60.87%)
Mutual labels:  schema, database
Schemazen
Script and create SQL Server objects quickly
Stars: ✭ 273 (-78.33%)
Mutual labels:  schema, database
Trilogy
TypeScript SQLite layer with support for both native C++ & pure JavaScript drivers.
Stars: ✭ 195 (-84.52%)
Mutual labels:  schema, database
Scaffolder
Database scaffolding tool
Stars: ✭ 102 (-91.9%)
Mutual labels:  schema, database
Eralchemy
Entity Relation Diagrams generation tool
Stars: ✭ 767 (-39.13%)
Mutual labels:  schema, database
Goose
A database migration tool. Supports SQL migrations and Go functions.
Stars: ✭ 2,112 (+67.62%)
Mutual labels:  schema, database
Scenic
Scenic is maintained by Derek Prior, Caleb Hearth, and you, our contributors.
Stars: ✭ 2,856 (+126.67%)
Mutual labels:  schema, database
Postguard
🐛 Statically validate Postgres SQL queries in JS / TS code and derive schemas.
Stars: ✭ 104 (-91.75%)
Mutual labels:  schema, database
Sleekdb
Pure PHP NoSQL database with no dependency. Flat file, JSON based document database.
Stars: ✭ 450 (-64.29%)
Mutual labels:  schema, database
Localtower
Manage your Ruby On Rails models, relations, and migrations from a simple UI.
Stars: ✭ 401 (-68.17%)
Mutual labels:  schema, database
Mongoke
Instant Graphql for MongoDb (active branch is golang, rewrite in process)
Stars: ✭ 203 (-83.89%)
Mutual labels:  schema, database
Squid
🦑 Provides SQL tagged template strings and schema definition functions.
Stars: ✭ 57 (-95.48%)
Mutual labels:  schema, database
Pgquarrel
pgquarrel compares PostgreSQL database schemas (DDL)
Stars: ✭ 274 (-78.25%)
Mutual labels:  schema, database
Mithril Data
A rich data model library for Mithril javascript framework
Stars: ✭ 17 (-98.65%)
Mutual labels:  schema, database
Neo4j Graphql
An optimized neo4j query resolver for Facebook's GraphQL
Stars: ✭ 60 (-95.24%)
Mutual labels:  schema, database
Mongoose Patch History
Mongoose plugin that saves a history of JSON patch operations for all documents belonging to a schema in an associated 'patches' collection
Stars: ✭ 82 (-93.49%)
Mutual labels:  schema
System Runtime
A JavaScript library that runs systems
Stars: ✭ 83 (-93.41%)
Mutual labels:  schema
Cs Books
超过1000本的计算机经典书籍、个人笔记资料以及本人在各平台发表文章中所涉及的资源等。书籍资源包括C/C++、Java、Python、Go语言、数据结构与算法、操作系统、后端架构、计算机系统知识、数据库、计算机网络、设计模式、前端、汇编以及校招社招各种面经~
Stars: ✭ 1,215 (-3.57%)
Mutual labels:  database
Cloudfail
Utilize misconfigured DNS and old database records to find hidden IP's behind the CloudFlare network
Stars: ✭ 1,239 (-1.67%)
Mutual labels:  database
Ngx Indexed Db
A service that wraps IndexedDB database in an Angular service. It exposes very simple observables API to enable the usage of IndexedDB without most of it plumbing.
Stars: ✭ 84 (-93.33%)
Mutual labels:  schema

Squasher

Build Status Code Climate Gem Version

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 with contribution notes

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].