aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUģis Ozols <ugis@ugisozols.com>2013-07-13 13:41:41 -0700
committerUģis Ozols <ugis@ugisozols.com>2013-07-13 13:41:41 -0700
commit48950c119297dc6c99edfe8d1c99eb7a77dc9496 (patch)
tree742dab40d319fea3d0909bce9f56ad36be98ead3
parent6c14fbc20c8dece121b7569b7a5a0bd3c497fd57 (diff)
parentccd0f3b7ec1d47dcce017389087ac6d20f709f93 (diff)
downloadrefinerycms-blog-48950c119297dc6c99edfe8d1c99eb7a77dc9496.tar.gz
refinerycms-blog-48950c119297dc6c99edfe8d1c99eb7a77dc9496.tar.bz2
refinerycms-blog-48950c119297dc6c99edfe8d1c99eb7a77dc9496.zip
Merge pull request #339 from refinery/revert_f906ef024ee39c31148edb49c6511f007735ce5a
Revert f906ef0 but maintain table name improvements
-rw-r--r--db/migrate/20110803223522_create_blog_structure.rb39
-rw-r--r--db/migrate/20110803223523_add_user_id_to_blog_posts.rb7
-rw-r--r--db/migrate/20110803223524_acts_as_taggable_on_migration.rb26
-rw-r--r--db/migrate/20110803223526_add_cached_slugs.rb6
-rw-r--r--db/migrate/20110803223527_add_custom_url_field_to_blog_posts.rb5
-rw-r--r--db/migrate/20110803223528_add_custom_teaser_field_to_blog_posts.rb6
-rw-r--r--db/migrate/20110803223529_add_primary_key_to_categorizations.rb14
-rw-r--r--db/migrate/20120103055909_add_source_url_to_blog_posts.rb7
-rw-r--r--db/migrate/20120223022021_add_access_count_to_posts.rb8
-rw-r--r--db/migrate/20120227022021_add_slug_to_posts_and_categories.rb9
-rw-r--r--db/migrate/20120530102901_create_blog_translations.rb17
-rw-r--r--db/migrate/20120531113632_delete_cached_slugs.rb6
-rw-r--r--db/migrate/20120601151114_create_category_translations.rb14
13 files changed, 117 insertions, 47 deletions
diff --git a/db/migrate/20110803223522_create_blog_structure.rb b/db/migrate/20110803223522_create_blog_structure.rb
index 3be7eee..37f4bd7 100644
--- a/db/migrate/20110803223522_create_blog_structure.rb
+++ b/db/migrate/20110803223522_create_blog_structure.rb
@@ -1,26 +1,17 @@
class CreateBlogStructure < ActiveRecord::Migration
def up
- create_table :refinery_blog_posts do |t|
+ create_table :refinery_blog_posts, :id => true 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_posts, :id
- add_index :refinery_blog_posts, :access_count
- add_index :refinery_blog_posts, :slug
- create_table :refinery_blog_comments do |t|
+ create_table :refinery_blog_comments, :id => true do |t|
t.integer :blog_post_id
t.boolean :spam
t.string :name
@@ -33,48 +24,30 @@ class CreateBlogStructure < ActiveRecord::Migration
add_index :refinery_blog_comments, :id
add_index :refinery_blog_comments, :blog_post_id
- create_table :refinery_blog_categories do |t|
+ create_table :refinery_blog_categories, :id => true do |t|
t.string :title
- t.string :slug
t.timestamps
end
add_index :refinery_blog_categories, :id
- add_index :refinery_blog_categories, :slug
- create_table :refinery_blog_categories_blog_posts do |t|
- t.primary_key :id
+ create_table :refinery_blog_categories_blog_posts, :id => true do |t|
t.integer :blog_category_id
t.integer :blog_post_id
end
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
- Refinery::UserPlugin.destroy_all({:name => "refinerycms_blog"})
+ Refinery::UserPlugin.destroy_all({:name => "refinerycms_blog"}) if defined?(Refinery::UserPlugin)
- Refinery::Page.delete_all({:link_url => "/blog"})
+ Refinery::Page.delete_all({:link_url => "/blog"}) if defined?(Refinery::Page)
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
new file mode 100644
index 0000000..94980b3
--- /dev/null
+++ b/db/migrate/20110803223523_add_user_id_to_blog_posts.rb
@@ -0,0 +1,7 @@
+class AddUserIdToBlogPosts < ActiveRecord::Migration
+
+ def change
+ add_column :refinery_blog_posts, :user_id, :integer
+ end
+
+end
diff --git a/db/migrate/20110803223524_acts_as_taggable_on_migration.rb b/db/migrate/20110803223524_acts_as_taggable_on_migration.rb
index 49a6ca2..812daf4 100644
--- a/db/migrate/20110803223524_acts_as_taggable_on_migration.rb
+++ b/db/migrate/20110803223524_acts_as_taggable_on_migration.rb
@@ -2,25 +2,23 @@ class ActsAsTaggableOnMigration < ActiveRecord::Migration
def up
create_table :tags do |t|
t.string :name
- end unless table_exists?(:tags)
-
- unless table_exists?(:taggings)
- create_table :taggings do |t|
- t.references :tag
+ end
- # 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
+ create_table :taggings do |t|
+ t.references :tag
- t.string :context
+ # 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.datetime :created_at
- end
+ t.string :context
- add_index :taggings, :tag_id
- add_index :taggings, [:taggable_id, :taggable_type, :context]
+ t.datetime :created_at
end
+
+ add_index :taggings, :tag_id
+ add_index :taggings, [:taggable_id, :taggable_type, :context]
end
def down
diff --git a/db/migrate/20110803223526_add_cached_slugs.rb b/db/migrate/20110803223526_add_cached_slugs.rb
new file mode 100644
index 0000000..389f83e
--- /dev/null
+++ b/db/migrate/20110803223526_add_cached_slugs.rb
@@ -0,0 +1,6 @@
+class AddCachedSlugs < ActiveRecord::Migration
+ def change
+ add_column :refinery_blog_categories, :cached_slug, :string
+ add_column :refinery_blog_posts, :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
new file mode 100644
index 0000000..518bbb8
--- /dev/null
+++ b/db/migrate/20110803223527_add_custom_url_field_to_blog_posts.rb
@@ -0,0 +1,5 @@
+class AddCustomUrlFieldToBlogPosts < ActiveRecord::Migration
+ def change
+ add_column :refinery_blog_posts, :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
new file mode 100644
index 0000000..86d787d
--- /dev/null
+++ b/db/migrate/20110803223528_add_custom_teaser_field_to_blog_posts.rb
@@ -0,0 +1,6 @@
+class AddCustomTeaserFieldToBlogPosts < ActiveRecord::Migration
+ def change
+ add_column :refinery_blog_posts, :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
new file mode 100644
index 0000000..dcf1493
--- /dev/null
+++ b/db/migrate/20110803223529_add_primary_key_to_categorizations.rb
@@ -0,0 +1,14 @@
+class AddPrimaryKeyToCategorizations < ActiveRecord::Migration
+ def up
+ unless Refinery::Blog::Categorization.column_names.include?("id")
+ add_column Refinery::Blog::Categorization.table_name, :id, :primary_key
+ end
+ end
+
+ def down
+ if Refinery::Blog::Categorization.column_names.include?("id")
+ remove_column Refinery::Blog::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
new file mode 100644
index 0000000..cd6fd27
--- /dev/null
+++ b/db/migrate/20120103055909_add_source_url_to_blog_posts.rb
@@ -0,0 +1,7 @@
+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
new file mode 100644
index 0000000..02cd131
--- /dev/null
+++ b/db/migrate/20120223022021_add_access_count_to_posts.rb
@@ -0,0 +1,8 @@
+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
new file mode 100644
index 0000000..87d1291
--- /dev/null
+++ b/db/migrate/20120227022021_add_slug_to_posts_and_categories.rb
@@ -0,0 +1,9 @@
+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
new file mode 100644
index 0000000..c301f42
--- /dev/null
+++ b/db/migrate/20120530102901_create_blog_translations.rb
@@ -0,0 +1,17 @@
+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
new file mode 100644
index 0000000..14c8653
--- /dev/null
+++ b/db/migrate/20120531113632_delete_cached_slugs.rb
@@ -0,0 +1,6 @@
+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
new file mode 100644
index 0000000..a7cb956
--- /dev/null
+++ b/db/migrate/20120601151114_create_category_translations.rb
@@ -0,0 +1,14 @@
+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