Comments (2)
@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
- Describe your database layout with ActiveRecord models (see http://guides.rubyonrails.org/active_record_basics.html)
- Connect to your database (see http://guides.rubyonrails.org/configuring.html#configuring-a-database)
- Start dumping
from evil-seed.
@jrweb247, feel free to reopen this issue if you have any questions left.
from evil-seed.
Related Issues (11)
- Ignoring columns or avoiding errors HOT 5
- Foreign key nullification HOT 3
- What would be the best way to anonymize specific attributes in a JSONB column HOT 3
- Ignore generated columns HOT 2
- Model with ActiveStorage attachment can't be anonymized HOT 3
- Errno::EMFILE: Too many open files @ rb_sysopen
- Recursive execution? HOT 4
- Rails 4.2.x and jruby compatibility HOT 5
- Invalid SQL order by clause from root model configuration HOT 1
- Excluding tables HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from evil-seed.