Rails migrations are an extremely handy way of capturing changes to your database and rolling them back if they are incorrect. Manipulating or querying a database is a pretty useful tool and ActiveRecord turns your tables into objects so I looked into how to access these features outside of a Rails environment. I wanted to be able to either specify the database connection details directly in the script if I was running it outside of a Rails application, or to be able to bind into the Rails application's database.yml database configuration file. To run it as a standalone script with the database details described inside the script run: ruby play_with_the_database.rb To run it within the context of a Rails application place the script inside a new directory called db/script and run: ruby play_with_the_database.rb development If you want to run the above script against the production database run: ruby play_with_the_database.rb production I'll show you the ruby code that I came
eng mgr / leader / full stack / java / agile / tdd / security / aws / go