Best practice for gems, which creates its own database

I have a gem that I want to be able to create my own database (and then, if necessary, migrate to this database). The driver uses ActiveRecord when reading and writing to the database. With the exception of embedding my gem in a non-maintenance Rails application just to get the necessary rake tasks, is there a best practice or way to increase the community for this? Attaching the entire Rails infrastructure to my small command line just to receive future updates seems to be too much overhead.

+4
source share
2 answers

You can use the standalone_migrations gem to manage your ActiveRecord environment outside of Rails: https://github.com/thuss/standalone-migrations . If you include your migrations or scheme in a gem package, your gem consumers can recreate the db structure from scratch. I agree with robbrit that SQLite is the easiest choice for a database.

+1
source

You can use DataMapper , which is a relatively lightweight ORM system (compared to ActiveRecord) combined with a SQLite database. You do not need to use Rails for this, DataMapper fits perfectly into a regular application, even something that is not based on a web interface.

+4
source

Source: https://habr.com/ru/post/1401704/


All Articles