summaryrefslogtreecommitdiff
path: root/db/migrations/0084_familiar_skrulls.sql
blob: 95bed728f0d8d381a2189feafd7faa3af9c03aea (plain)
1
2
DROP VIEW "public"."role_view";--> statement-breakpoint
CREATE VIEW "public"."role_view" AS (select "roles"."id" as "id", "roles"."name" as "name", "roles"."description" as "description", "roles"."domain" as "domain", "roles"."created_at" as "created_at", "vendors"."id" as "company_id", "vendors"."vendor_name" as "company_name", COUNT("users"."id") as "user_count" from "roles" left join "user_roles" on "user_roles"."role_id" = "roles"."id" left join "users" on "users"."id" = "user_roles"."user_id" left join "vendors" on "roles"."company_id" = "vendors"."id" group by "roles"."id", "vendors"."id");