Class: CreateTweets

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

Class Method Summary collapse

Class Method Details

.downObject



22
23
24
# File 'lib/generators/templates/create_tweets.rb', line 22

def self.down
  drop_table :tweets
end

.upObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/generators/templates/create_tweets.rb', line 2

def self.up
  create_table :tweets, :force => true do |t|
    t.datetime :tweeted_at
    t.string :text, :length => 140
    if Rails.database.mysql?
      t.column :twitter_id, 'BIGINT UNSIGNED'
    elsif Rails.database.postgresql?
      t.column :twitter_id, 'BIGINT'
    end
    t.integer :twitter_id, :limit => 20
    t.string :from_user
    t.string :profile_image_url
    t.string :to_user
    t.integer :reach, :default => 0
    t.timestamps
  end
  add_index :tweets, :tweeted_at
  add_index :tweets, :twitter_id, :unique => true
end