

drop table if exists migration_party_vehicle;

create table migration_party_vehicle as select pv.id, party_id, p.migration_id party_migration_id, vehicle_id, v.migration_id vehicle_migration_id
from party_vehicle pv
left join party p on p.id = pv.party_id
left join vehicle v on v.id = pv.vehicle_id;

create index migration_party_vehicle_party_idx on migration_party_vehicle(party_migration_id);
create index migration_party_vehicle_vehicle_idx on migration_party_vehicle(vehicle_migration_id);
create index migration_party_vehicle_partyvehicle_idx on migration_party_vehicle(vehicle_migration_id, party_migration_id);
