Skip to content

Instantly share code, notes, and snippets.

@jgn
Created January 26, 2016 20:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgn/0d59fb19ffe716a29819 to your computer and use it in GitHub Desktop.
Save jgn/0d59fb19ffe716a29819 to your computer and use it in GitHub Desktop.
require 'active_record'
spec = { adapter: :postgresql, database: :jgn }
ActiveRecord::Base.establish_connection(spec)
if ActiveRecord::Base.connection.table_exists?(:members)
ActiveRecord::Base.connection.drop_table :members
puts 'Dropped table'
end
# To get a feel for the methods like #create_table, see
# http://guides.rubyonrails.org/active_record_migrations.html
# http://guides.rubyonrails.org/active_record_migrations.html#creating-a-table
ActiveRecord::Base.connection.create_table :members do |table|
# :id is the default primary key, and is created automatically
table.string :first_name
table.string :last_name
table.string :type
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment