Add an owner_id
field to your apps
table and then iterate through your apps_owners
table and set the owner_id
field in apps
to the owner_id
field in apps_owners
for the apps
record whose id
is equal to app_id
.
Assuming you're correct and there aren't multiple apps_owners
entries for the same app_id
following SQL should do it (not tested), although I'm not familiar with how to incorporate raw SQL into migrations:
update apps set owner_id=(select owner_id from apps_owners where apps.id = apps_owners.app_id)