- 追加された行はこの色です。
- 削除された行はこの色です。
&tag(Rails/運用);
*目次 [#h9d8bf92]
#contents
*関連ページ [#x6a08cdd]
-[[SQLite3]]
*参考情報 [#v247ac09]
*データベース関連の操作 [#rbc99554]
-[[RubyOnRails - Railsの rake db コマンドリスト - Qiita:http://qiita.com/icche/items/e9b08c6b11f762b949de]]
-[[ruby on rails - Difference between rake db:migrate db:reset and db:schema:load - Stack Overflow:http://stackoverflow.com/questions/10301794/difference-between-rake-dbmigrate-dbreset-and-dbschemaload]]
**データベースの生成 [#v1754c21]
指定のデータベースだけを作成する。テーブルは作成されない。この後migrationを実行するかschemaからロードしないといけない。
-全てのデータベースを生成
bundle exec rake db:create:all
-特定環境のデータベースを再生成
bundle exec rake db:create RAILS_ENV=test
**データベースの削除 [#cd697b7d]
-全てのデータベースを削除
bundle exec rake db:drop
-特定環境のデータベースを削除
bundle exec rake db:drop RAILS_ENV=test
**データベース・テーブルの再生成 [#k3831a50]
-drop、create、schema.rbからの復帰を実行(migrationは無視)
bunde exec rake db:reset
-drop、create、migrationの実行
bundle exec rake db:migrate:reset
*サーバー操作 [#xc8815f7]
**サーバーの起動 [#t50f01b0]
-指定環境でサーバーを起動する
bundle exec rails s -e production
*rails [#c4ecb277]
**dbconsole [#z22f8264]
-起動方法
bundle exec rails dbconsole
-環境指定(test環境の場合)
bundle exec rails dbconsole test
★以下の操作はSQLite3やMySQLの操作方法と同じ。