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