Rename triggerRestoredEvent to triggerRestoreEvent, move triggerRestoreEvent
from the Syncable interface to SyncMaster, call triggerRestoreEvent only when
restoring SyncMaster, delete useless assertions.
Update comments in DeleteResourceMapping to explain the detach() behavior. Move triggerRestoredEvent() from SyncMaster to Syncable interface, test restoring tenant resources.
Also make all resource syncing-related listener closures static.
Also correct return type for getGlobalIdentifierKey to string|int.
(We intentionally do not support returning null like many other
"get x key" methods would since such a case might break resource
syncing logic. This is also why we use inline getAttribute() in the
creating listener instead of calling the method.)
Also move pivot record deletion to that listener and improve tests
The 'tenant pivot records are deleted along with the tenants to which
they belong to' test is failing in this commit -- the listener
for deleting mappings when a *tenant* is deleted is only implemented
in the next commit. The only change done here is to re-add FKs
(necessary for passing *in this commit* in that specific dataset
variant) that were removed from the default test migration as we now
have the the DeleteResourceMapping listener that's enabled by default.