Skip to content

Instantly share code, notes, and snippets.

@npassaro
Last active December 19, 2015 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save npassaro/307a23f40287482a5275 to your computer and use it in GitHub Desktop.
Save npassaro/307a23f40287482a5275 to your computer and use it in GitHub Desktop.
How to use activerecord standalone
require 'active_record'
require 'sqlite3'
require 'logger'
ActiveRecord::Base.logger = Logger.new('debug.log')
ActiveRecord::Base.configurations = YAML::load(IO.read('database.yml'))
ActiveRecord::Base.establish_connection('development')
class Schema < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :name
t.string :state
end
add_index :users, :name
end
end
Schema.new.change
class User < ActiveRecord::Base
end
######################
# database.yml:
######################
development:
adapter: sqlite3
database: db/data.sqlite3
pool: 5
timeout: 5000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment