]>
gitweb.michael.orlitzky.com - mailshears.git/blob - lib/mv/plugins/davical.rb
3 require 'common/davical_plugin'
8 # DAViCal only supports Postgres, so even if we ever are
9 # database-agnostic, this plugin can't be.
16 # Switch the given usernames. DAViCal uses foreign keys properly
17 # and only supports postgres, so we let the ON UPDATE CASCADE
18 # trigger handle most of the work.
20 # It's obviously an error if the source user does not exist. It
21 # would also be an error if the destination domain didn't exist;
22 # however, DAViCal doesn't know about domains, so we let that slide.
23 raise NonexistentUserError
.new(src
.to_s()) if not user_exists(src
)
25 # And it's an error if the destination user exists already.
26 raise UserAlreadyExistsError
.new(dst
.to_s()) if user_exists(dst
)
28 sql_queries
= ['UPDATE usr SET username = $1 WHERE username = $2']
31 connection
= PGconn
.connect(@db_host,
39 sql_queries
.each
do |sql_query
|
40 connection
.query(sql_query
, [dst
.to_s(), src
.to_s()])
46 # Pretend like we're database-agnostic in case we ever are.
47 raise DatabaseError
.new(e
)