Probably fixed initial view setup. Needs create drop then recreate

This commit is contained in:
2025-11-05 21:05:36 +00:00
parent 68223f664a
commit e577945e75
4 changed files with 34 additions and 3 deletions

View 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.

View File

@@ -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
time,
account_id,

View File

@@ -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
time,
adset_id,

View File

@@ -1,6 +1,8 @@
--- 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
time,
account_id,