Gem Version Build

static_db

Dump DB contents to YAML and load them back again. Aimed at SQLite. Committable to git.

Installation

⚠️ This gem modifies the Rails startup sequence. Don't use this gem unless you want to build a static site generator. This gem also creates and drops the DB for you.

Add it to your Rails project:

# Gemfile
gem "static_db"
# config/initializer/static_db.rb
StaticDb.configure do |config|
  # `content/data` is the default. You only need this initializer,
  # if you want a custom path.
  config.fixture_path = Rails.root.join("content", "data")
end

Usage

⚠️ Only use on Rails projects with SQLite. Have a valid db/schema.rb.

Start your app with bin/dev. You will notice that a DB gets created for you. It will be empty.

Create some records. Then, stop your server with Ctrl+C.

The DB contents will have been dumped to content/data.

Restart your server with bin/dev. Your SQLite DB will be dropped and recreated with all previously stored data from content/data.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/dunkelziffer/static_db.

License

The gem is available as open source under the terms of the MIT License.