KatanaCode/blogit

View on GitHub
lib/generators/templates/rename_blogit_tables.rb

Summary

Maintainability
A
0 mins
Test Coverage
class RenameBlogitTables < ActiveRecord::Migration
  def change
    if table_exists?('blog_posts')
      rename_table('blog_posts', 'blogit_posts') 
    else
      report_missing_table("blog_posts")
    end
    
    if table_exists?('blog_comments')
      rename_table('blog_comments', 'blogit_comments')
    else
      report_missing_table("blog_posts")
    end  
  end
  
  private
  
  def report_missing_table(t_name)
    warn "Table named: #{t_name} not found. Have you run the initial blogit migrations yet?"
  end
end