Module: Rails::Generators::Database::MySQL

Included in:
MySQL2, Trilogy
Defined in:
lib/rails/generators/database.rb

Instance Method Summary collapse

Instance Method Details

#hostObject



44
45
46
# File 'lib/rails/generators/database.rb', line 44

def host
  "127.0.0.1"
end

#nameObject



9
10
11
# File 'lib/rails/generators/database.rb', line 9

def name
  "mysql"
end

#portObject



13
14
15
# File 'lib/rails/generators/database.rb', line 13

def port
  3306
end

#serviceObject



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/rails/generators/database.rb', line 17

def service
  {
    "image" => "mysql/mysql-server:8.0",
    "restart" => "unless-stopped",
    "environment" => {
      "MYSQL_ALLOW_EMPTY_PASSWORD" => "true",
      "MYSQL_ROOT_HOST" => "%"
    },
    "volumes" => ["mysql-data:/var/lib/mysql"],
    "networks" => ["default"],
  }
end

#socketObject



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/rails/generators/database.rb', line 30

def socket
  @socket ||= [
    "/tmp/mysql.sock",                        # default
    "/var/run/mysqld/mysqld.sock",            # debian/gentoo
    "/var/tmp/mysql.sock",                    # freebsd
    "/var/lib/mysql/mysql.sock",              # fedora
    "/opt/local/lib/mysql/mysql.sock",        # fedora
    "/opt/local/var/run/mysqld/mysqld.sock",  # mac + darwinports + mysql
    "/opt/local/var/run/mysql4/mysqld.sock",  # mac + darwinports + mysql4
    "/opt/local/var/run/mysql5/mysqld.sock",  # mac + darwinports + mysql5
    "/opt/lampp/var/mysql/mysql.sock"         # xampp for linux
  ].find { |f| File.exist?(f) } unless Gem.win_platform?
end