Use triggers for db migration.

Change-Id: I2dfa8ec418eb771a98b47cd6d82132184e661fc2