Project

static_db

0.0
No release in over 3 years
Example description
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

>= 1.15
>= 13.0
>= 3.9

Runtime

>= 7.0
 Project Readme

Gem Version Build JRuby Build

static_db

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

Installation

WARNING: 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

Supported Ruby versions

  • Ruby (MRI) >= 3.2.0

Usage

Only use on Rails projects with SQLite. Have a valid db/schema.rb. For additional dramatic effect, do a rails db:drop.

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. Your SQLite DB will be gone.

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

Contributing

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

Credits

This gem is generated via newgem template by @palkan.

License

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