diff options
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/1_create_blog_structure.rb | 54 | ||||
-rw-r--r-- | db/migrate/2_add_user_id_to_blog_posts.rb | 11 | ||||
-rw-r--r-- | db/migrate/3_acts_as_taggable_on_migration.rb | 28 | ||||
-rw-r--r-- | db/seeds/refinerycms_blog.rb | 16 |
4 files changed, 109 insertions, 0 deletions
diff --git a/db/migrate/1_create_blog_structure.rb b/db/migrate/1_create_blog_structure.rb new file mode 100644 index 0000000..197efb1 --- /dev/null +++ b/db/migrate/1_create_blog_structure.rb @@ -0,0 +1,54 @@ +class CreateBlogStructure < ActiveRecord::Migration + + def self.up + create_table :blog_posts, :id => true do |t| + t.string :title + t.text :body + t.boolean :draft + t.datetime :published_at + t.timestamps + end + + add_index :blog_posts, :id + + create_table :blog_comments, :id => true do |t| + t.integer :blog_post_id + t.boolean :spam + t.string :name + t.string :email + t.text :body + t.string :state + t.timestamps + end + + add_index :blog_comments, :id + + create_table :blog_categories, :id => true do |t| + t.string :title + t.timestamps + end + + add_index :blog_categories, :id + + create_table :blog_categories_blog_posts, :id => false 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' + + load(Rails.root.join('db', 'seeds', 'refinerycms_blog.rb').to_s) + end + + def self.down + UserPlugin.destroy_all({:name => "refinerycms_blog"}) + + Page.delete_all({:link_url => "/blog"}) + + drop_table :blog_posts + drop_table :blog_comments + drop_table :blog_categories + drop_table :blog_categories_blog_posts + 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 new file mode 100644 index 0000000..cd62524 --- /dev/null +++ b/db/migrate/2_add_user_id_to_blog_posts.rb @@ -0,0 +1,11 @@ +class AddUserIdToBlogPosts < ActiveRecord::Migration + + def self.up + add_column :blog_posts, :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 new file mode 100644 index 0000000..1661061 --- /dev/null +++ b/db/migrate/3_acts_as_taggable_on_migration.rb @@ -0,0 +1,28 @@ +class ActsAsTaggableOnMigration < ActiveRecord::Migration + def self.up + create_table :tags do |t| + t.string :name + end + + 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 + + t.string :context + + t.datetime :created_at + end + + add_index :taggings, :tag_id + add_index :taggings, [:taggable_id, :taggable_type, :context] + end + + def self.down + drop_table :taggings + drop_table :tags + end +end diff --git a/db/seeds/refinerycms_blog.rb b/db/seeds/refinerycms_blog.rb new file mode 100644 index 0000000..f958fab --- /dev/null +++ b/db/seeds/refinerycms_blog.rb @@ -0,0 +1,16 @@ +User.find(:all).each do |user| + user.plugins.create(:name => "refinerycms_blog", + :position => (user.plugins.maximum(:position) || -1) +1) +end + +page = Page.create( + :title => "Blog", + :link_url => "/blog", + :deletable => false, + :position => ((Page.maximum(:position, :conditions => {:parent_id => nil}) || -1)+1), + :menu_match => "^/blogs?(\/|\/.+?|)$" +) + +Page.default_parts.each do |default_page_part| + page.parts.create(:title => default_page_part, :body => nil) +end |