Files
database/migrations/archive/000.449.sql
T
Rikard BartholfandGitHub ddcbd0afb0 Archive old migrations (#426)
* Archive old migrations

* Fix invalid placement of migrations
2024-10-17 11:19:12 +02:00

21 lines
685 B
SQL

DROP VIEW IF EXISTS v_order_emails;
CREATE VIEW v_order_emails AS
select
orders.id order_id,
orders.inserted::date order_date,
billing.email billing_email,
billing.first_name billing_firstname,
billing.last_name billing_lastname
from
orders
left join addresses billing on billing_address_id = billing.id
where
orders.paid = 1
;
-- If we want to read this with direct access from BigQuery to Postgres:
-- CREATE USER bigquery WITH PASSWORD 'secret';
-- GRANT SELECT ON v_order_emails TO bigquery;
-- GRANT USAGE ON SCHEMA public TO bigquery;
-- We don't need this now as we will access the view ourselves instead and get the results to BigQuery via S3.