aboutsummaryrefslogtreecommitdiffstats
path: root/db
diff options
context:
space:
mode:
authorUģis Ozols <ugis.ozolss@gmail.com>2011-07-27 13:46:24 +0300
committerUģis Ozols <ugis.ozolss@gmail.com>2011-07-27 13:46:24 +0300
commit3fa8937b95a4d90000ad1be9c588424052136455 (patch)
tree07e61cd13bd88a76d13c3d759475d67d088d5f6e /db
parente5db679226bac7ef8ddd568c40f52addd52d7a8a (diff)
downloadrefinerycms-blog-3fa8937b95a4d90000ad1be9c588424052136455.tar.gz
refinerycms-blog-3fa8937b95a4d90000ad1be9c588424052136455.tar.bz2
refinerycms-blog-3fa8937b95a4d90000ad1be9c588424052136455.zip
Rails 3.1 - wip.
Diffstat (limited to 'db')
-rw-r--r--db/migrate/1_create_blog_structure.rb32
-rw-r--r--db/migrate/2_add_user_id_to_blog_posts.rb12
-rw-r--r--db/migrate/3_acts_as_taggable_on_migration.rb4
-rw-r--r--db/migrate/4_create_seo_meta_for_blog.rb4
-rw-r--r--db/migrate/5_add_cached_slugs.rb11
-rw-r--r--db/migrate/6_add_custom_url_field_to_blog_posts.rb8
-rw-r--r--db/migrate/7_add_custom_teaser_field_to_blog_posts.rb8
-rw-r--r--db/migrate/8_add_primary_key_to_categorizations.rb12
-rw-r--r--db/seeds/refinerycms_blog.rb12
9 files changed, 44 insertions, 59 deletions
diff --git a/db/migrate/1_create_blog_structure.rb b/db/migrate/1_create_blog_structure.rb
index a93d2d4..612584e 100644
--- a/db/migrate/1_create_blog_structure.rb
+++ b/db/migrate/1_create_blog_structure.rb
@@ -1,7 +1,7 @@
class CreateBlogStructure < ActiveRecord::Migration
- def self.up
- create_table :blog_posts, :id => true do |t|
+ def up
+ create_table Refinery::BlogPost.table_name, :id => true do |t|
t.string :title
t.text :body
t.boolean :draft
@@ -9,9 +9,9 @@ class CreateBlogStructure < ActiveRecord::Migration
t.timestamps
end
- add_index :blog_posts, :id
+ add_index Refinery::BlogPost.table_name, :id
- create_table :blog_comments, :id => true do |t|
+ create_table Refinery::BlogComment.table_name, :id => true do |t|
t.integer :blog_post_id
t.boolean :spam
t.string :name
@@ -21,34 +21,34 @@ class CreateBlogStructure < ActiveRecord::Migration
t.timestamps
end
- add_index :blog_comments, :id
+ add_index Refinery::BlogComment.table_name, :id
- create_table :blog_categories, :id => true do |t|
+ create_table Refinery::BlogCategory.table_name, :id => true do |t|
t.string :title
t.timestamps
end
- add_index :blog_categories, :id
+ add_index Refinery::BlogCategory.table_name, :id
- create_table :blog_categories_blog_posts, :id => true do |t|
+ create_table Refinery::Categorization.table_name, :id => true do |t|
t.integer :blog_category_id
t.integer :blog_post_id
end
- add_index :blog_categories_blog_posts, [:blog_category_id, :blog_post_id], :name => 'index_blog_categories_blog_posts_on_bc_and_bp'
+ add_index Refinery::Categorization.table_name, [:blog_category_id, :blog_post_id], :name => 'index_blog_categories_blog_posts_on_bc_and_bp'
load(Rails.root.join('db', 'seeds', 'refinerycms_blog.rb').to_s)
end
- def self.down
- UserPlugin.destroy_all({:name => "refinerycms_blog"})
+ def down
+ Refinery::UserPlugin.destroy_all({:name => "refinerycms_blog"})
- Page.delete_all({:link_url => "/blog"})
+ Refinery::Page.delete_all({:link_url => "/blog"})
- drop_table :blog_posts
- drop_table :blog_comments
- drop_table :blog_categories
- drop_table :blog_categories_blog_posts
+ drop_table Refinery::BlogPost.table_name
+ drop_table Refinery::BlogComment.table_name
+ drop_table Refinery::Category.table_name
+ drop_table Refinery::Categorization.table_name
end
end
diff --git a/db/migrate/2_add_user_id_to_blog_posts.rb b/db/migrate/2_add_user_id_to_blog_posts.rb
index cd62524..5be3224 100644
--- a/db/migrate/2_add_user_id_to_blog_posts.rb
+++ b/db/migrate/2_add_user_id_to_blog_posts.rb
@@ -1,11 +1,7 @@
class AddUserIdToBlogPosts < ActiveRecord::Migration
-
- def self.up
- add_column :blog_posts, :user_id, :integer
+
+ def change
+ add_column Refinery::BlogPost.table_name, :user_id, :integer
end
-
- def self.down
- remove_column :blog_posts, :user_id
- end
-
+
end \ No newline at end of file
diff --git a/db/migrate/3_acts_as_taggable_on_migration.rb b/db/migrate/3_acts_as_taggable_on_migration.rb
index 1661061..812daf4 100644
--- a/db/migrate/3_acts_as_taggable_on_migration.rb
+++ b/db/migrate/3_acts_as_taggable_on_migration.rb
@@ -1,5 +1,5 @@
class ActsAsTaggableOnMigration < ActiveRecord::Migration
- def self.up
+ def up
create_table :tags do |t|
t.string :name
end
@@ -21,7 +21,7 @@ class ActsAsTaggableOnMigration < ActiveRecord::Migration
add_index :taggings, [:taggable_id, :taggable_type, :context]
end
- def self.down
+ def down
drop_table :taggings
drop_table :tags
end
diff --git a/db/migrate/4_create_seo_meta_for_blog.rb b/db/migrate/4_create_seo_meta_for_blog.rb
index baf81a4..b1c3c31 100644
--- a/db/migrate/4_create_seo_meta_for_blog.rb
+++ b/db/migrate/4_create_seo_meta_for_blog.rb
@@ -1,6 +1,6 @@
class CreateSeoMetaForBlog < ActiveRecord::Migration
- def self.up
+ def up
unless ::SeoMetum.table_exists?
create_table ::SeoMetum.table_name do |t|
t.integer :seo_meta_id
@@ -18,7 +18,7 @@ class CreateSeoMetaForBlog < ActiveRecord::Migration
end
end
- def self.down
+ def down
# can't drop the table because someone else might be using it.
end
diff --git a/db/migrate/5_add_cached_slugs.rb b/db/migrate/5_add_cached_slugs.rb
index c189302..9e39586 100644
--- a/db/migrate/5_add_cached_slugs.rb
+++ b/db/migrate/5_add_cached_slugs.rb
@@ -1,11 +1,6 @@
class AddCachedSlugs < ActiveRecord::Migration
- def self.up
- add_column :blog_categories, :cached_slug, :string
- add_column :blog_posts, :cached_slug, :string
- end
-
- def self.down
- remove_column :blog_categories, :cached_slug
- remove_column :blog_posts, :cached_slug
+ def change
+ add_column Refinery::BlogCategory.table_name, :cached_slug, :string
+ add_column Refinery::BlogPost.table_name, :cached_slug, :string
end
end
diff --git a/db/migrate/6_add_custom_url_field_to_blog_posts.rb b/db/migrate/6_add_custom_url_field_to_blog_posts.rb
index 5a8901e..22b49a4 100644
--- a/db/migrate/6_add_custom_url_field_to_blog_posts.rb
+++ b/db/migrate/6_add_custom_url_field_to_blog_posts.rb
@@ -1,9 +1,5 @@
class AddCustomUrlFieldToBlogPosts < ActiveRecord::Migration
- def self.up
- add_column :blog_posts, :custom_url, :string
- end
-
- def self.down
- remove_column :blog_posts, :custom_url
+ def change
+ add_column Refinery::BlogPost.table_name, :custom_url, :string
end
end
diff --git a/db/migrate/7_add_custom_teaser_field_to_blog_posts.rb b/db/migrate/7_add_custom_teaser_field_to_blog_posts.rb
index daa4d04..9c50b97 100644
--- a/db/migrate/7_add_custom_teaser_field_to_blog_posts.rb
+++ b/db/migrate/7_add_custom_teaser_field_to_blog_posts.rb
@@ -1,10 +1,6 @@
class AddCustomTeaserFieldToBlogPosts < ActiveRecord::Migration
- def self.up
- add_column :blog_posts, :custom_teaser, :text
- end
-
- def self.down
- remove_column :blog_posts, :custom_teaser
+ def change
+ add_column Refinery::BlogPost.table_name, :custom_teaser, :text
end
end
diff --git a/db/migrate/8_add_primary_key_to_categorizations.rb b/db/migrate/8_add_primary_key_to_categorizations.rb
index efee289..5bbfcf3 100644
--- a/db/migrate/8_add_primary_key_to_categorizations.rb
+++ b/db/migrate/8_add_primary_key_to_categorizations.rb
@@ -1,12 +1,14 @@
class AddPrimaryKeyToCategorizations < ActiveRecord::Migration
- def self.up
- unless ::Categorization.column_names.include?("id")
- add_column :blog_categories_blog_posts, :id, :primary_key
+ def up
+ unless Refinery::Categorization.column_names.include?("id")
+ add_column Refinery::Categorization.table_name, :id, :primary_key
end
end
- def self.down
- remove_column :blog_categories_blog_posts, :id
+ def down
+ if Refinery::Categorization.column_names.include?("id")
+ remove_column Refinery::Categorization.table_name, :id
+ end
end
end
diff --git a/db/seeds/refinerycms_blog.rb b/db/seeds/refinerycms_blog.rb
index 0be2a06..19c4370 100644
--- a/db/seeds/refinerycms_blog.rb
+++ b/db/seeds/refinerycms_blog.rb
@@ -1,20 +1,20 @@
-::User.find(:all).each do |user|
+Refinery::User.find(:all).each do |user|
if user.plugins.where(:name => 'refinerycms_blog').blank?
user.plugins.create(:name => "refinerycms_blog",
:position => (user.plugins.maximum(:position) || -1) +1)
end
-end if defined?(::User)
+end if defined?(Refinery::User)
-if defined?(::Page)
- page = ::Page.create(
+if defined?(Refinery::Page)
+ page = Refinery::Page.create(
:title => "Blog",
:link_url => "/blog",
:deletable => false,
- :position => ((Page.maximum(:position, :conditions => {:parent_id => nil}) || -1)+1),
+ :position => ((Refinery::Page.maximum(:position, :conditions => {:parent_id => nil}) || -1)+1),
:menu_match => "^/blogs?(\/|\/.+?|)$"
)
- ::Page.default_parts.each do |default_page_part|
+ Refinery::Page.default_parts.each do |default_page_part|
page.parts.create(:title => default_page_part, :body => nil)
end
end \ No newline at end of file