aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2015-09-01 11:31:33 +0900
committerKazuki Yamaguchi <k@rhe.jp>2015-09-01 11:31:33 +0900
commit626d90c7135f4bdb4d8340e76597d18a3ef22e93 (patch)
tree1b64cf74cc126cd8f8b0583a1ea707229d1364a9
parent5ae0327599e136934c428395ac3c32ae6cd1410b (diff)
downloadaclog-626d90c7135f4bdb4d8340e76597d18a3ef22e93.tar.gz
migrate: UNSIGNED is available only for MySQL
-rw-r--r--db/migrate/20131117024504_change_ids_to_unsigned.rb70
1 files changed, 36 insertions, 34 deletions
diff --git a/db/migrate/20131117024504_change_ids_to_unsigned.rb b/db/migrate/20131117024504_change_ids_to_unsigned.rb
index 6530dc5..ebf998f 100644
--- a/db/migrate/20131117024504_change_ids_to_unsigned.rb
+++ b/db/migrate/20131117024504_change_ids_to_unsigned.rb
@@ -1,43 +1,45 @@
-class ChangeIdsToUnsigned < ActiveRecord::Migration
- def up
- # accounts
- execute "ALTER TABLE accounts " +
- "MODIFY user_id bigint unsigned NOT NULL"
+if ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::MysqlAdapter)
+ 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"
+ # 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"
+ # 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
+ # 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"
+ 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"
+ # 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"
+ # 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"
+ # retweets
+ execute "ALTER TABLE retweets " +
+ "MODIFY user_id bigint NOT NULL, " +
+ "MODIFY tweet_id bigint NOT NULL"
+ end
end
end