require 'pg' require 'common/agendav_plugin' require 'mv/mv_plugin' class AgendavMv include AgendavPlugin include MvPlugin def mv_domain(from, to) # AgenDAV doesn't have a concept of domains. end def mv_account(from, to) sql_queries = ['UPDATE prefs SET username = $1 WHERE username $2;'] sql_queries << 'UPDATE shared SET user_from = $1 WHERE user_from = $2;' sql_queries << 'UPDATE shared SET user_which = $1 WHERE user_which = $2;' begin connection = PGconn.connect(@db_host, @db_port, @db_opts, @db_tty, @db_name, @db_user, @db_pass) sql_queries.each do |sql_query| connection.query(sql_query, [to, from]) end connection.close() rescue PGError => e # Pretend like we're database-agnostic in case we ever are. raise DatabaseError.new(e) end end end