-- migrate email and phone to addresses table

ALTER TABLE addresses ADD column IF NOT EXISTS email text;
ALTER TABLE addresses ADD column IF NOT EXISTS phone text;

UPDATE addresses SET phone = oo.phone, email = oo.email FROM orders oo WHERE addresses.id = oo.billing_address_id;
UPDATE addresses SET phone = oo.delivery_phone, email = oo.delivery_email FROM orders oo WHERE addresses.id = oo.delivery_address_id;


-- ALTER table orders drop column phone;
-- ALTER table orders drop column email;
-- ALTER table orders drop column delivery_email;
-- ALTER table orders drop column delivery_phone;
