added forum topic/post

This commit is contained in:
albert
2010-02-20 20:25:01 -05:00
parent 0bb52fd63a
commit 9f05154a5a
11 changed files with 271 additions and 1 deletions

View File

@@ -0,0 +1,22 @@
class CreateForumTopics < ActiveRecord::Migration
def self.up
create_table :forum_topics do |t|
t.column :creator_id, :integer, :null => false
t.column :title, :string, :null => false
t.column :response_count, :integer, :null => false, :default => 0
t.column :is_sticky, :boolean, :null => false, :default => false
t.column :is_locked, :boolean, :null => false, :default => false
t.column :text_index, "tsvector", :null => false
t.timestamps
end
add_index :forum_topics, :creator_id
execute "CREATE INDEX index_forum_topics_on_text_index ON forum_topics USING GIN (text_index)"
execute "CREATE TRIGGER trigger_forum_topics_on_update BEFORE INSERT OR UPDATE ON forum_topics FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('text_index', 'pg_catalog.english', 'title')"
end
def self.down
drop_table :forum_topics
end
end

View File

@@ -0,0 +1,20 @@
class CreateForumPosts < ActiveRecord::Migration
def self.up
create_table :forum_posts do |t|
t.column :topic_id, :integer, :null => false
t.column :creator_id, :integer, :null => false
t.column :body, :text, :null => false
t.column :text_index, "tsvector", :null => false
t.timestamps
end
add_index :forum_posts, :topic_id
add_index :forum_posts, :creator_id
execute "CREATE INDEX index_forum_posts_on_text_index ON forum_posts USING GIN (text_index)"
execute "CREATE TRIGGER trigger_forum_posts_on_update BEFORE INSERT OR UPDATE ON forum_posts FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('text_index', 'pg_catalog.english', 'body')"
end
def self.down
drop_table :forum_posts
end
end