<commit_before>#
# Cookbook Name:: gitlab
# Recipe:: database_mysql
#

mysql = node['mysql']
gitlab = node['gitlab']

# 5.Database
include_recipe "mysql::server"
include_recipe "database::mysql"

mysql_connection = {
  :host => 'localhost',
  :username => 'root',
  :password => mysql['server_root_password']
}

## Create a user for GitLab.
mysql_database_user gitlab['user'] do
  connection mysql_connection
  password gitlab['<PASSWORD>']
  action :create
end

## Create the GitLab database & grant all privileges on database
gitlab['environments'].each do |environment|
  mysql_database "gitlabhq_#{environment}" do
    connection mysql_connection
    action :create
  end

  mysql_database_user gitlab['user'] do
    connection mysql_connection
    password gitlab['<PASSWORD>']
    database_name "gitlabhq_#{environment}"
    host 'localhost'
    privileges ["SELECT", "UPDATE", "INSERT", "DELETE", "CREATE", "DROP", "INDEX", "ALTER", "LOCK TABLES"]
    action :grant
  end
end
<commit_msg>Add encoding and collation to the db creation.<commit_after>#
# Cookbook Name:: gitlab
# Recipe:: database_mysql
#

mysql = node['mysql']
gitlab = node['gitlab']

# 5.Database
include_recipe "mysql::server"
include_recipe "database::mysql"

mysql_connection = {
  :host => 'localhost',
  :username => 'root',
  :password => mysql['<PASSWORD>']
}

## Create a user for GitLab.
mysql_database_user gitlab['user'] do
  connection mysql_connection
  password gitlab['<PASSWORD>']
  action :create
end

## Create the GitLab database & grant all privileges on database
gitlab['environments'].each do |environment|
  mysql_database "gitlabhq_#{environment}" do
    encoding "utf8"
    collation "utf8_unicode_ci"
    connection mysql_connection
    action :create
  end

  mysql_database_user gitlab['user'] do
    connection mysql_connection
    password gitlab['database_password']
    database_name "gitlabhq_#{environment}"
    host 'localhost'
    privileges ["SELECT", "UPDATE", "INSERT", "DELETE", "CREATE", "DROP", "INDEX", "ALTER", "LOCK TABLES"]
    action :grant
  end
end

{'fraction_non_alphanumeric': 0.12693050193050193, 'fraction_numerical': 0.0019305019305019305, 'mean_word_length': 5.115044247787611, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4089098', 'n_tokens_mistral': 649, 'n_tokens_neox': 641, 'n_words': 177}