added forum topic/post
This commit is contained in:
22
db/migrate/20100221003655_create_forum_topics.rb
Normal file
22
db/migrate/20100221003655_create_forum_topics.rb
Normal 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
|
||||
20
db/migrate/20100221005812_create_forum_posts.rb
Normal file
20
db/migrate/20100221005812_create_forum_posts.rb
Normal 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
|
||||
Reference in New Issue
Block a user