Class: CreateTamedBeastTables

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/generators/tamed_beast/templates/migration.rb

Class Method Summary collapse

Class Method Details

.downObject



49
50
51
52
53
54
55
56
# File 'lib/generators/tamed_beast/templates/migration.rb', line 49

def self.down
  remove_column :users, :posts_count
  remove_column :users, :last_seen_at

  drop_table :topics
  drop_table :posts
  drop_table :forums
end

.upObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/generators/tamed_beast/templates/migration.rb', line 2

def self.up
  create_table "forums" do |t|
    t.string  "name"
    t.string  "description"
    t.integer "topics_count",     :default => 0
    t.integer "posts_count",      :default => 0
    t.integer "position"
    t.text    "description_html"
  end

  create_table "posts" do |t|
    t.integer  "user_id"
    t.integer  "topic_id"
    t.text     "body"
    t.datetime "created_at"
    t.datetime "updated_at"
    t.integer  "forum_id"
    t.text     "body_html"
  end

  add_index "posts", ["forum_id", "created_at"], :name => "index_posts_on_forum_id"
  add_index "posts", ["user_id", "created_at"], :name => "index_posts_on_user_id"
  add_index "posts", ["topic_id", "created_at"], :name => "index_posts_on_topic_id"

  create_table "topics" do |t|
    t.integer  "forum_id"
    t.integer  "user_id"
    t.string   "title"
    t.datetime "created_at"
    t.datetime "updated_at"
    t.integer  "hits",         :default => 0
    t.integer  "sticky",       :default => 0
    t.integer  "posts_count",  :default => 0
    t.datetime "replied_at"
    t.boolean  "locked",       :default => false
    t.integer  "replied_by"
    t.integer  "last_post_id"
  end

  add_index "topics", ["forum_id"], :name => "index_topics_on_forum_id"
  add_index "topics", ["forum_id", "sticky", "replied_at"], :name => "index_topics_on_sticky_and_replied_at"
  add_index "topics", ["forum_id", "replied_at"], :name => "index_topics_on_forum_id_and_replied_at"

  add_column :users, :posts_count, :integer, :default => 0
  add_column :users, :last_seen_at, :datetime
end