CAVaccineInventory / vial

The Django application powering calltheshots.us

Home Page:https://vial.calltheshots.us

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Make more tables available in Mode

simonw opened this issue · comments

A bunch of new ones like core_locationreviewnote aren't visible there yet.

This query shows visible tables:

select table_name
from information_schema.role_table_grants 
where grantee=current_user
and privilege_type = 'SELECT';

In Mode right now it only returns 34.

This query (run with a full privileged account) returns all tables:

SELECT table_name
FROM information_schema.tables
WHERE table_schema = 'public'
ORDER BY table_name

I ran this in Mode:

with visible as (select table_name
from information_schema.role_table_grants 
where grantee=current_user
and privilege_type = 'SELECT')
select string_agg('''' || table_name || '''', ', ') from visible

Then pasted the results to create this SQL query:

SELECT table_name
FROM information_schema.tables
WHERE table_schema = 'public'
and table_name not in ('location', 'call_report_availability_tag', 'call_request_reason', 'location_type', 'provider', 'provider_type', 'api_apikey', 'api_log', 'django_migrations', 'concordance_identifier', 'concordance_location', 'concordance_source_location', 'call_request', 'reversion_revision', 'core_reportreviewnote', 'eva_report', 'report', 'published_report', 'published_report_availability_tag', 'published_report_eva_report', 'state', 'core_reportreviewnote_tags', 'core_reportreviewtag', 'reporter', 'reversion_version', 'appointment_tag', 'availability_tag', 'county', 'django_admin_log', 'source_location_match_history', 'task', 'source_location', 'task_type', 'completed_location_merge')
ORDER BY table_name

This gave me back the list of 27 tables that Mode does not currently have access to.

I ran this against the production database:

grant select on
  public.auth_group,
  public.auth_group_permissions,
  public.auth_permission,
  public.auth_user_groups,
  public.auth_user_user_permissions,
  public.core_locationreviewnote,
  public.core_locationreviewnote_tags,
  public.core_locationreviewtag,
  public.django_content_type,
  public.import_run,
  public.provider_phase,
  public.provider_provider_phase
to "datascience";

And now this in Mode returns 46 tables:

select table_name
from information_schema.role_table_grants 
where grantee=current_user
and privilege_type = 'SELECT';

Also ran this to grant some extra tables to Django SQL Dashboard:

grant select on
  public.core_locationreviewnote,
  public.core_locationreviewnote_tags,
  public.core_locationreviewtag,
  public.import_run,
  public.provider_phase,
  public.provider_provider_phase
to "read-only-core-tables";