From f906ef024ee39c31148edb49c6511f007735ce5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?U=C4=A3is=20Ozols?= Date: Fri, 23 Nov 2012 15:16:46 +0200 Subject: Squash migrations. This also makes sure tags and taggings tables doesn't exist before trying to create them. --- db/migrate/20110803223522_create_blog_structure.rb | 51 +++++++++++++++++----- .../20110803223523_add_user_id_to_blog_posts.rb | 7 --- ...20110803223524_acts_as_taggable_on_migration.rb | 26 ++++++----- db/migrate/20110803223526_add_cached_slugs.rb | 6 --- ...803223527_add_custom_url_field_to_blog_posts.rb | 5 --- ...223528_add_custom_teaser_field_to_blog_posts.rb | 6 --- ...803223529_add_primary_key_to_categorizations.rb | 14 ------ .../20120103055909_add_source_url_to_blog_posts.rb | 7 --- .../20120223022021_add_access_count_to_posts.rb | 8 ---- ...20227022021_add_slug_to_posts_and_categories.rb | 9 ---- .../20120530102901_create_blog_translations.rb | 17 -------- db/migrate/20120531113632_delete_cached_slugs.rb | 6 --- .../20120601151114_create_category_translations.rb | 14 ------ 13 files changed, 53 insertions(+), 123 deletions(-) delete mode 100644 db/migrate/20110803223523_add_user_id_to_blog_posts.rb delete mode 100644 db/migrate/20110803223526_add_cached_slugs.rb delete mode 100644 db/migrate/20110803223527_add_custom_url_field_to_blog_posts.rb delete mode 100644 db/migrate/20110803223528_add_custom_teaser_field_to_blog_posts.rb delete mode 100644 db/migrate/20110803223529_add_primary_key_to_categorizations.rb delete mode 100644 db/migrate/20120103055909_add_source_url_to_blog_posts.rb delete mode 100644 db/migrate/20120223022021_add_access_count_to_posts.rb delete mode 100644 db/migrate/20120227022021_add_slug_to_posts_and_categories.rb delete mode 100644 db/migrate/20120530102901_create_blog_translations.rb delete mode 100644 db/migrate/20120531113632_delete_cached_slugs.rb delete mode 100644 db/migrate/20120601151114_create_category_translations.rb (limited to 'db/migrate') diff --git a/db/migrate/20110803223522_create_blog_structure.rb b/db/migrate/20110803223522_create_blog_structure.rb index 010102f..a59b90f 100644 --- a/db/migrate/20110803223522_create_blog_structure.rb +++ b/db/migrate/20110803223522_create_blog_structure.rb @@ -1,17 +1,26 @@ class CreateBlogStructure < ActiveRecord::Migration def up - create_table Refinery::Blog::Post.table_name, :id => true do |t| + create_table :refinery_blog_posts do |t| t.string :title t.text :body t.boolean :draft t.datetime :published_at + t.integer :user_id + t.string :slug + t.string :custom_url + t.text :custom_teaser + t.string :source_url + t.string :source_url_title + t.integer :access_count, :default => 0 t.timestamps end - add_index Refinery::Blog::Post.table_name, :id + add_index :refinery_blog_posts, :id + add_index :refinery_blog_posts, :access_count + add_index :refinery_blog_posts, :slug - create_table Refinery::Blog::Comment.table_name, :id => true do |t| + create_table :refinery_blog_comments do |t| t.integer :blog_post_id t.boolean :spam t.string :name @@ -21,21 +30,36 @@ class CreateBlogStructure < ActiveRecord::Migration t.timestamps end - add_index Refinery::Blog::Comment.table_name, :id + add_index :refinery_blog_comments, :id - create_table Refinery::Blog::Category.table_name, :id => true do |t| + create_table :refinery_blog_categories do |t| t.string :title + t.string :slug t.timestamps end - add_index Refinery::Blog::Category.table_name, :id + add_index :refinery_blog_categories, :id + add_index :refinery_blog_categories, :slug - create_table Refinery::Categorization.table_name, :id => true do |t| + create_table :refinery_blog_categories_blog_posts do |t| + t.primary_key :id t.integer :blog_category_id t.integer :blog_post_id end - add_index Refinery::Categorization.table_name, [:blog_category_id, :blog_post_id], :name => 'index_blog_categories_blog_posts_on_bc_and_bp' + add_index :refinery_blog_categories_blog_posts, [:blog_category_id, :blog_post_id], :name => 'index_blog_categories_blog_posts_on_bc_and_bp' + + Refinery::Blog::Post.create_translation_table!({ + :body => :text, + :custom_teaser => :text, + :custom_url => :string, + :slug => :string, + :title => :string + }) + Refinery::Blog::Category.create_translation_table!({ + :title => :string, + :slug => :string + }) end def down @@ -43,10 +67,13 @@ class CreateBlogStructure < ActiveRecord::Migration Refinery::Page.delete_all({:link_url => "/blog"}) - drop_table Refinery::Blog::Post.table_name - drop_table Refinery::Blog::Comment.table_name - drop_table Refinery::Blog::Category.table_name - drop_table Refinery::Categorization.table_name + drop_table :refinery_blog_posts + drop_table :refinery_blog_comments + drop_table :refinery_blog_categories + drop_table :refinery_blog_categories_blog_posts + + Refinery::Blog::Post.drop_translation_table! + Refinery::Blog::Category.drop_translation_table! end end diff --git a/db/migrate/20110803223523_add_user_id_to_blog_posts.rb b/db/migrate/20110803223523_add_user_id_to_blog_posts.rb deleted file mode 100644 index 2fadb28..0000000 --- a/db/migrate/20110803223523_add_user_id_to_blog_posts.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddUserIdToBlogPosts < ActiveRecord::Migration - - def change - add_column Refinery::Blog::Post.table_name, :user_id, :integer - end - -end \ No newline at end of file diff --git a/db/migrate/20110803223524_acts_as_taggable_on_migration.rb b/db/migrate/20110803223524_acts_as_taggable_on_migration.rb index 812daf4..49a6ca2 100644 --- a/db/migrate/20110803223524_acts_as_taggable_on_migration.rb +++ b/db/migrate/20110803223524_acts_as_taggable_on_migration.rb @@ -2,23 +2,25 @@ class ActsAsTaggableOnMigration < ActiveRecord::Migration def up create_table :tags do |t| t.string :name - end + end unless table_exists?(:tags) - create_table :taggings do |t| - t.references :tag + unless table_exists?(:taggings) + create_table :taggings do |t| + t.references :tag - # You should make sure that the column created is - # long enough to store the required class names. - t.references :taggable, :polymorphic => true - t.references :tagger, :polymorphic => true + # You should make sure that the column created is + # long enough to store the required class names. + t.references :taggable, :polymorphic => true + t.references :tagger, :polymorphic => true - t.string :context + t.string :context - t.datetime :created_at - end + t.datetime :created_at + end - add_index :taggings, :tag_id - add_index :taggings, [:taggable_id, :taggable_type, :context] + add_index :taggings, :tag_id + add_index :taggings, [:taggable_id, :taggable_type, :context] + end end def down diff --git a/db/migrate/20110803223526_add_cached_slugs.rb b/db/migrate/20110803223526_add_cached_slugs.rb deleted file mode 100644 index 1024323..0000000 --- a/db/migrate/20110803223526_add_cached_slugs.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddCachedSlugs < ActiveRecord::Migration - def change - add_column Refinery::Blog::Category.table_name, :cached_slug, :string - add_column Refinery::Blog::Post.table_name, :cached_slug, :string - end -end diff --git a/db/migrate/20110803223527_add_custom_url_field_to_blog_posts.rb b/db/migrate/20110803223527_add_custom_url_field_to_blog_posts.rb deleted file mode 100644 index 7d3a225..0000000 --- a/db/migrate/20110803223527_add_custom_url_field_to_blog_posts.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddCustomUrlFieldToBlogPosts < ActiveRecord::Migration - def change - add_column Refinery::Blog::Post.table_name, :custom_url, :string - end -end diff --git a/db/migrate/20110803223528_add_custom_teaser_field_to_blog_posts.rb b/db/migrate/20110803223528_add_custom_teaser_field_to_blog_posts.rb deleted file mode 100644 index 895acb5..0000000 --- a/db/migrate/20110803223528_add_custom_teaser_field_to_blog_posts.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddCustomTeaserFieldToBlogPosts < ActiveRecord::Migration - def change - add_column Refinery::Blog::Post.table_name, :custom_teaser, :text - end -end - diff --git a/db/migrate/20110803223529_add_primary_key_to_categorizations.rb b/db/migrate/20110803223529_add_primary_key_to_categorizations.rb deleted file mode 100644 index 5bbfcf3..0000000 --- a/db/migrate/20110803223529_add_primary_key_to_categorizations.rb +++ /dev/null @@ -1,14 +0,0 @@ -class AddPrimaryKeyToCategorizations < ActiveRecord::Migration - def up - unless Refinery::Categorization.column_names.include?("id") - add_column Refinery::Categorization.table_name, :id, :primary_key - end - end - - def down - if Refinery::Categorization.column_names.include?("id") - remove_column Refinery::Categorization.table_name, :id - end - end -end - diff --git a/db/migrate/20120103055909_add_source_url_to_blog_posts.rb b/db/migrate/20120103055909_add_source_url_to_blog_posts.rb deleted file mode 100644 index cd6fd27..0000000 --- a/db/migrate/20120103055909_add_source_url_to_blog_posts.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddSourceUrlToBlogPosts < ActiveRecord::Migration - def change - add_column Refinery::Blog::Post.table_name, :source_url, :string - add_column Refinery::Blog::Post.table_name, :source_url_title, :string - - end -end diff --git a/db/migrate/20120223022021_add_access_count_to_posts.rb b/db/migrate/20120223022021_add_access_count_to_posts.rb deleted file mode 100644 index 02cd131..0000000 --- a/db/migrate/20120223022021_add_access_count_to_posts.rb +++ /dev/null @@ -1,8 +0,0 @@ -class AddAccessCountToPosts < ActiveRecord::Migration - def change - add_column Refinery::Blog::Post.table_name, :access_count, :integer, :default => 0 - - add_index Refinery::Blog::Post.table_name, :access_count - - end -end \ No newline at end of file diff --git a/db/migrate/20120227022021_add_slug_to_posts_and_categories.rb b/db/migrate/20120227022021_add_slug_to_posts_and_categories.rb deleted file mode 100644 index 87d1291..0000000 --- a/db/migrate/20120227022021_add_slug_to_posts_and_categories.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddSlugToPostsAndCategories < ActiveRecord::Migration - def change - add_column Refinery::Blog::Post.table_name, :slug, :string - add_index Refinery::Blog::Post.table_name, :slug - - add_column Refinery::Blog::Category.table_name, :slug, :string - add_index Refinery::Blog::Category.table_name, :slug - end -end \ No newline at end of file diff --git a/db/migrate/20120530102901_create_blog_translations.rb b/db/migrate/20120530102901_create_blog_translations.rb deleted file mode 100644 index c301f42..0000000 --- a/db/migrate/20120530102901_create_blog_translations.rb +++ /dev/null @@ -1,17 +0,0 @@ -class CreateBlogTranslations < ActiveRecord::Migration - def up - Refinery::Blog::Post.create_translation_table!({ - :body => :text, - :custom_teaser => :text, - :custom_url => :string, - :slug => :string, - :title => :string - }, { - :migrate_data => true - }) - end - - def down - Refinery::Blog::Post.drop_translation_table! :migrate_data => true - end -end diff --git a/db/migrate/20120531113632_delete_cached_slugs.rb b/db/migrate/20120531113632_delete_cached_slugs.rb deleted file mode 100644 index 14c8653..0000000 --- a/db/migrate/20120531113632_delete_cached_slugs.rb +++ /dev/null @@ -1,6 +0,0 @@ -class DeleteCachedSlugs < ActiveRecord::Migration - def change - remove_column Refinery::Blog::Category.table_name, :cached_slug - remove_column Refinery::Blog::Post.table_name, :cached_slug - end -end diff --git a/db/migrate/20120601151114_create_category_translations.rb b/db/migrate/20120601151114_create_category_translations.rb deleted file mode 100644 index a7cb956..0000000 --- a/db/migrate/20120601151114_create_category_translations.rb +++ /dev/null @@ -1,14 +0,0 @@ -class CreateCategoryTranslations < ActiveRecord::Migration - def up - Refinery::Blog::Category.create_translation_table!({ - :title => :string, - :slug => :string - }, { - :migrate_data => true - }) - end - - def down - Refinery::Blog::Category.drop_translation_table! :migrate_data => true - end -end -- cgit v1.2.3