#check for column
ActiveRecord::Base.connection.tables.include?(name)
#check for table
Model.columns_hash.has_key("column_name")?
Tags:
migrations,
rails,
table
1 Comment »
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 source code version control system like Subversion or Sourcesafe. You need a more advanced revisioning system for databases… hence Rails Migrations.
Read the rest of this entry »
Tags:
activerecord,
database,
migrate,
migrations,
models,
rails,
Ruby,
ruby on rails,
script/console,
version control
1 Comment »