Created
January 26, 2016 20:31
-
-
Save jgn/0d59fb19ffe716a29819 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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