Git Product home page Git Product logo

Comments (2)

Envek avatar Envek commented on July 28, 2024

@jrweb247, hi!

This gem is not a standalone solution and aimed to be used with existing applications that are using ActiveRecord (Ruby on Rails or Sinatra or anything).


In case of Rails, this gem is intended to use an existing configuration of your application. So just configure your database.yml or specify DATABASE_URL environment variable.


If you want to use it as a standalone application, you can place exerything in single file like this:

#!/usr/bin/env ruby

require 'bundler/inline'

gemfile do
  source 'https://rubygems.org'
  gem 'activerecord'
  gem 'evil-seed'
  gem 'mysql2'
end

require 'tempfile'

class Category < ActiveRecord::Base
  has_many :translations, class_name: "Category::Translation"
end

class Category::Translation < ActiveRecord::Base
  belongs_to :category, inverse_of: :translations
end

EvilSeed.configure do |config|
  config.root("Category", "id < ?", 1000)
end

ActiveRecord::Base.establish_connection(ENV.fetch("DATABASE_URL"))

EvilSeed.dump(File.join(__dir__, "dump.sql").to_s)

And launch it like so:

DATABASE_URL=mysql2://user:pass@host/db ruby path/to/your/script.rb

Here you need to

  1. Describe your database layout with ActiveRecord models (see http://guides.rubyonrails.org/active_record_basics.html)
  2. Connect to your database (see http://guides.rubyonrails.org/configuring.html#configuring-a-database)
  3. Start dumping

from evil-seed.

Envek avatar Envek commented on July 28, 2024

@jrweb247, feel free to reopen this issue if you have any questions left.

from evil-seed.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.