Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add default_character_set options to mysql helpers #1840

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions helpers/mysql
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,25 @@
# Requires YunoHost version 2.2.4 or higher.
ynh_mysql_connect_as() {
# Declare an array to define the options of this helper.
local legacy_args=upd
local -A args_array=([u]=user= [p]=password= [d]=database=)
local legacy_args=updc
local -A args_array=( [u]=user= [p]=password= [d]=database= [c]=default_character_set= )
local user
local password
local database
local default_character_set
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
database="${database:-}"
default_character_set="${default_character_set:-}"

mysql --user="$user" --password="$password" --batch "$database"
if [ -n "$default_character_set" ]
then
default_character_set="--default-character-set=$default_character_set"
else
default_character_set="--default-character-set=latin1"
fi

mysql --user="$user" --password="$password" "$default_character_set" --batch "$database"
}

# Execute a command as root user
Expand Down Expand Up @@ -127,13 +136,15 @@ ynh_mysql_drop_db() {
# Requires YunoHost version 2.2.4 or higher.
ynh_mysql_dump_db() {
# Declare an array to define the options of this helper.
local legacy_args=d
local -A args_array=([d]=database=)
local legacy_args=dc
local -A args_array=( [d]=database= [c]=default_character_set= )
local database
local default_character_set
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
default_character_set="${default_character_set:-latin1}"

mysqldump --single-transaction --skip-dump-date --routines "$database"
mysqldump --single-transaction --skip-dump-date --routines --default-character-set=$default_character_set "$database"
}

# Create a user
Expand Down
Loading