fix #11663, #11877: SQL DOMAIN; import logs (rebased); FS delete log trigger

Fixes:
* http://trac.openmicroscopy.org.uk/ome/ticket/11663
* http://trac.openmicroscopy.org.uk/ome/ticket/11664
* http://trac.openmicroscopy.org.uk/ome/ticket/11877

--rebased-from #2055

Check that everything still seems to work: can import, view, delete images; can view import logs.

Breaking so needs label from @sbesson? Also @ajpatterson should glance at some of the changes.