printf"\n\nA database with with the name \"$(DATABASE_NAME)\" does already exist.\nCall 'make drop-$(DATABASE_NAME)' to delete that database or reconfigure with './configure'.\n";\
printf"\n\nA database with with the name \"$(M_DATABASE_NAME)\" does already exist.\nCall 'make drop-$(M_DATABASE_NAME)' to delete that database or reconfigure with './configure'.\n";\
($(MYSQL_CMD)$(MYSQL_CONNECTION)-e"SELECT COUNT(*) FROM mysql.user WHERE user='$(DATABASE_USER)' AND host=\"$$host\";" | grep 0 )||(echo"The user '$(DATABASE_USER)@$$host' is already in the database. Please use another user or delete her. E.g. with 'mysql -u $(MYSQL_USER) -p -e \"DROP USER $(DATABASE_USER)@$$host;\"'";exit 1 );\
($(M_MYSQL_CMD)$(M_MYSQL_CONNECTION)-e"SELECT COUNT(*) FROM mysql.user WHERE user='$(M_DATABASE_USER)' AND host=\"$$host\";" | grep 0 )||(echo"The user '$(M_DATABASE_USER)@$$host' is already in the database. Please use another user or delete her. E.g. with 'mysql -u $(M_MYSQL_USER) -p -e \"DROP USER $(M_DATABASE_USER)@$$host;\"'";exit 1 );\
done
@while true;do\
printf"\n Please enter the password for $(DATABASE_USER): ";read-s password;\
printf"\nPlease repeat the password for $(DATABASE_USER): ";read-s password2;\
printf"\n Please enter the password for $(M_DATABASE_USER): ";read-s password;\
printf"\nPlease repeat the password for $(M_DATABASE_USER): ";read-s password2;\
) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;"
# copy from old transaction_log
mysql$MYSQL_CONNECTION-D$DATABASE-e"INSERT INTO new_transaction_log SELECT transaction, user_id, (Year(timestamp) * 10000 + Month(timestamp) * 100 + Day(timestamp)) as date, ((Hour(timestamp) + 1) * 10000 + (Minute(timestamp) + 1)*100 + Second(timestamp) + 1 ) as time, NULL as ns, entity_id from transaction_log";
mysql_execute "INSERT INTO new_transaction_log SELECT transaction, user_id, (Year(timestamp) * 10000 + Month(timestamp) * 100 + Day(timestamp)) as date, ((Hour(timestamp) + 1) * 10000 + (Minute(timestamp) + 1)*100 + Second(timestamp) + 1 ) as time, NULL as ns, entity_id from transaction_log";
# check if both have same number of rows
ROWSTEST=$(mysql$MYSQL_CONNECTION-D$DATABASE-e"SELECT count(*) from new_transaction_log into @newRows; SELECT count(*) from transaction_log into @oldRows; Select (@newRows = @oldRows) as test" | sed-e':a;N;$!ba;s/[^01]//g')
ROWSTEST=$(mysql_execute "SELECT count(*) from new_transaction_log into @newRows; SELECT count(*) from transaction_log into @oldRows; Select (@newRows = @oldRows) as test" | sed-e':a;N;$!ba;s/[^01]//g')
if[ 0 -eq"$ROWSTEST"];then
failure "The rows do not match. Something went wrong."
CMD_OPTIONS="options:\n\n-h, --help\n\tShow brief help.\n-l LOGIN_PATH, --login-path=LOGIN_PATH\n\tA login-path for the mysql connection (see 'man mysql' and 'man mysql-config-editor').\n-u USER, --user=USER\n\tA mysql user.\n-p PASSWORD, --password=PASSWORD\n\tThe password for the mysql user.\n"