added flags migration and foreign keys for updates and removes