Probably fixed initial view setup. Needs create drop then recreate
This commit is contained in:
25
src/meta_api_grabber/views/SETUP_PERMISSIONS.md
Normal file
25
src/meta_api_grabber/views/SETUP_PERMISSIONS.md
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# View Permissions Setup
|
||||||
|
|
||||||
|
The scheduled grabber needs the `meta_user` to have permissions to create/drop/modify views.
|
||||||
|
|
||||||
|
## One-time Setup (run as superuser or database owner)
|
||||||
|
|
||||||
|
```sql
|
||||||
|
-- Give meta_user the ability to create views in the public schema
|
||||||
|
GRANT CREATE ON SCHEMA public TO meta_user;
|
||||||
|
|
||||||
|
-- Alternative: Make meta_user the owner of all views (if they already exist)
|
||||||
|
-- ALTER MATERIALIZED VIEW account_insights_flattened OWNER TO meta_user;
|
||||||
|
-- ALTER MATERIALIZED VIEW campaign_insights_flattened OWNER TO meta_user;
|
||||||
|
-- ALTER MATERIALIZED VIEW adset_insights_flattened OWNER TO meta_user;
|
||||||
|
```
|
||||||
|
|
||||||
|
Run these commands once as a superuser/database owner, then the scheduled grabber can manage views normally.
|
||||||
|
|
||||||
|
## Why This Is Needed
|
||||||
|
|
||||||
|
PostgreSQL materialized views must be owned by the user who created them. Since the scheduled grabber recreates views on startup (to apply schema changes), it needs permission to:
|
||||||
|
- `DROP MATERIALIZED VIEW` - remove old views
|
||||||
|
- `CREATE MATERIALIZED VIEW` - create new views
|
||||||
|
|
||||||
|
Without proper schema permissions, the `meta_user` cannot perform these operations.
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
CREATE OR REPLACE MATERIALIZED VIEW account_insights_flattened AS
|
DROP MATERIALIZED VIEW IF EXISTS account_insights_flattened CASCADE;
|
||||||
|
|
||||||
|
CREATE MATERIALIZED VIEW account_insights_flattened AS
|
||||||
SELECT
|
SELECT
|
||||||
time,
|
time,
|
||||||
account_id,
|
account_id,
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
CREATE OR REPLACE MATERIALIZED VIEW adset_insights_flattened AS
|
DROP MATERIALIZED VIEW IF EXISTS adset_insights_flattened CASCADE;
|
||||||
|
|
||||||
|
CREATE MATERIALIZED VIEW adset_insights_flattened AS
|
||||||
SELECT
|
SELECT
|
||||||
time,
|
time,
|
||||||
adset_id,
|
adset_id,
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
--- campaign insights
|
--- campaign insights
|
||||||
|
|
||||||
CREATE OR REPLACE MATERIALIZED VIEW campaign_insights_flattened AS
|
DROP MATERIALIZED VIEW IF EXISTS campaign_insights_flattened CASCADE;
|
||||||
|
|
||||||
|
CREATE MATERIALIZED VIEW campaign_insights_flattened AS
|
||||||
SELECT
|
SELECT
|
||||||
time,
|
time,
|
||||||
account_id,
|
account_id,
|
||||||
|
|||||||
Reference in New Issue
Block a user