File: activerecord.rb

package info (click to toggle)
ruby-carrierwave 0.10.0%2Bgh-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,200 kB
  • ctags: 531
  • sloc: ruby: 7,180; sh: 26; makefile: 4
file content (22 lines) | stat: -rw-r--r-- 585 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
require 'mysql2'
require 'active_record'
require 'carrierwave/orm/activerecord'

# Change this if MySQL is unavailable
dbconfig = {
  :adapter  => 'mysql2',
  :database => 'carrierwave_test',
  :username => 'root',
  :encoding => 'utf8'
}

database = dbconfig.delete(:database)

ActiveRecord::Base.establish_connection(dbconfig)
begin
  ActiveRecord::Base.connection.create_database database
rescue ActiveRecord::StatementInvalid => e # database already exists
end
ActiveRecord::Base.establish_connection(dbconfig.merge(:database => database))

ActiveRecord::Migration.verbose = false