Check if table and columns exist to use in Rails migrations
ruby #check for column ActiveRecord::Base.connection.tables.include?(name) #check for table Model.columns_hash.has_key("column_name")?
ruby #check for column ActiveRecord::Base.connection.tables.include?(name) #check for table Model.columns_hash.has_key("column_name")?
Migrations as version control for databases When I first learned about Rails migration, I immediately thought that dropping down a revision would be something you would do often. In actuality, Rails migrations is more like a version control for databases. Since databases changes require modifications to both code and data, you cannot simply use a…