aboutsummaryrefslogtreecommitdiffstats
path: root/db/migrate/20131117024504_change_ids_to_unsigned.rb
blob: 6530dc520f2a14d2a3c42e63d2d12dfb7c3a010a (plain)
1
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
class ChangeIdsToUnsigned < ActiveRecord::Migration
  def up
    # accounts
    execute "ALTER TABLE accounts " +
      "MODIFY user_id bigint unsigned NOT NULL"

    # tweets
    execute "ALTER TABLE tweets " +
      "MODIFY user_id bigint unsigned NOT NULL, " +
      "MODIFY in_reply_to_id bigint unsigned DEFAULT NULL"

    # favorites
    execute "ALTER TABLE favorites " +
      "MODIFY user_id bigint unsigned NOT NULL, " +
      "MODIFY tweet_id bigint unsigned NOT NULL"

    # retweets
    execute "ALTER TABLE retweets " +
      "MODIFY user_id bigint unsigned NOT NULL, " +
      "MODIFY tweet_id bigint unsigned NOT NULL"
  end

  def down
    # accounts
    execute "ALTER TABLE accounts " +
      "MODIFY user_id bigint NOT NULL"

    # tweets
    execute "ALTER TABLE tweets " +
      "MODIFY user_id bigint NOT NULL, " +
      "MODIFY in_reply_to_id bigint DEFAULT NULL"

    # favorites
    execute "ALTER TABLE favorites " +
      "MODIFY user_id bigint NOT NULL, " +
      "MODIFY tweet_id bigint NOT NULL"

    # retweets
    execute "ALTER TABLE retweets " +
      "MODIFY user_id bigint NOT NULL, " +
      "MODIFY tweet_id bigint NOT NULL"
  end
end