summaryrefslogtreecommitdiff
path: root/db/migrations/0003_unknown_speed_demon.sql
blob: 19fc36a8757098e913a5745afcd576792f63f8d4 (plain)
1
2
3
4
5
DROP VIEW "public"."user_view";--> statement-breakpoint
ALTER TABLE "roles" ADD COLUMN "description" text DEFAULT '' NOT NULL;--> statement-breakpoint
CREATE VIEW "public"."user_view" AS (select "users"."id" as "user_id", "users"."name" as "user_name", "users"."email" as "user_email", "users"."domain" as "user_domain", "users"."image_url" as "user_image", "companies"."id" as "company_id", "companies"."name" as "company_name", 
      array_agg("roles"."name")
     as "roles", "users"."created_at" as "created_at" from "users" left join "companies" on "users"."company_id" = "companies"."id" left join "user_roles" on "users"."id" = "user_roles"."user_id" left join "roles" on "user_roles"."role_id" = "roles"."id" group by "users"."id", "companies"."id");