update_tables_0.3.x-0.4.py
changeset 15 1607f7b2dba9
parent 13 1d9bf63a86f7
child 20 55146c78b3fb
equal deleted inserted replaced
14:ebc9b864bc9a 15:1607f7b2dba9
   106        FROM users
   106        FROM users
   107             LEFT JOIN domains USING (gid)
   107             LEFT JOIN domains USING (gid)
   108             LEFT JOIN maillocation USING (mid)""")
   108             LEFT JOIN maillocation USING (mid)""")
   109 dbh.commit()
   109 dbh.commit()
   110 
   110 
   111 # Update VIEW dovecot_user
   111 # Replace VIEW dovecot_user
       
   112 dbc.execute("DROP VIEW dovecot_user")
       
   113 dbh.commit()
   112 dbc.execute("""CREATE OR REPLACE VIEW dovecot_user AS
   114 dbc.execute("""CREATE OR REPLACE VIEW dovecot_user AS
   113     SELECT local_part || '@' || domains.domainname AS userid,
   115     SELECT local_part || '@' || domains.domainname AS userid,
   114            domains.domaindir || '/' || uid AS home, uid, gid
   116            uid, gid, domains.domaindir || '/' || uid AS home,
       
   117            '~/' || maillocation.maillocation AS mail
   115       FROM users
   118       FROM users
   116            LEFT JOIN domains USING (gid)""")
   119            LEFT JOIN domains USING (gid)
       
   120            LEFT JOIN maillocation USING (mid);""")
   117 dbh.commit()
   121 dbh.commit()
   118 
   122 
   119 # fix table users (Part II)
   123 # fix table users (Part II)
   120 dbc.execute("ALTER TABLE users DROP home")
   124 dbc.execute("ALTER TABLE users DROP home")
   121 dbh.commit()
   125 dbh.commit()