Sha256: 247818b7d3a425b59118fced4a0fd724527856c60bc5153e3839f6d5338bb746

Contents?: true

Size: 525 Bytes

Versions: 6

Compression:

Stored size: 525 Bytes

Contents

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

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
blogit-1.1.2 lib/generators/templates/rename_blogit_tables.rb
blogit-admin-0.0.1 lib/generators/templates/rename_blogit_tables.rb
blogit-1.1.1 lib/generators/templates/rename_blogit_tables.rb
blogit-1.1.0 lib/generators/templates/rename_blogit_tables.rb
blogit-1.0.0 lib/generators/templates/rename_blogit_tables.rb
blogit-1.0.0.rc1 lib/generators/templates/rename_blogit_tables.rb