Co-authored-by: Niklas Fondberg <niklas.fondberg@photowall.se> Co-authored-by: Rikard Bartholf <rikard@bartholf.nu>
14 lines
599 B
SQL
14 lines
599 B
SQL
-- 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;
|