lib/db_rotator.rb in db-rotator-0.0.1 vs lib/db_rotator.rb in db-rotator-0.0.2

- old
+ new

@@ -61,11 +61,11 @@ end end def grant_access verbose_message "Granting ..." - mysql_exec "GRANT ALL ON #{todays_dbname}.* to `%`@`localhost`" + mysql_exec "GRANT ALL ON #{todays_dbname}.* to #{current_user}" end def populate_schemas @schemas = raw_schemas.split.each.with_object([]) do |schema_name, memo| memo << Schema.new(schema_name, schema_regex) if schema_name =~ schema_regex @@ -116,9 +116,13 @@ bash_exec "df -h `mysql -B -e 'select @@datadir;' | tail -1` | tail -1 | awk '{ print $2 }'" end def raw_schemas mysql_exec "SHOW DATABASES" + end + + def current_user + mysql_exec("SELECT current_user()").split("\n").last end def bash_exec(cmd, skip_raise = false) out = `#{cmd} || echo '__failed'` out = out.strip == "__failed" ? nil : out