addLog to single SQL statement

also adds constraint to facilitate this and introduces a migration script.