diff --git a/drizzle/0025_remaining_crm_features.sql b/drizzle/0025_remaining_crm_features.sql
new file mode 100644
index 00000000..e1776de6
--- /dev/null
+++ b/drizzle/0025_remaining_crm_features.sql
@@ -0,0 +1,130 @@
+CREATE TABLE "internal_tasks" (
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
+ "organization_id" uuid NOT NULL,
+ "product_id" uuid NOT NULL,
+ "relationship_id" uuid,
+ "owner_id" text NOT NULL,
+ "title" text NOT NULL,
+ "description" text DEFAULT '' NOT NULL,
+ "due_at" timestamp with time zone NOT NULL,
+ "time_zone" text NOT NULL,
+ "recurrence" jsonb,
+ "status" text DEFAULT 'open' NOT NULL,
+ "version" integer DEFAULT 1 NOT NULL,
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
+ CONSTRAINT "internal_tasks_organization_id_product_id_id_unique" UNIQUE("organization_id","product_id","id")
+);
+--> statement-breakpoint
+ALTER TABLE "internal_tasks" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
+CREATE TABLE "native_drafts" (
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
+ "organization_id" uuid NOT NULL,
+ "product_id" uuid NOT NULL,
+ "relationship_id" uuid NOT NULL,
+ "owner_id" text NOT NULL,
+ "source_conversation_id" uuid NOT NULL,
+ "channel" text NOT NULL,
+ "title" text NOT NULL,
+ "reason" text DEFAULT '' NOT NULL,
+ "body" text NOT NULL,
+ "source_id" text NOT NULL,
+ "source_hash" text NOT NULL,
+ "scheduled_action_id" uuid,
+ "version" integer DEFAULT 1 NOT NULL,
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
+ CONSTRAINT "native_drafts_organization_id_product_id_id_unique" UNIQUE("organization_id","product_id","id"),
+ CONSTRAINT "native_draft_source_hash" CHECK ("native_drafts"."source_hash" ~ '^[a-f0-9]{64}$')
+);
+--> statement-breakpoint
+ALTER TABLE "native_drafts" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
+CREATE TABLE "yodu_bindings" (
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
+ "organization_id" uuid NOT NULL,
+ "product_id" uuid NOT NULL,
+ "source_id" uuid NOT NULL,
+ "external_subject_id" text NOT NULL,
+ "relationship_id" uuid NOT NULL,
+ "created_by" text NOT NULL,
+ "version" integer DEFAULT 1 NOT NULL,
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
+ CONSTRAINT "yodu_bindings_source_id_external_subject_id_unique" UNIQUE("source_id","external_subject_id")
+);
+--> statement-breakpoint
+ALTER TABLE "yodu_bindings" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
+CREATE TABLE "yodu_events" (
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
+ "organization_id" uuid NOT NULL,
+ "product_id" uuid NOT NULL,
+ "source_id" uuid NOT NULL,
+ "external_subject_id" text NOT NULL,
+ "provider_event_id" text NOT NULL,
+ "kind" text NOT NULL,
+ "occurred_at" timestamp with time zone NOT NULL,
+ "received_at" timestamp with time zone NOT NULL,
+ "payload_hash" text NOT NULL,
+ "source_version" integer NOT NULL,
+ CONSTRAINT "yodu_events_source_id_provider_event_id_unique" UNIQUE("source_id","provider_event_id"),
+ CONSTRAINT "yodu_event_kind" CHECK ("yodu_events"."kind" IN ('signup', 'onboarding', 'payment', 'activation')),
+ CONSTRAINT "yodu_event_hash" CHECK ("yodu_events"."payload_hash" ~ '^[a-f0-9]{64}$'),
+ CONSTRAINT "yodu_event_source_version" CHECK ("yodu_events"."source_version" > 0)
+);
+--> statement-breakpoint
+ALTER TABLE "yodu_events" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
+CREATE TABLE "yodu_sources" (
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
+ "organization_id" uuid NOT NULL,
+ "product_id" uuid NOT NULL,
+ "label" text NOT NULL,
+ "enabled" boolean DEFAULT true NOT NULL,
+ "encrypted_secret" text NOT NULL,
+ "created_by" text NOT NULL,
+ "version" integer DEFAULT 1 NOT NULL,
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
+ CONSTRAINT "yodu_sources_organization_id_product_id_id_unique" UNIQUE("organization_id","product_id","id")
+);
+--> statement-breakpoint
+ALTER TABLE "yodu_sources" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
+ALTER TABLE "conversations" ALTER COLUMN "connection_id" DROP NOT NULL;--> statement-breakpoint
+ALTER TABLE "messages" ALTER COLUMN "connection_id" DROP NOT NULL;--> statement-breakpoint
+ALTER TABLE "actions" ADD COLUMN "reason_source" text;--> statement-breakpoint
+ALTER TABLE "conversations" ADD COLUMN "provenance" text DEFAULT 'provider' NOT NULL;--> statement-breakpoint
+ALTER TABLE "internal_tasks" ADD CONSTRAINT "internal_tasks_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "internal_tasks" ADD CONSTRAINT "internal_tasks_organization_id_product_id_products_organization_id_id_fk" FOREIGN KEY ("organization_id","product_id") REFERENCES "public"."products"("organization_id","id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "internal_tasks" ADD CONSTRAINT "internal_tasks_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk" FOREIGN KEY ("organization_id","product_id","relationship_id") REFERENCES "public"."relationships"("organization_id","product_id","id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "internal_tasks" ADD CONSTRAINT "internal_tasks_organization_id_owner_id_memberships_organization_id_user_id_fk" FOREIGN KEY ("organization_id","owner_id") REFERENCES "public"."memberships"("organization_id","user_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "native_drafts" ADD CONSTRAINT "native_drafts_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "native_drafts" ADD CONSTRAINT "native_drafts_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk" FOREIGN KEY ("organization_id","product_id","relationship_id") REFERENCES "public"."relationships"("organization_id","product_id","id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "native_drafts" ADD CONSTRAINT "native_drafts_organization_id_owner_id_memberships_organization_id_user_id_fk" FOREIGN KEY ("organization_id","owner_id") REFERENCES "public"."memberships"("organization_id","user_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "native_drafts" ADD CONSTRAINT "native_drafts_organization_id_product_id_source_conversation_id_conversations_organization_id_product_id_id_fk" FOREIGN KEY ("organization_id","product_id","source_conversation_id") REFERENCES "public"."conversations"("organization_id","product_id","id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "native_drafts" ADD CONSTRAINT "native_drafts_organization_id_product_id_scheduled_action_id_actions_organization_id_product_id_id_fk" FOREIGN KEY ("organization_id","product_id","scheduled_action_id") REFERENCES "public"."actions"("organization_id","product_id","id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "yodu_bindings" ADD CONSTRAINT "yodu_bindings_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "yodu_bindings" ADD CONSTRAINT "yodu_bindings_organization_id_product_id_source_id_yodu_sources_organization_id_product_id_id_fk" FOREIGN KEY ("organization_id","product_id","source_id") REFERENCES "public"."yodu_sources"("organization_id","product_id","id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "yodu_bindings" ADD CONSTRAINT "yodu_bindings_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk" FOREIGN KEY ("organization_id","product_id","relationship_id") REFERENCES "public"."relationships"("organization_id","product_id","id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "yodu_bindings" ADD CONSTRAINT "yodu_bindings_organization_id_created_by_memberships_organization_id_user_id_fk" FOREIGN KEY ("organization_id","created_by") REFERENCES "public"."memberships"("organization_id","user_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "yodu_events" ADD CONSTRAINT "yodu_events_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "yodu_events" ADD CONSTRAINT "yodu_events_organization_id_product_id_source_id_yodu_sources_organization_id_product_id_id_fk" FOREIGN KEY ("organization_id","product_id","source_id") REFERENCES "public"."yodu_sources"("organization_id","product_id","id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "yodu_sources" ADD CONSTRAINT "yodu_sources_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "yodu_sources" ADD CONSTRAINT "yodu_sources_organization_id_product_id_products_organization_id_id_fk" FOREIGN KEY ("organization_id","product_id") REFERENCES "public"."products"("organization_id","id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "yodu_sources" ADD CONSTRAINT "yodu_sources_organization_id_created_by_memberships_organization_id_user_id_fk" FOREIGN KEY ("organization_id","created_by") REFERENCES "public"."memberships"("organization_id","user_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
+CREATE INDEX "internal_tasks_organization_id_product_id_status_due_at_index" ON "internal_tasks" USING btree ("organization_id","product_id","status","due_at");--> statement-breakpoint
+CREATE UNIQUE INDEX "native_drafts_source" ON "native_drafts" USING btree ("organization_id","owner_id","source_id");--> statement-breakpoint
+CREATE INDEX "yodu_events_product_received" ON "yodu_events" USING btree ("organization_id","product_id","received_at","id");--> statement-breakpoint
+CREATE UNIQUE INDEX "conversations_native_source" ON "conversations" USING btree ("organization_id","owner_id","channel","external_thread_id") WHERE "conversations"."provenance" = 'native';--> statement-breakpoint
+CREATE UNIQUE INDEX "messages_native_source" ON "messages" USING btree ("conversation_id","provider_message_id") WHERE "messages"."connection_id" IS NULL;--> statement-breakpoint
+ALTER TABLE "conversations" ADD CONSTRAINT "conversation_provenance" CHECK (("conversations"."provenance" = 'provider') = ("conversations"."connection_id" IS NOT NULL));--> statement-breakpoint
+ALTER TABLE "messages" ADD CONSTRAINT "message_body_source" CHECK ("messages"."provider_message_id" <> '');--> statement-breakpoint
+CREATE POLICY "gravity_server_access" ON "internal_tasks" AS PERMISSIVE FOR ALL TO "gravity_app" USING (true) WITH CHECK (true);--> statement-breakpoint
+CREATE POLICY "gravity_server_access" ON "native_drafts" AS PERMISSIVE FOR ALL TO "gravity_app" USING (true) WITH CHECK (true);--> statement-breakpoint
+CREATE POLICY "gravity_server_access" ON "yodu_bindings" AS PERMISSIVE FOR ALL TO "gravity_app" USING (true) WITH CHECK (true);--> statement-breakpoint
+CREATE POLICY "gravity_server_access" ON "yodu_events" AS PERMISSIVE FOR ALL TO "gravity_app" USING (true) WITH CHECK (true);--> statement-breakpoint
+CREATE POLICY "gravity_server_access" ON "yodu_sources" AS PERMISSIVE FOR ALL TO "gravity_app" USING (true) WITH CHECK (true);
+--> statement-breakpoint
+GRANT SELECT, INSERT, UPDATE, DELETE ON TABLE public.internal_tasks, public.native_drafts, public.yodu_sources, public.yodu_bindings, public.yodu_events TO gravity_app;
+--> statement-breakpoint
+REVOKE ALL ON TABLE public.internal_tasks, public.native_drafts, public.yodu_sources, public.yodu_bindings, public.yodu_events FROM PUBLIC;
+--> statement-breakpoint
+DO $$ DECLARE api_role text; BEGIN
+ FOR api_role IN SELECT rolname FROM pg_roles WHERE rolname IN ('anon', 'authenticated', 'service_role') LOOP
+ EXECUTE format('REVOKE ALL ON TABLE public.internal_tasks, public.native_drafts, public.yodu_sources, public.yodu_bindings, public.yodu_events FROM %I', api_role);
+ END LOOP;
+END $$;
diff --git a/drizzle/0026_deal_archiving.sql b/drizzle/0026_deal_archiving.sql
new file mode 100644
index 00000000..a2de6184
--- /dev/null
+++ b/drizzle/0026_deal_archiving.sql
@@ -0,0 +1 @@
+ALTER TABLE "opportunities" ADD COLUMN "archived_at" timestamp with time zone;
\ No newline at end of file
diff --git a/drizzle/meta/0025_snapshot.json b/drizzle/meta/0025_snapshot.json
new file mode 100644
index 00000000..12ef00a7
--- /dev/null
+++ b/drizzle/meta/0025_snapshot.json
@@ -0,0 +1,9148 @@
+{
+ "id": "e9d16b77-7a90-4ceb-84f0-78ace310f6fe",
+ "prevId": "7f64b8da-258a-4e69-9e8c-aa2c10028dd5",
+ "version": "7",
+ "dialect": "postgresql",
+ "tables": {
+ "public.actions": {
+ "name": "actions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "relationship_id": {
+ "name": "relationship_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "enrollment_id": {
+ "name": "enrollment_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_conversation_id": {
+ "name": "source_conversation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reason": {
+ "name": "reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reason_source": {
+ "name": "reason_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owed_by": {
+ "name": "owed_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "channel": {
+ "name": "channel",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "due_at": {
+ "name": "due_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'open'"
+ },
+ "draft": {
+ "name": "draft",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "draft_hash": {
+ "name": "draft_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "approved_hash": {
+ "name": "approved_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "approved_by": {
+ "name": "approved_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "actions_organization_id_product_id_status_due_at_index": {
+ "name": "actions_organization_id_product_id_status_due_at_index",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "product_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "due_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "actions_organization_id_organizations_id_fk": {
+ "name": "actions_organization_id_organizations_id_fk",
+ "tableFrom": "actions",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "actions_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk": {
+ "name": "actions_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk",
+ "tableFrom": "actions",
+ "tableTo": "relationships",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "relationship_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "actions_organization_id_product_id_enrollment_id_enrollments_organization_id_product_id_id_fk": {
+ "name": "actions_organization_id_product_id_enrollment_id_enrollments_organization_id_product_id_id_fk",
+ "tableFrom": "actions",
+ "tableTo": "enrollments",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "enrollment_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "actions_organization_id_product_id_source_conversation_id_conversations_organization_id_product_id_id_fk": {
+ "name": "actions_organization_id_product_id_source_conversation_id_conversations_organization_id_product_id_id_fk",
+ "tableFrom": "actions",
+ "tableTo": "conversations",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "source_conversation_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "actions_organization_id_owner_id_memberships_organization_id_user_id_fk": {
+ "name": "actions_organization_id_owner_id_memberships_organization_id_user_id_fk",
+ "tableFrom": "actions",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "owner_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "actions_organization_id_product_id_id_unique": {
+ "name": "actions_organization_id_product_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "product_id",
+ "id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.asset_stages": {
+ "name": "asset_stages",
+ "schema": "",
+ "columns": {
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "asset_id": {
+ "name": "asset_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "stage_id": {
+ "name": "stage_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "asset_stages_organization_id_organizations_id_fk": {
+ "name": "asset_stages_organization_id_organizations_id_fk",
+ "tableFrom": "asset_stages",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "asset_stages_organization_id_product_id_asset_id_assets_organization_id_product_id_id_fk": {
+ "name": "asset_stages_organization_id_product_id_asset_id_assets_organization_id_product_id_id_fk",
+ "tableFrom": "asset_stages",
+ "tableTo": "assets",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "asset_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "asset_stages_organization_id_product_id_stage_id_stages_organization_id_product_id_id_fk": {
+ "name": "asset_stages_organization_id_product_id_stage_id_stages_organization_id_product_id_id_fk",
+ "tableFrom": "asset_stages",
+ "tableTo": "stages",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "stage_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "asset_stages_asset_id_stage_id_unique": {
+ "name": "asset_stages_asset_id_stage_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "asset_id",
+ "stage_id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.assets": {
+ "name": "assets",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "folder_id": {
+ "name": "folder_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "storage_key": {
+ "name": "storage_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mime_type": {
+ "name": "mime_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "size": {
+ "name": "size",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sha256": {
+ "name": "sha256",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'draft'"
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "uploaded_by": {
+ "name": "uploaded_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "assets_organization_id_organizations_id_fk": {
+ "name": "assets_organization_id_organizations_id_fk",
+ "tableFrom": "assets",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "assets_organization_id_product_id_folder_id_folders_organization_id_product_id_id_fk": {
+ "name": "assets_organization_id_product_id_folder_id_folders_organization_id_product_id_id_fk",
+ "tableFrom": "assets",
+ "tableTo": "folders",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "folder_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "assets_organization_id_uploaded_by_memberships_organization_id_user_id_fk": {
+ "name": "assets_organization_id_uploaded_by_memberships_organization_id_user_id_fk",
+ "tableFrom": "assets",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "uploaded_by"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "assets_organization_id_product_id_id_unique": {
+ "name": "assets_organization_id_product_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "product_id",
+ "id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {
+ "asset_size_valid": {
+ "name": "asset_size_valid",
+ "value": "\"assets\".\"size\" > 0 AND \"assets\".\"size\" <= 10485760"
+ }
+ },
+ "isRLSEnabled": true
+ },
+ "public.change_events": {
+ "name": "change_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_conversation_id": {
+ "name": "source_conversation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_id": {
+ "name": "actor_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "entity_id": {
+ "name": "entity_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "change_events_organization_id_created_at_index": {
+ "name": "change_events_organization_id_created_at_index",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "change_events_organization_id_organizations_id_fk": {
+ "name": "change_events_organization_id_organizations_id_fk",
+ "tableFrom": "change_events",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "change_events_organization_id_product_id_source_conversation_id_conversations_organization_id_product_id_id_fk": {
+ "name": "change_events_organization_id_product_id_source_conversation_id_conversations_organization_id_product_id_id_fk",
+ "tableFrom": "change_events",
+ "tableTo": "conversations",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "source_conversation_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "change_events_organization_id_product_id_products_organization_id_id_fk": {
+ "name": "change_events_organization_id_product_id_products_organization_id_id_fk",
+ "tableFrom": "change_events",
+ "tableTo": "products",
+ "columnsFrom": [
+ "organization_id",
+ "product_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.companies": {
+ "name": "companies",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "domain": {
+ "name": "domain",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "tags": {
+ "name": "tags",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "amount_minor": {
+ "name": "amount_minor",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "currency": {
+ "name": "currency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'USD'"
+ }
+ },
+ "indexes": {
+ "companies_browse": {
+ "name": "companies_browse",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "companies_organization_id_organizations_id_fk": {
+ "name": "companies_organization_id_organizations_id_fk",
+ "tableFrom": "companies",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "companies_organization_id_id_unique": {
+ "name": "companies_organization_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {
+ "company_amount_nonnegative": {
+ "name": "company_amount_nonnegative",
+ "value": "\"companies\".\"amount_minor\" IS NULL OR \"companies\".\"amount_minor\" >= 0"
+ },
+ "company_currency_valid": {
+ "name": "company_currency_valid",
+ "value": "\"companies\".\"currency\" ~ '^[A-Z]{3}$'"
+ }
+ },
+ "isRLSEnabled": true
+ },
+ "public.connections": {
+ "name": "connections",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "external_account_id": {
+ "name": "external_account_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_configuration_id": {
+ "name": "provider_configuration_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "display_name": {
+ "name": "display_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "encrypted_credentials": {
+ "name": "encrypted_credentials",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scopes": {
+ "name": "scopes",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "sync_cursor": {
+ "name": "sync_cursor",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "last_synced_at": {
+ "name": "last_synced_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error_code": {
+ "name": "error_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lease_id": {
+ "name": "lease_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lease_until": {
+ "name": "lease_until",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "webhook_secret": {
+ "name": "webhook_secret",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'disconnected'"
+ },
+ "self_email": {
+ "name": "self_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "inbox_folder_ids": {
+ "name": "inbox_folder_ids",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "sent_folder_ids": {
+ "name": "sent_folder_ids",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ }
+ },
+ "indexes": {
+ "connections_legacy_provider_account": {
+ "name": "connections_legacy_provider_account",
+ "columns": [
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "external_account_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"connections\".\"provider_configuration_id\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "connections_organization_id_organizations_id_fk": {
+ "name": "connections_organization_id_organizations_id_fk",
+ "tableFrom": "connections",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "connections_organization_id_product_id_products_organization_id_id_fk": {
+ "name": "connections_organization_id_product_id_products_organization_id_id_fk",
+ "tableFrom": "connections",
+ "tableTo": "products",
+ "columnsFrom": [
+ "organization_id",
+ "product_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "connections_organization_id_owner_id_provider_configuration_id_provider_configurations_organization_id_owner_id_id_fk": {
+ "name": "connections_organization_id_owner_id_provider_configuration_id_provider_configurations_organization_id_owner_id_id_fk",
+ "tableFrom": "connections",
+ "tableTo": "provider_configurations",
+ "columnsFrom": [
+ "organization_id",
+ "owner_id",
+ "provider_configuration_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "owner_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "connections_organization_id_owner_id_memberships_organization_id_user_id_fk": {
+ "name": "connections_organization_id_owner_id_memberships_organization_id_user_id_fk",
+ "tableFrom": "connections",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "owner_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "connections_organization_id_id_unique": {
+ "name": "connections_organization_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "id"
+ ]
+ },
+ "connections_provider_provider_configuration_id_external_account_id_unique": {
+ "name": "connections_provider_provider_configuration_id_external_account_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "provider",
+ "provider_configuration_id",
+ "external_account_id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.connector_events": {
+ "name": "connector_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "connection_id": {
+ "name": "connection_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_event_id": {
+ "name": "provider_event_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "connector_events_organization_id_organizations_id_fk": {
+ "name": "connector_events_organization_id_organizations_id_fk",
+ "tableFrom": "connector_events",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "connector_events_organization_id_connection_id_connections_organization_id_id_fk": {
+ "name": "connector_events_organization_id_connection_id_connections_organization_id_id_fk",
+ "tableFrom": "connector_events",
+ "tableTo": "connections",
+ "columnsFrom": [
+ "organization_id",
+ "connection_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "connector_events_connection_id_provider_event_id_unique": {
+ "name": "connector_events_connection_id_provider_event_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "connection_id",
+ "provider_event_id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.contact_contributions": {
+ "name": "contact_contributions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "person_id": {
+ "name": "person_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_id": {
+ "name": "actor_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_member_id": {
+ "name": "source_member_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "transport": {
+ "name": "transport",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "grant_id": {
+ "name": "grant_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "batch_id": {
+ "name": "batch_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_record_id": {
+ "name": "source_record_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "request_hash": {
+ "name": "request_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "connection_id": {
+ "name": "connection_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_conversation_id": {
+ "name": "source_conversation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "contact_contributions_person": {
+ "name": "contact_contributions_person",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "person_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "contact_contributions_actor": {
+ "name": "contact_contributions_actor",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "actor_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "person_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "contact_contributions_batch_row": {
+ "name": "contact_contributions_batch_row",
+ "columns": [
+ {
+ "expression": "batch_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_record_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "contact_contributions_provider_row": {
+ "name": "contact_contributions_provider_row",
+ "columns": [
+ {
+ "expression": "connection_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_record_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "contact_contributions_original_creator": {
+ "name": "contact_contributions_original_creator",
+ "columns": [
+ {
+ "expression": "person_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"contact_contributions\".\"kind\" = 'created'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "contact_contributions_organization_id_organizations_id_fk": {
+ "name": "contact_contributions_organization_id_organizations_id_fk",
+ "tableFrom": "contact_contributions",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "contact_contributions_organization_id_person_id_people_organization_id_id_fk": {
+ "name": "contact_contributions_organization_id_person_id_people_organization_id_id_fk",
+ "tableFrom": "contact_contributions",
+ "tableTo": "people",
+ "columnsFrom": [
+ "organization_id",
+ "person_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "contact_contributions_organization_id_product_id_products_organization_id_id_fk": {
+ "name": "contact_contributions_organization_id_product_id_products_organization_id_id_fk",
+ "tableFrom": "contact_contributions",
+ "tableTo": "products",
+ "columnsFrom": [
+ "organization_id",
+ "product_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "contact_contributions_organization_id_actor_id_memberships_organization_id_user_id_fk": {
+ "name": "contact_contributions_organization_id_actor_id_memberships_organization_id_user_id_fk",
+ "tableFrom": "contact_contributions",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "actor_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "contact_contributions_organization_id_source_member_id_memberships_organization_id_user_id_fk": {
+ "name": "contact_contributions_organization_id_source_member_id_memberships_organization_id_user_id_fk",
+ "tableFrom": "contact_contributions",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "source_member_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "contact_contributions_organization_id_product_id_batch_id_contact_import_batches_organization_id_product_id_id_fk": {
+ "name": "contact_contributions_organization_id_product_id_batch_id_contact_import_batches_organization_id_product_id_id_fk",
+ "tableFrom": "contact_contributions",
+ "tableTo": "contact_import_batches",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "batch_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "contact_contributions_organization_id_connection_id_connections_organization_id_id_fk": {
+ "name": "contact_contributions_organization_id_connection_id_connections_organization_id_id_fk",
+ "tableFrom": "contact_contributions",
+ "tableTo": "connections",
+ "columnsFrom": [
+ "organization_id",
+ "connection_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "contact_contributions_organization_id_product_id_source_conversation_id_conversations_organization_id_product_id_id_fk": {
+ "name": "contact_contributions_organization_id_product_id_source_conversation_id_conversations_organization_id_product_id_id_fk",
+ "tableFrom": "contact_contributions",
+ "tableTo": "conversations",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "source_conversation_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {
+ "contact_contribution_batch_row": {
+ "name": "contact_contribution_batch_row",
+ "value": "((\"contact_contributions\".\"batch_id\" IS NULL) = (\"contact_contributions\".\"request_hash\" IS NULL)) AND (\"contact_contributions\".\"batch_id\" IS NULL OR (\"contact_contributions\".\"product_id\" IS NOT NULL AND \"contact_contributions\".\"source_record_id\" IS NOT NULL))"
+ }
+ },
+ "isRLSEnabled": true
+ },
+ "public.contact_import_batches": {
+ "name": "contact_import_batches",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "submitted_by": {
+ "name": "submitted_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_member_id": {
+ "name": "source_member_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_kind": {
+ "name": "source_kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "label": {
+ "name": "label",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "submission_key": {
+ "name": "submission_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "transport": {
+ "name": "transport",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "grant_id": {
+ "name": "grant_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "contact_import_batches_organization_id_organizations_id_fk": {
+ "name": "contact_import_batches_organization_id_organizations_id_fk",
+ "tableFrom": "contact_import_batches",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "contact_import_batches_organization_id_product_id_products_organization_id_id_fk": {
+ "name": "contact_import_batches_organization_id_product_id_products_organization_id_id_fk",
+ "tableFrom": "contact_import_batches",
+ "tableTo": "products",
+ "columnsFrom": [
+ "organization_id",
+ "product_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "contact_import_batches_organization_id_submitted_by_memberships_organization_id_user_id_fk": {
+ "name": "contact_import_batches_organization_id_submitted_by_memberships_organization_id_user_id_fk",
+ "tableFrom": "contact_import_batches",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "submitted_by"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "contact_import_batches_organization_id_source_member_id_memberships_organization_id_user_id_fk": {
+ "name": "contact_import_batches_organization_id_source_member_id_memberships_organization_id_user_id_fk",
+ "tableFrom": "contact_import_batches",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "source_member_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "contact_import_batches_organization_id_product_id_id_unique": {
+ "name": "contact_import_batches_organization_id_product_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "product_id",
+ "id"
+ ]
+ },
+ "contact_import_batches_organization_id_submitted_by_submission_key_unique": {
+ "name": "contact_import_batches_organization_id_submitted_by_submission_key_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "submitted_by",
+ "submission_key"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.contact_rules": {
+ "name": "contact_rules",
+ "schema": "",
+ "columns": {
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "cooldown_days": {
+ "name": "cooldown_days",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "daily_cap_per_sender": {
+ "name": "daily_cap_per_sender",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "quiet_hours_start": {
+ "name": "quiet_hours_start",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "quiet_hours_end": {
+ "name": "quiet_hours_end",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "contact_rules_organization_id_organizations_id_fk": {
+ "name": "contact_rules_organization_id_organizations_id_fk",
+ "tableFrom": "contact_rules",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {
+ "contact_rules_cooldown": {
+ "name": "contact_rules_cooldown",
+ "value": "\"contact_rules\".\"cooldown_days\" BETWEEN 0 AND 365"
+ },
+ "contact_rules_cap": {
+ "name": "contact_rules_cap",
+ "value": "\"contact_rules\".\"daily_cap_per_sender\" BETWEEN 1 AND 10000"
+ },
+ "contact_rules_quiet_hours": {
+ "name": "contact_rules_quiet_hours",
+ "value": "\"contact_rules\".\"quiet_hours_start\" BETWEEN 0 AND 23 AND \"contact_rules\".\"quiet_hours_end\" BETWEEN 0 AND 23"
+ }
+ },
+ "isRLSEnabled": true
+ },
+ "public.conversations": {
+ "name": "conversations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "relationship_id": {
+ "name": "relationship_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "connection_id": {
+ "name": "connection_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provenance": {
+ "name": "provenance",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'provider'"
+ },
+ "external_thread_id": {
+ "name": "external_thread_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "visibility": {
+ "name": "visibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'private'"
+ },
+ "channel": {
+ "name": "channel",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "conversations_native_source": {
+ "name": "conversations_native_source",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "channel",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "external_thread_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"conversations\".\"provenance\" = 'native'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "conversations_organization_id_organizations_id_fk": {
+ "name": "conversations_organization_id_organizations_id_fk",
+ "tableFrom": "conversations",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "conversations_organization_id_connection_id_connections_organization_id_id_fk": {
+ "name": "conversations_organization_id_connection_id_connections_organization_id_id_fk",
+ "tableFrom": "conversations",
+ "tableTo": "connections",
+ "columnsFrom": [
+ "organization_id",
+ "connection_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "conversations_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk": {
+ "name": "conversations_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk",
+ "tableFrom": "conversations",
+ "tableTo": "relationships",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "relationship_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "conversations_organization_id_owner_id_memberships_organization_id_user_id_fk": {
+ "name": "conversations_organization_id_owner_id_memberships_organization_id_user_id_fk",
+ "tableFrom": "conversations",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "owner_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "conversations_organization_id_product_id_id_unique": {
+ "name": "conversations_organization_id_product_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "product_id",
+ "id"
+ ]
+ },
+ "conversations_connection_id_external_thread_id_unique": {
+ "name": "conversations_connection_id_external_thread_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "connection_id",
+ "external_thread_id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {
+ "conversation_provenance": {
+ "name": "conversation_provenance",
+ "value": "(\"conversations\".\"provenance\" = 'provider') = (\"conversations\".\"connection_id\" IS NOT NULL)"
+ }
+ },
+ "isRLSEnabled": true
+ },
+ "public.deliveries": {
+ "name": "deliveries",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "relationship_id": {
+ "name": "relationship_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "connection_id": {
+ "name": "connection_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "touch_id": {
+ "name": "touch_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "action_id": {
+ "name": "action_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_version": {
+ "name": "source_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "idempotency_key": {
+ "name": "idempotency_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "request_hash": {
+ "name": "request_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "channel": {
+ "name": "channel",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "recipient": {
+ "name": "recipient",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "draft": {
+ "name": "draft",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "subject": {
+ "name": "subject",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "external_thread_id": {
+ "name": "external_thread_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "external_message_id": {
+ "name": "external_message_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "error_code": {
+ "name": "error_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "sent_at": {
+ "name": "sent_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "deliveries_touch_claim": {
+ "name": "deliveries_touch_claim",
+ "columns": [
+ {
+ "expression": "touch_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"deliveries\".\"status\" <> 'failed'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "deliveries_action_claim": {
+ "name": "deliveries_action_claim",
+ "columns": [
+ {
+ "expression": "action_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_version",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"deliveries\".\"status\" <> 'failed'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "deliveries_sender_day": {
+ "name": "deliveries_sender_day",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "deliveries_organization_id_organizations_id_fk": {
+ "name": "deliveries_organization_id_organizations_id_fk",
+ "tableFrom": "deliveries",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "deliveries_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk": {
+ "name": "deliveries_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk",
+ "tableFrom": "deliveries",
+ "tableTo": "relationships",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "relationship_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "deliveries_organization_id_product_id_touch_id_touches_organization_id_product_id_id_fk": {
+ "name": "deliveries_organization_id_product_id_touch_id_touches_organization_id_product_id_id_fk",
+ "tableFrom": "deliveries",
+ "tableTo": "touches",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "touch_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "deliveries_organization_id_product_id_action_id_actions_organization_id_product_id_id_fk": {
+ "name": "deliveries_organization_id_product_id_action_id_actions_organization_id_product_id_id_fk",
+ "tableFrom": "deliveries",
+ "tableTo": "actions",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "action_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "deliveries_organization_id_connection_id_connections_organization_id_id_fk": {
+ "name": "deliveries_organization_id_connection_id_connections_organization_id_id_fk",
+ "tableFrom": "deliveries",
+ "tableTo": "connections",
+ "columnsFrom": [
+ "organization_id",
+ "connection_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "deliveries_organization_id_owner_id_memberships_organization_id_user_id_fk": {
+ "name": "deliveries_organization_id_owner_id_memberships_organization_id_user_id_fk",
+ "tableFrom": "deliveries",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "owner_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "deliveries_organization_id_owner_id_idempotency_key_unique": {
+ "name": "deliveries_organization_id_owner_id_idempotency_key_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "owner_id",
+ "idempotency_key"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {
+ "delivery_source": {
+ "name": "delivery_source",
+ "value": "(\"deliveries\".\"touch_id\" IS NOT NULL) <> (\"deliveries\".\"action_id\" IS NOT NULL)"
+ },
+ "delivery_status": {
+ "name": "delivery_status",
+ "value": "\"deliveries\".\"status\" IN ('sending', 'unknown', 'accepted', 'sent', 'failed')"
+ }
+ },
+ "isRLSEnabled": true
+ },
+ "public.enrollments": {
+ "name": "enrollments",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "relationship_id": {
+ "name": "relationship_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sequence_id": {
+ "name": "sequence_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pause_reason": {
+ "name": "pause_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "step": {
+ "name": "step",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "enrolled_at": {
+ "name": "enrolled_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ }
+ },
+ "indexes": {
+ "enrollments_active_relationship_sequence": {
+ "name": "enrollments_active_relationship_sequence",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "relationship_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "sequence_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"enrollments\".\"status\" IN ('running', 'paused')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "enrollments_organization_id_organizations_id_fk": {
+ "name": "enrollments_organization_id_organizations_id_fk",
+ "tableFrom": "enrollments",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "enrollments_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk": {
+ "name": "enrollments_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk",
+ "tableFrom": "enrollments",
+ "tableTo": "relationships",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "relationship_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "enrollments_organization_id_product_id_sequence_id_sequences_organization_id_product_id_id_fk": {
+ "name": "enrollments_organization_id_product_id_sequence_id_sequences_organization_id_product_id_id_fk",
+ "tableFrom": "enrollments",
+ "tableTo": "sequences",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "sequence_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "enrollments_organization_id_product_id_id_unique": {
+ "name": "enrollments_organization_id_product_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "product_id",
+ "id"
+ ]
+ },
+ "enrollments_organization_id_product_id_relationship_id_id_unique": {
+ "name": "enrollments_organization_id_product_id_relationship_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "product_id",
+ "relationship_id",
+ "id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {
+ "enrollment_pause_reason": {
+ "name": "enrollment_pause_reason",
+ "value": "(\"enrollments\".\"status\" = 'paused') = (\"enrollments\".\"pause_reason\" IS NOT NULL)"
+ }
+ },
+ "isRLSEnabled": true
+ },
+ "public.evidence": {
+ "name": "evidence",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "relationship_id": {
+ "name": "relationship_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "excerpt": {
+ "name": "excerpt",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "classification": {
+ "name": "classification",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "evidence_organization_id_organizations_id_fk": {
+ "name": "evidence_organization_id_organizations_id_fk",
+ "tableFrom": "evidence",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "evidence_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk": {
+ "name": "evidence_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk",
+ "tableFrom": "evidence",
+ "tableTo": "relationships",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "relationship_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.file_entry": {
+ "name": "file_entry",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "parent_id": {
+ "name": "parent_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "visibility": {
+ "name": "visibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'private'"
+ },
+ "grants": {
+ "name": "grants",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "public_token": {
+ "name": "public_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "storage_key": {
+ "name": "storage_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mime_type": {
+ "name": "mime_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "size": {
+ "name": "size",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "sync_id": {
+ "name": "sync_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "file_entry_parent_idx": {
+ "name": "file_entry_parent_idx",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "product_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "parent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "file_entry_name_unique": {
+ "name": "file_entry_name_unique",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "product_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "coalesce(\"parent_id\"::text, '')",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "lower(\"name\")",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "file_entry_public_token_unique": {
+ "name": "file_entry_public_token_unique",
+ "columns": [
+ {
+ "expression": "public_token",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "file_entry_organization_id_organizations_id_fk": {
+ "name": "file_entry_organization_id_organizations_id_fk",
+ "tableFrom": "file_entry",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "file_entry_organization_id_product_id_products_organization_id_id_fk": {
+ "name": "file_entry_organization_id_product_id_products_organization_id_id_fk",
+ "tableFrom": "file_entry",
+ "tableTo": "products",
+ "columnsFrom": [
+ "organization_id",
+ "product_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "file_entry_organization_id_owner_id_memberships_organization_id_user_id_fk": {
+ "name": "file_entry_organization_id_owner_id_memberships_organization_id_user_id_fk",
+ "tableFrom": "file_entry",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "owner_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "file_entry_organization_id_product_id_parent_id_file_entry_organization_id_product_id_id_fk": {
+ "name": "file_entry_organization_id_product_id_parent_id_file_entry_organization_id_product_id_id_fk",
+ "tableFrom": "file_entry",
+ "tableTo": "file_entry",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "parent_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "file_entry_scope_id": {
+ "name": "file_entry_scope_id",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "product_id",
+ "id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {
+ "file_entry_kind": {
+ "name": "file_entry_kind",
+ "value": "\"file_entry\".\"kind\" in ('folder','markdown','file')"
+ },
+ "file_entry_visibility": {
+ "name": "file_entry_visibility",
+ "value": "\"file_entry\".\"visibility\" in ('private','workspace','public','shared','inherit')"
+ },
+ "file_entry_inherit_parent": {
+ "name": "file_entry_inherit_parent",
+ "value": "\"file_entry\".\"visibility\" <> 'inherit' or \"file_entry\".\"parent_id\" is not null"
+ },
+ "file_entry_no_self_parent": {
+ "name": "file_entry_no_self_parent",
+ "value": "\"file_entry\".\"parent_id\" is distinct from \"file_entry\".\"id\""
+ },
+ "file_entry_size": {
+ "name": "file_entry_size",
+ "value": "\"file_entry\".\"size\" between 0 and 104857600"
+ }
+ },
+ "isRLSEnabled": true
+ },
+ "public.file_upload": {
+ "name": "file_upload",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "parent_id": {
+ "name": "parent_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mime_type": {
+ "name": "mime_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "size": {
+ "name": "size",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "storage_key": {
+ "name": "storage_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "file_upload_organization_id_organizations_id_fk": {
+ "name": "file_upload_organization_id_organizations_id_fk",
+ "tableFrom": "file_upload",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "file_upload_organization_id_product_id_products_organization_id_id_fk": {
+ "name": "file_upload_organization_id_product_id_products_organization_id_id_fk",
+ "tableFrom": "file_upload",
+ "tableTo": "products",
+ "columnsFrom": [
+ "organization_id",
+ "product_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "file_upload_organization_id_owner_id_memberships_organization_id_user_id_fk": {
+ "name": "file_upload_organization_id_owner_id_memberships_organization_id_user_id_fk",
+ "tableFrom": "file_upload",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "owner_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "file_upload_organization_id_product_id_parent_id_file_entry_organization_id_product_id_id_fk": {
+ "name": "file_upload_organization_id_product_id_parent_id_file_entry_organization_id_product_id_id_fk",
+ "tableFrom": "file_upload",
+ "tableTo": "file_entry",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "parent_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {
+ "file_upload_size": {
+ "name": "file_upload_size",
+ "value": "\"file_upload\".\"size\" between 0 and 104857600"
+ }
+ },
+ "isRLSEnabled": true
+ },
+ "public.folders": {
+ "name": "folders",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "parent_id": {
+ "name": "parent_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "folders_organization_id_organizations_id_fk": {
+ "name": "folders_organization_id_organizations_id_fk",
+ "tableFrom": "folders",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "folders_organization_id_product_id_products_organization_id_id_fk": {
+ "name": "folders_organization_id_product_id_products_organization_id_id_fk",
+ "tableFrom": "folders",
+ "tableTo": "products",
+ "columnsFrom": [
+ "organization_id",
+ "product_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "folders_organization_id_product_id_parent_id_folders_organization_id_product_id_id_fk": {
+ "name": "folders_organization_id_product_id_parent_id_folders_organization_id_product_id_id_fk",
+ "tableFrom": "folders",
+ "tableTo": "folders",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "parent_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "folders_organization_id_product_id_id_unique": {
+ "name": "folders_organization_id_product_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "product_id",
+ "id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {
+ "folder_not_self_parent": {
+ "name": "folder_not_self_parent",
+ "value": "\"folders\".\"parent_id\" IS NULL OR \"folders\".\"parent_id\" <> \"folders\".\"id\""
+ }
+ },
+ "isRLSEnabled": true
+ },
+ "public.integration_flows": {
+ "name": "integration_flows",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "state_hash": {
+ "name": "state_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_verifier": {
+ "name": "encrypted_verifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "connection_id": {
+ "name": "connection_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "consumed_at": {
+ "name": "consumed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "integration_flows_organization_id_organizations_id_fk": {
+ "name": "integration_flows_organization_id_organizations_id_fk",
+ "tableFrom": "integration_flows",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "integration_flows_organization_id_product_id_products_organization_id_id_fk": {
+ "name": "integration_flows_organization_id_product_id_products_organization_id_id_fk",
+ "tableFrom": "integration_flows",
+ "tableTo": "products",
+ "columnsFrom": [
+ "organization_id",
+ "product_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "integration_flows_organization_id_owner_id_memberships_organization_id_user_id_fk": {
+ "name": "integration_flows_organization_id_owner_id_memberships_organization_id_user_id_fk",
+ "tableFrom": "integration_flows",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "owner_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "integration_flows_organization_id_connection_id_connections_organization_id_id_fk": {
+ "name": "integration_flows_organization_id_connection_id_connections_organization_id_id_fk",
+ "tableFrom": "integration_flows",
+ "tableTo": "connections",
+ "columnsFrom": [
+ "organization_id",
+ "connection_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "integration_flows_state_hash_unique": {
+ "name": "integration_flows_state_hash_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "state_hash"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.integration_items": {
+ "name": "integration_items",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "connection_id": {
+ "name": "connection_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "external_id": {
+ "name": "external_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "record": {
+ "name": "record",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'unmatched'"
+ },
+ "relationship_id": {
+ "name": "relationship_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "entity_id": {
+ "name": "entity_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "integration_items_organization_id_connection_id_status_index": {
+ "name": "integration_items_organization_id_connection_id_status_index",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "connection_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "integration_items_organization_id_organizations_id_fk": {
+ "name": "integration_items_organization_id_organizations_id_fk",
+ "tableFrom": "integration_items",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "integration_items_organization_id_connection_id_connections_organization_id_id_fk": {
+ "name": "integration_items_organization_id_connection_id_connections_organization_id_id_fk",
+ "tableFrom": "integration_items",
+ "tableTo": "connections",
+ "columnsFrom": [
+ "organization_id",
+ "connection_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "integration_items_organization_id_product_id_products_organization_id_id_fk": {
+ "name": "integration_items_organization_id_product_id_products_organization_id_id_fk",
+ "tableFrom": "integration_items",
+ "tableTo": "products",
+ "columnsFrom": [
+ "organization_id",
+ "product_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "integration_items_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk": {
+ "name": "integration_items_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk",
+ "tableFrom": "integration_items",
+ "tableTo": "relationships",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "relationship_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "integration_items_connection_id_external_id_unique": {
+ "name": "integration_items_connection_id_external_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "connection_id",
+ "external_id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.integration_receipts": {
+ "name": "integration_receipts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "connection_id": {
+ "name": "connection_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "external_id": {
+ "name": "external_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "attempts": {
+ "name": "attempts",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "error_code": {
+ "name": "error_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "next_attempt_at": {
+ "name": "next_attempt_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "lease_until": {
+ "name": "lease_until",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "processed_at": {
+ "name": "processed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "integration_receipts_processed_at_next_attempt_at_index": {
+ "name": "integration_receipts_processed_at_next_attempt_at_index",
+ "columns": [
+ {
+ "expression": "processed_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "next_attempt_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "integration_receipts_organization_id_organizations_id_fk": {
+ "name": "integration_receipts_organization_id_organizations_id_fk",
+ "tableFrom": "integration_receipts",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "integration_receipts_organization_id_connection_id_connections_organization_id_id_fk": {
+ "name": "integration_receipts_organization_id_connection_id_connections_organization_id_id_fk",
+ "tableFrom": "integration_receipts",
+ "tableTo": "connections",
+ "columnsFrom": [
+ "organization_id",
+ "connection_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "integration_receipts_connection_id_external_id_unique": {
+ "name": "integration_receipts_connection_id_external_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "connection_id",
+ "external_id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.internal_tasks": {
+ "name": "internal_tasks",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "relationship_id": {
+ "name": "relationship_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "due_at": {
+ "name": "due_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "time_zone": {
+ "name": "time_zone",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "recurrence": {
+ "name": "recurrence",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'open'"
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "internal_tasks_organization_id_product_id_status_due_at_index": {
+ "name": "internal_tasks_organization_id_product_id_status_due_at_index",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "product_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "due_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "internal_tasks_organization_id_organizations_id_fk": {
+ "name": "internal_tasks_organization_id_organizations_id_fk",
+ "tableFrom": "internal_tasks",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "internal_tasks_organization_id_product_id_products_organization_id_id_fk": {
+ "name": "internal_tasks_organization_id_product_id_products_organization_id_id_fk",
+ "tableFrom": "internal_tasks",
+ "tableTo": "products",
+ "columnsFrom": [
+ "organization_id",
+ "product_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "internal_tasks_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk": {
+ "name": "internal_tasks_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk",
+ "tableFrom": "internal_tasks",
+ "tableTo": "relationships",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "relationship_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "internal_tasks_organization_id_owner_id_memberships_organization_id_user_id_fk": {
+ "name": "internal_tasks_organization_id_owner_id_memberships_organization_id_user_id_fk",
+ "tableFrom": "internal_tasks",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "owner_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "internal_tasks_organization_id_product_id_id_unique": {
+ "name": "internal_tasks_organization_id_product_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "product_id",
+ "id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.invitations": {
+ "name": "invitations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_ids": {
+ "name": "product_ids",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token_hash": {
+ "name": "token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "inviter_id": {
+ "name": "inviter_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "accepted_at": {
+ "name": "accepted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "invitations_organization_idx": {
+ "name": "invitations_organization_idx",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "invitations_pending_email": {
+ "name": "invitations_pending_email",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "email",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"invitations\".\"accepted_at\" IS NULL AND \"invitations\".\"revoked_at\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "invitations_organization_id_organizations_id_fk": {
+ "name": "invitations_organization_id_organizations_id_fk",
+ "tableFrom": "invitations",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "invitations_inviter_id_user_id_fk": {
+ "name": "invitations_inviter_id_user_id_fk",
+ "tableFrom": "invitations",
+ "tableTo": "user",
+ "columnsFrom": [
+ "inviter_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "invitations_token_hash_unique": {
+ "name": "invitations_token_hash_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "token_hash"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {
+ "invitation_email_lowercase": {
+ "name": "invitation_email_lowercase",
+ "value": "\"invitations\".\"email\" = lower(\"invitations\".\"email\")"
+ },
+ "invitation_single_outcome": {
+ "name": "invitation_single_outcome",
+ "value": "\"invitations\".\"accepted_at\" IS NULL OR \"invitations\".\"revoked_at\" IS NULL"
+ }
+ },
+ "isRLSEnabled": true
+ },
+ "public.mcp_grants": {
+ "name": "mcp_grants",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_ids": {
+ "name": "product_ids",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "active": {
+ "name": "active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "mcp_grants_organization_id_organizations_id_fk": {
+ "name": "mcp_grants_organization_id_organizations_id_fk",
+ "tableFrom": "mcp_grants",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "mcp_grants_user_id_user_id_fk": {
+ "name": "mcp_grants_user_id_user_id_fk",
+ "tableFrom": "mcp_grants",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "mcp_grants_organization_id_user_id_memberships_organization_id_user_id_fk": {
+ "name": "mcp_grants_organization_id_user_id_memberships_organization_id_user_id_fk",
+ "tableFrom": "mcp_grants",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "user_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.meetings": {
+ "name": "meetings",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "relationship_id": {
+ "name": "relationship_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "starts_at": {
+ "name": "starts_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "summary": {
+ "name": "summary",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "proposed_commitment": {
+ "name": "proposed_commitment",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "commitment_action_id": {
+ "name": "commitment_action_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "meetings_organization_id_organizations_id_fk": {
+ "name": "meetings_organization_id_organizations_id_fk",
+ "tableFrom": "meetings",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "meetings_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk": {
+ "name": "meetings_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk",
+ "tableFrom": "meetings",
+ "tableTo": "relationships",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "relationship_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "meetings_organization_id_product_id_commitment_action_id_actions_organization_id_product_id_id_fk": {
+ "name": "meetings_organization_id_product_id_commitment_action_id_actions_organization_id_product_id_id_fk",
+ "tableFrom": "meetings",
+ "tableTo": "actions",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "commitment_action_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.memberships": {
+ "name": "memberships",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "active": {
+ "name": "active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "memberships_organization_id_organizations_id_fk": {
+ "name": "memberships_organization_id_organizations_id_fk",
+ "tableFrom": "memberships",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "memberships_user_id_user_id_fk": {
+ "name": "memberships_user_id_user_id_fk",
+ "tableFrom": "memberships",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "memberships_organization_id_user_id_unique": {
+ "name": "memberships_organization_id_user_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "user_id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.messages": {
+ "name": "messages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "conversation_id": {
+ "name": "conversation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "connection_id": {
+ "name": "connection_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider_message_id": {
+ "name": "provider_message_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "direction": {
+ "name": "direction",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "occurred_at": {
+ "name": "occurred_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "messages_native_source": {
+ "name": "messages_native_source",
+ "columns": [
+ {
+ "expression": "conversation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider_message_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"messages\".\"connection_id\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "messages_activity_idx": {
+ "name": "messages_activity_idx",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "product_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "occurred_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "messages_organization_id_organizations_id_fk": {
+ "name": "messages_organization_id_organizations_id_fk",
+ "tableFrom": "messages",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "messages_organization_id_product_id_conversation_id_conversations_organization_id_product_id_id_fk": {
+ "name": "messages_organization_id_product_id_conversation_id_conversations_organization_id_product_id_id_fk",
+ "tableFrom": "messages",
+ "tableTo": "conversations",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "conversation_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "messages_organization_id_connection_id_connections_organization_id_id_fk": {
+ "name": "messages_organization_id_connection_id_connections_organization_id_id_fk",
+ "tableFrom": "messages",
+ "tableTo": "connections",
+ "columnsFrom": [
+ "organization_id",
+ "connection_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "messages_connection_id_provider_message_id_unique": {
+ "name": "messages_connection_id_provider_message_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "connection_id",
+ "provider_message_id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {
+ "message_body_source": {
+ "name": "message_body_source",
+ "value": "\"messages\".\"provider_message_id\" <> ''"
+ }
+ },
+ "isRLSEnabled": true
+ },
+ "public.native_drafts": {
+ "name": "native_drafts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "relationship_id": {
+ "name": "relationship_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_conversation_id": {
+ "name": "source_conversation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "channel": {
+ "name": "channel",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reason": {
+ "name": "reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_id": {
+ "name": "source_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_hash": {
+ "name": "source_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scheduled_action_id": {
+ "name": "scheduled_action_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "native_drafts_source": {
+ "name": "native_drafts_source",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "native_drafts_organization_id_organizations_id_fk": {
+ "name": "native_drafts_organization_id_organizations_id_fk",
+ "tableFrom": "native_drafts",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "native_drafts_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk": {
+ "name": "native_drafts_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk",
+ "tableFrom": "native_drafts",
+ "tableTo": "relationships",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "relationship_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "native_drafts_organization_id_owner_id_memberships_organization_id_user_id_fk": {
+ "name": "native_drafts_organization_id_owner_id_memberships_organization_id_user_id_fk",
+ "tableFrom": "native_drafts",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "owner_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "native_drafts_organization_id_product_id_source_conversation_id_conversations_organization_id_product_id_id_fk": {
+ "name": "native_drafts_organization_id_product_id_source_conversation_id_conversations_organization_id_product_id_id_fk",
+ "tableFrom": "native_drafts",
+ "tableTo": "conversations",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "source_conversation_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "native_drafts_organization_id_product_id_scheduled_action_id_actions_organization_id_product_id_id_fk": {
+ "name": "native_drafts_organization_id_product_id_scheduled_action_id_actions_organization_id_product_id_id_fk",
+ "tableFrom": "native_drafts",
+ "tableTo": "actions",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "scheduled_action_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "native_drafts_organization_id_product_id_id_unique": {
+ "name": "native_drafts_organization_id_product_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "product_id",
+ "id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {
+ "native_draft_source_hash": {
+ "name": "native_draft_source_hash",
+ "value": "\"native_drafts\".\"source_hash\" ~ '^[a-f0-9]{64}$'"
+ }
+ },
+ "isRLSEnabled": true
+ },
+ "public.oauth_selections": {
+ "name": "oauth_selections",
+ "schema": "",
+ "columns": {
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "flow_key": {
+ "name": "flow_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "grant_id": {
+ "name": "grant_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "oauth_selections_grant_id_mcp_grants_id_fk": {
+ "name": "oauth_selections_grant_id_mcp_grants_id_fk",
+ "tableFrom": "oauth_selections",
+ "tableTo": "mcp_grants",
+ "columnsFrom": [
+ "grant_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "oauth_selections_session_id_flow_key_pk": {
+ "name": "oauth_selections_session_id_flow_key_pk",
+ "columns": [
+ "session_id",
+ "flow_key"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.opportunities": {
+ "name": "opportunities",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "relationship_id": {
+ "name": "relationship_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "stage_id": {
+ "name": "stage_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "amount_minor": {
+ "name": "amount_minor",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "currency": {
+ "name": "currency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'USD'"
+ },
+ "tags": {
+ "name": "tags",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'open'"
+ },
+ "probability": {
+ "name": "probability",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expected_close_date": {
+ "name": "expected_close_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "closed_at": {
+ "name": "closed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "lost_reason": {
+ "name": "lost_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "opportunities_organization_id_organizations_id_fk": {
+ "name": "opportunities_organization_id_organizations_id_fk",
+ "tableFrom": "opportunities",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "opportunities_organization_id_owner_id_memberships_organization_id_user_id_fk": {
+ "name": "opportunities_organization_id_owner_id_memberships_organization_id_user_id_fk",
+ "tableFrom": "opportunities",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "owner_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "opportunities_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk": {
+ "name": "opportunities_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk",
+ "tableFrom": "opportunities",
+ "tableTo": "relationships",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "relationship_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "opportunities_organization_id_product_id_stage_id_stages_organization_id_product_id_id_fk": {
+ "name": "opportunities_organization_id_product_id_stage_id_stages_organization_id_product_id_id_fk",
+ "tableFrom": "opportunities",
+ "tableTo": "stages",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "stage_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {
+ "deal_amount_nonnegative": {
+ "name": "deal_amount_nonnegative",
+ "value": "\"opportunities\".\"amount_minor\" IS NULL OR \"opportunities\".\"amount_minor\" >= 0"
+ },
+ "deal_probability_valid": {
+ "name": "deal_probability_valid",
+ "value": "\"opportunities\".\"probability\" IS NULL OR (\"opportunities\".\"probability\" >= 0 AND \"opportunities\".\"probability\" <= 100)"
+ },
+ "deal_status_valid": {
+ "name": "deal_status_valid",
+ "value": "\"opportunities\".\"status\" IN ('open', 'won', 'lost')"
+ },
+ "deal_currency_valid": {
+ "name": "deal_currency_valid",
+ "value": "\"opportunities\".\"currency\" ~ '^[A-Z]{3}$'"
+ }
+ },
+ "isRLSEnabled": true
+ },
+ "public.organizations": {
+ "name": "organizations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "timezone": {
+ "name": "timezone",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'UTC'"
+ },
+ "allowed_email_domains": {
+ "name": "allowed_email_domains",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "organizations_slug_unique": {
+ "name": "organizations_slug_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "slug"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.people": {
+ "name": "people",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "company_id": {
+ "name": "company_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "other_emails": {
+ "name": "other_emails",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "phone": {
+ "name": "phone",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "linkedin_url": {
+ "name": "linkedin_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "summary": {
+ "name": "summary",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "do_not_contact": {
+ "name": "do_not_contact",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "time_zone": {
+ "name": "time_zone",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "tags": {
+ "name": "tags",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "amount_minor": {
+ "name": "amount_minor",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "currency": {
+ "name": "currency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'USD'"
+ }
+ },
+ "indexes": {
+ "people_company_browse": {
+ "name": "people_company_browse",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "company_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "archived_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "people_name_browse": {
+ "name": "people_name_browse",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "people_organization_linkedin_url": {
+ "name": "people_organization_linkedin_url",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "lower(\"linkedin_url\")",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"people\".\"linkedin_url\" <> ''",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "people_organization_id_organizations_id_fk": {
+ "name": "people_organization_id_organizations_id_fk",
+ "tableFrom": "people",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "people_organization_id_company_id_companies_organization_id_id_fk": {
+ "name": "people_organization_id_company_id_companies_organization_id_id_fk",
+ "tableFrom": "people",
+ "tableTo": "companies",
+ "columnsFrom": [
+ "organization_id",
+ "company_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "people_organization_id_id_unique": {
+ "name": "people_organization_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {
+ "person_amount_nonnegative": {
+ "name": "person_amount_nonnegative",
+ "value": "\"people\".\"amount_minor\" IS NULL OR \"people\".\"amount_minor\" >= 0"
+ },
+ "person_currency_valid": {
+ "name": "person_currency_valid",
+ "value": "\"people\".\"currency\" ~ '^[A-Z]{3}$'"
+ }
+ },
+ "isRLSEnabled": true
+ },
+ "public.pipelines": {
+ "name": "pipelines",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "pipelines_organization_id_organizations_id_fk": {
+ "name": "pipelines_organization_id_organizations_id_fk",
+ "tableFrom": "pipelines",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "pipelines_organization_id_product_id_products_organization_id_id_fk": {
+ "name": "pipelines_organization_id_product_id_products_organization_id_id_fk",
+ "tableFrom": "pipelines",
+ "tableTo": "products",
+ "columnsFrom": [
+ "organization_id",
+ "product_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "pipelines_organization_id_product_id_id_unique": {
+ "name": "pipelines_organization_id_product_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "product_id",
+ "id"
+ ]
+ },
+ "pipelines_organization_id_product_id_name_unique": {
+ "name": "pipelines_organization_id_product_id_name_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "product_id",
+ "name"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.product_memberships": {
+ "name": "product_memberships",
+ "schema": "",
+ "columns": {
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "product_memberships_organization_id_organizations_id_fk": {
+ "name": "product_memberships_organization_id_organizations_id_fk",
+ "tableFrom": "product_memberships",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "product_memberships_user_id_user_id_fk": {
+ "name": "product_memberships_user_id_user_id_fk",
+ "tableFrom": "product_memberships",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "product_memberships_organization_id_product_id_products_organization_id_id_fk": {
+ "name": "product_memberships_organization_id_product_id_products_organization_id_id_fk",
+ "tableFrom": "product_memberships",
+ "tableTo": "products",
+ "columnsFrom": [
+ "organization_id",
+ "product_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "product_memberships_organization_id_user_id_memberships_organization_id_user_id_fk": {
+ "name": "product_memberships_organization_id_user_id_memberships_organization_id_user_id_fk",
+ "tableFrom": "product_memberships",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "user_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "product_memberships_organization_id_product_id_user_id_unique": {
+ "name": "product_memberships_organization_id_product_id_user_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "product_id",
+ "user_id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.products": {
+ "name": "products",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "color": {
+ "name": "color",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'#7565cf'"
+ },
+ "color_key": {
+ "name": "color_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'violet'"
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "products_organization_id_organizations_id_fk": {
+ "name": "products_organization_id_organizations_id_fk",
+ "tableFrom": "products",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "products_organization_id_id_unique": {
+ "name": "products_organization_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "id"
+ ]
+ },
+ "products_organization_id_name_unique": {
+ "name": "products_organization_id_name_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "name"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {
+ "product_color_key": {
+ "name": "product_color_key",
+ "value": "\"products\".\"color_key\" IN ('violet', 'blue', 'teal', 'green', 'yellow', 'orange', 'red', 'pink', 'gray')"
+ }
+ },
+ "isRLSEnabled": true
+ },
+ "public.provider_configurations": {
+ "name": "provider_configurations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_credentials": {
+ "name": "encrypted_credentials",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "webhook_ready": {
+ "name": "webhook_ready",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "active": {
+ "name": "active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "provider_configurations_active_owner": {
+ "name": "provider_configurations_active_owner",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"provider_configurations\".\"active\" = true",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "provider_configurations_organization_id_organizations_id_fk": {
+ "name": "provider_configurations_organization_id_organizations_id_fk",
+ "tableFrom": "provider_configurations",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "provider_configurations_organization_id_owner_id_memberships_organization_id_user_id_fk": {
+ "name": "provider_configurations_organization_id_owner_id_memberships_organization_id_user_id_fk",
+ "tableFrom": "provider_configurations",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "owner_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "provider_configurations_organization_id_owner_id_id_unique": {
+ "name": "provider_configurations_organization_id_owner_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "owner_id",
+ "id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.relationships": {
+ "name": "relationships",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "person_id": {
+ "name": "person_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "purpose": {
+ "name": "purpose",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'buyer'"
+ },
+ "qualification": {
+ "name": "qualification",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'unverified'"
+ },
+ "context": {
+ "name": "context",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "context_details": {
+ "name": "context_details",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{\"background\":\"\",\"needs\":\"\",\"timing\":\"\",\"budget\":\"\",\"decisionProcess\":\"\",\"risks\":\"\",\"history\":\"\",\"signals\":[],\"fields\":[]}'::jsonb"
+ },
+ "context_source": {
+ "name": "context_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stage_id": {
+ "name": "stage_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stage_pipeline": {
+ "name": "stage_pipeline",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'outreach'"
+ },
+ "priority": {
+ "name": "priority",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'normal'"
+ },
+ "next_step": {
+ "name": "next_step",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "next_step_due_at": {
+ "name": "next_step_due_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_outbound_at": {
+ "name": "last_outbound_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_inbound_at": {
+ "name": "last_inbound_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "touch_count": {
+ "name": "touch_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "tags": {
+ "name": "tags",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "amount_minor": {
+ "name": "amount_minor",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "currency": {
+ "name": "currency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'USD'"
+ }
+ },
+ "indexes": {
+ "relationships_person_browse": {
+ "name": "relationships_person_browse",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "person_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "product_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "relationships_organization_id_organizations_id_fk": {
+ "name": "relationships_organization_id_organizations_id_fk",
+ "tableFrom": "relationships",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "relationships_organization_id_product_id_stage_id_stage_pipeline_stages_organization_id_product_id_id_pipeline_fk": {
+ "name": "relationships_organization_id_product_id_stage_id_stage_pipeline_stages_organization_id_product_id_id_pipeline_fk",
+ "tableFrom": "relationships",
+ "tableTo": "stages",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "stage_id",
+ "stage_pipeline"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id",
+ "pipeline"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "relationships_organization_id_product_id_products_organization_id_id_fk": {
+ "name": "relationships_organization_id_product_id_products_organization_id_id_fk",
+ "tableFrom": "relationships",
+ "tableTo": "products",
+ "columnsFrom": [
+ "organization_id",
+ "product_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "relationships_organization_id_person_id_people_organization_id_id_fk": {
+ "name": "relationships_organization_id_person_id_people_organization_id_id_fk",
+ "tableFrom": "relationships",
+ "tableTo": "people",
+ "columnsFrom": [
+ "organization_id",
+ "person_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "relationships_organization_id_owner_id_memberships_organization_id_user_id_fk": {
+ "name": "relationships_organization_id_owner_id_memberships_organization_id_user_id_fk",
+ "tableFrom": "relationships",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "owner_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "relationships_organization_id_id_unique": {
+ "name": "relationships_organization_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "id"
+ ]
+ },
+ "relationships_organization_id_product_id_id_unique": {
+ "name": "relationships_organization_id_product_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "product_id",
+ "id"
+ ]
+ },
+ "relationships_organization_id_product_id_person_id_purpose_unique": {
+ "name": "relationships_organization_id_product_id_person_id_purpose_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "product_id",
+ "person_id",
+ "purpose"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {
+ "relationship_amount_nonnegative": {
+ "name": "relationship_amount_nonnegative",
+ "value": "\"relationships\".\"amount_minor\" IS NULL OR \"relationships\".\"amount_minor\" >= 0"
+ },
+ "relationship_currency_valid": {
+ "name": "relationship_currency_valid",
+ "value": "\"relationships\".\"currency\" ~ '^[A-Z]{3}$'"
+ },
+ "relationship_stage_outreach": {
+ "name": "relationship_stage_outreach",
+ "value": "\"relationships\".\"stage_pipeline\" = 'outreach'"
+ },
+ "relationship_touch_count": {
+ "name": "relationship_touch_count",
+ "value": "\"relationships\".\"touch_count\" >= 0"
+ }
+ },
+ "isRLSEnabled": true
+ },
+ "public.sequences": {
+ "name": "sequences",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "steps": {
+ "name": "steps",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "sequences_organization_id_organizations_id_fk": {
+ "name": "sequences_organization_id_organizations_id_fk",
+ "tableFrom": "sequences",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "sequences_organization_id_product_id_products_organization_id_id_fk": {
+ "name": "sequences_organization_id_product_id_products_organization_id_id_fk",
+ "tableFrom": "sequences",
+ "tableTo": "products",
+ "columnsFrom": [
+ "organization_id",
+ "product_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "sequences_organization_id_product_id_id_unique": {
+ "name": "sequences_organization_id_product_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "product_id",
+ "id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.stages": {
+ "name": "stages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pipeline_id": {
+ "name": "pipeline_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "position": {
+ "name": "position",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pipeline": {
+ "name": "pipeline",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'deal'"
+ },
+ "category": {
+ "name": "category",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'open'"
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "stages_organization_id_organizations_id_fk": {
+ "name": "stages_organization_id_organizations_id_fk",
+ "tableFrom": "stages",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "stages_organization_id_product_id_pipeline_id_pipelines_organization_id_product_id_id_fk": {
+ "name": "stages_organization_id_product_id_pipeline_id_pipelines_organization_id_product_id_id_fk",
+ "tableFrom": "stages",
+ "tableTo": "pipelines",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "pipeline_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "stages_organization_id_product_id_products_organization_id_id_fk": {
+ "name": "stages_organization_id_product_id_products_organization_id_id_fk",
+ "tableFrom": "stages",
+ "tableTo": "products",
+ "columnsFrom": [
+ "organization_id",
+ "product_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "stages_organization_id_product_id_id_unique": {
+ "name": "stages_organization_id_product_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "product_id",
+ "id"
+ ]
+ },
+ "stages_organization_id_product_id_id_pipeline_unique": {
+ "name": "stages_organization_id_product_id_id_pipeline_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "product_id",
+ "id",
+ "pipeline"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.touches": {
+ "name": "touches",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "relationship_id": {
+ "name": "relationship_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "enrollment_id": {
+ "name": "enrollment_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "step_number": {
+ "name": "step_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "follow_up": {
+ "name": "follow_up",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "channel": {
+ "name": "channel",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sender_id": {
+ "name": "sender_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "due_at": {
+ "name": "due_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'planned'"
+ },
+ "draft": {
+ "name": "draft",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "draft_hash": {
+ "name": "draft_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "approved_hash": {
+ "name": "approved_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "approved_by": {
+ "name": "approved_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sent_by": {
+ "name": "sent_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sent_at": {
+ "name": "sent_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "external_message_id": {
+ "name": "external_message_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sent_warnings": {
+ "name": "sent_warnings",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "skip_reason": {
+ "name": "skip_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "closed_at": {
+ "name": "closed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "touches_enrollment_step": {
+ "name": "touches_enrollment_step",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "relationship_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "enrollment_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "step_number",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "touches_external_message": {
+ "name": "touches_external_message",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "channel",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "external_message_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"touches\".\"external_message_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "touches_organization_id_product_id_status_due_at_index": {
+ "name": "touches_organization_id_product_id_status_due_at_index",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "product_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "due_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "touches_organization_id_organizations_id_fk": {
+ "name": "touches_organization_id_organizations_id_fk",
+ "tableFrom": "touches",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "touches_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk": {
+ "name": "touches_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk",
+ "tableFrom": "touches",
+ "tableTo": "relationships",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "relationship_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "touches_organization_id_product_id_relationship_id_enrollment_id_enrollments_organization_id_product_id_relationship_id_id_fk": {
+ "name": "touches_organization_id_product_id_relationship_id_enrollment_id_enrollments_organization_id_product_id_relationship_id_id_fk",
+ "tableFrom": "touches",
+ "tableTo": "enrollments",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "relationship_id",
+ "enrollment_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "relationship_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "touches_organization_id_sender_id_memberships_organization_id_user_id_fk": {
+ "name": "touches_organization_id_sender_id_memberships_organization_id_user_id_fk",
+ "tableFrom": "touches",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "sender_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "touches_organization_id_approved_by_memberships_organization_id_user_id_fk": {
+ "name": "touches_organization_id_approved_by_memberships_organization_id_user_id_fk",
+ "tableFrom": "touches",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "approved_by"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "touches_organization_id_sent_by_memberships_organization_id_user_id_fk": {
+ "name": "touches_organization_id_sent_by_memberships_organization_id_user_id_fk",
+ "tableFrom": "touches",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "sent_by"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "touches_organization_id_product_id_id_unique": {
+ "name": "touches_organization_id_product_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "product_id",
+ "id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {
+ "touch_follow_up": {
+ "name": "touch_follow_up",
+ "value": "\"touches\".\"follow_up\" BETWEEN 0 AND 3"
+ },
+ "touch_sent_report": {
+ "name": "touch_sent_report",
+ "value": "(\"touches\".\"status\" = 'sent') = (\"touches\".\"sent_at\" IS NOT NULL AND \"touches\".\"sent_by\" IS NOT NULL)"
+ },
+ "touch_approval": {
+ "name": "touch_approval",
+ "value": "\"touches\".\"status\" <> 'approved' OR (\"touches\".\"approved_hash\" IS NOT NULL AND \"touches\".\"approved_hash\" = \"touches\".\"draft_hash\")"
+ }
+ },
+ "isRLSEnabled": true
+ },
+ "public.yodu_bindings": {
+ "name": "yodu_bindings",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_id": {
+ "name": "source_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "external_subject_id": {
+ "name": "external_subject_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "relationship_id": {
+ "name": "relationship_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "yodu_bindings_organization_id_organizations_id_fk": {
+ "name": "yodu_bindings_organization_id_organizations_id_fk",
+ "tableFrom": "yodu_bindings",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "yodu_bindings_organization_id_product_id_source_id_yodu_sources_organization_id_product_id_id_fk": {
+ "name": "yodu_bindings_organization_id_product_id_source_id_yodu_sources_organization_id_product_id_id_fk",
+ "tableFrom": "yodu_bindings",
+ "tableTo": "yodu_sources",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "source_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "yodu_bindings_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk": {
+ "name": "yodu_bindings_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk",
+ "tableFrom": "yodu_bindings",
+ "tableTo": "relationships",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "relationship_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "yodu_bindings_organization_id_created_by_memberships_organization_id_user_id_fk": {
+ "name": "yodu_bindings_organization_id_created_by_memberships_organization_id_user_id_fk",
+ "tableFrom": "yodu_bindings",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "created_by"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "yodu_bindings_source_id_external_subject_id_unique": {
+ "name": "yodu_bindings_source_id_external_subject_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "source_id",
+ "external_subject_id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.yodu_events": {
+ "name": "yodu_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_id": {
+ "name": "source_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "external_subject_id": {
+ "name": "external_subject_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_event_id": {
+ "name": "provider_event_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "occurred_at": {
+ "name": "occurred_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "received_at": {
+ "name": "received_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payload_hash": {
+ "name": "payload_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_version": {
+ "name": "source_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "yodu_events_product_received": {
+ "name": "yodu_events_product_received",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "product_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "received_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "yodu_events_organization_id_organizations_id_fk": {
+ "name": "yodu_events_organization_id_organizations_id_fk",
+ "tableFrom": "yodu_events",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "yodu_events_organization_id_product_id_source_id_yodu_sources_organization_id_product_id_id_fk": {
+ "name": "yodu_events_organization_id_product_id_source_id_yodu_sources_organization_id_product_id_id_fk",
+ "tableFrom": "yodu_events",
+ "tableTo": "yodu_sources",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "source_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "yodu_events_source_id_provider_event_id_unique": {
+ "name": "yodu_events_source_id_provider_event_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "source_id",
+ "provider_event_id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {
+ "yodu_event_kind": {
+ "name": "yodu_event_kind",
+ "value": "\"yodu_events\".\"kind\" IN ('signup', 'onboarding', 'payment', 'activation')"
+ },
+ "yodu_event_hash": {
+ "name": "yodu_event_hash",
+ "value": "\"yodu_events\".\"payload_hash\" ~ '^[a-f0-9]{64}$'"
+ },
+ "yodu_event_source_version": {
+ "name": "yodu_event_source_version",
+ "value": "\"yodu_events\".\"source_version\" > 0"
+ }
+ },
+ "isRLSEnabled": true
+ },
+ "public.yodu_sources": {
+ "name": "yodu_sources",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "label": {
+ "name": "label",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "encrypted_secret": {
+ "name": "encrypted_secret",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "yodu_sources_organization_id_organizations_id_fk": {
+ "name": "yodu_sources_organization_id_organizations_id_fk",
+ "tableFrom": "yodu_sources",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "yodu_sources_organization_id_product_id_products_organization_id_id_fk": {
+ "name": "yodu_sources_organization_id_product_id_products_organization_id_id_fk",
+ "tableFrom": "yodu_sources",
+ "tableTo": "products",
+ "columnsFrom": [
+ "organization_id",
+ "product_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "yodu_sources_organization_id_created_by_memberships_organization_id_user_id_fk": {
+ "name": "yodu_sources_organization_id_created_by_memberships_organization_id_user_id_fk",
+ "tableFrom": "yodu_sources",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "created_by"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "yodu_sources_organization_id_product_id_id_unique": {
+ "name": "yodu_sources_organization_id_product_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "product_id",
+ "id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.account": {
+ "name": "account",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "account_id": {
+ "name": "account_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_id": {
+ "name": "provider_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "access_token": {
+ "name": "access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token": {
+ "name": "refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "id_token": {
+ "name": "id_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_token_expires_at": {
+ "name": "access_token_expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token_expires_at": {
+ "name": "refresh_token_expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "password": {
+ "name": "password",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "account_userId_idx": {
+ "name": "account_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "account_user_id_user_id_fk": {
+ "name": "account_user_id_user_id_fk",
+ "tableFrom": "account",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.jwks": {
+ "name": "jwks",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "public_key": {
+ "name": "public_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "private_key": {
+ "name": "private_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alg": {
+ "name": "alg",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "crv": {
+ "name": "crv",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.oauth_access_token": {
+ "name": "oauth_access_token",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reference_id": {
+ "name": "reference_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "authorization_code_id": {
+ "name": "authorization_code_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resources": {
+ "name": "resources",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "requested_user_info_claims": {
+ "name": "requested_user_info_claims",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_id": {
+ "name": "refresh_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revoked": {
+ "name": "revoked",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "confirmation": {
+ "name": "confirmation",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scopes": {
+ "name": "scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "oauthAccessToken_clientId_idx": {
+ "name": "oauthAccessToken_clientId_idx",
+ "columns": [
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "oauthAccessToken_sessionId_idx": {
+ "name": "oauthAccessToken_sessionId_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "oauthAccessToken_userId_idx": {
+ "name": "oauthAccessToken_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "oauthAccessToken_authorizationCodeId_idx": {
+ "name": "oauthAccessToken_authorizationCodeId_idx",
+ "columns": [
+ {
+ "expression": "authorization_code_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "oauthAccessToken_refreshId_idx": {
+ "name": "oauthAccessToken_refreshId_idx",
+ "columns": [
+ {
+ "expression": "refresh_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "oauth_access_token_client_id_oauth_client_client_id_fk": {
+ "name": "oauth_access_token_client_id_oauth_client_client_id_fk",
+ "tableFrom": "oauth_access_token",
+ "tableTo": "oauth_client",
+ "columnsFrom": [
+ "client_id"
+ ],
+ "columnsTo": [
+ "client_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "oauth_access_token_session_id_session_id_fk": {
+ "name": "oauth_access_token_session_id_session_id_fk",
+ "tableFrom": "oauth_access_token",
+ "tableTo": "session",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "oauth_access_token_user_id_user_id_fk": {
+ "name": "oauth_access_token_user_id_user_id_fk",
+ "tableFrom": "oauth_access_token",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "oauth_access_token_refresh_id_oauth_refresh_token_id_fk": {
+ "name": "oauth_access_token_refresh_id_oauth_refresh_token_id_fk",
+ "tableFrom": "oauth_access_token",
+ "tableTo": "oauth_refresh_token",
+ "columnsFrom": [
+ "refresh_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "oauth_access_token_token_unique": {
+ "name": "oauth_access_token_token_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "token"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.oauth_client": {
+ "name": "oauth_client",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_secret": {
+ "name": "client_secret",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "client_discovery_id": {
+ "name": "client_discovery_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "disabled": {
+ "name": "disabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "skip_consent": {
+ "name": "skip_consent",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enable_end_session": {
+ "name": "enable_end_session",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "subject_type": {
+ "name": "subject_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scopes": {
+ "name": "scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "client_credentials_scopes": {
+ "name": "client_credentials_scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'{}'"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uri": {
+ "name": "uri",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "icon": {
+ "name": "icon",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "contacts": {
+ "name": "contacts",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tos": {
+ "name": "tos",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "policy": {
+ "name": "policy",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "software_id": {
+ "name": "software_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "software_version": {
+ "name": "software_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "software_statement": {
+ "name": "software_statement",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "redirect_uris": {
+ "name": "redirect_uris",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "post_logout_redirect_uris": {
+ "name": "post_logout_redirect_uris",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "backchannel_logout_uri": {
+ "name": "backchannel_logout_uri",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "backchannel_logout_session_required": {
+ "name": "backchannel_logout_session_required",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "token_endpoint_auth_method": {
+ "name": "token_endpoint_auth_method",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "application_type": {
+ "name": "application_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "jwks": {
+ "name": "jwks",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "jwks_uri": {
+ "name": "jwks_uri",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "grant_types": {
+ "name": "grant_types",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "response_types": {
+ "name": "response_types",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "require_pkce": {
+ "name": "require_pkce",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dpop_bound_access_tokens": {
+ "name": "dpop_bound_access_tokens",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "reference_id": {
+ "name": "reference_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "oauthClient_userId_idx": {
+ "name": "oauthClient_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "oauth_client_user_id_user_id_fk": {
+ "name": "oauth_client_user_id_user_id_fk",
+ "tableFrom": "oauth_client",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "oauth_client_client_id_unique": {
+ "name": "oauth_client_client_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "client_id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.oauth_client_assertion": {
+ "name": "oauth_client_assertion",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.oauth_client_resource": {
+ "name": "oauth_client_resource",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "resource_id": {
+ "name": "resource_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "oauthClientResource_clientId_resourceId_uidx": {
+ "name": "oauthClientResource_clientId_resourceId_uidx",
+ "columns": [
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "resource_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "oauthClientResource_clientId_idx": {
+ "name": "oauthClientResource_clientId_idx",
+ "columns": [
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "oauthClientResource_resourceId_idx": {
+ "name": "oauthClientResource_resourceId_idx",
+ "columns": [
+ {
+ "expression": "resource_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "oauth_client_resource_client_id_oauth_client_client_id_fk": {
+ "name": "oauth_client_resource_client_id_oauth_client_client_id_fk",
+ "tableFrom": "oauth_client_resource",
+ "tableTo": "oauth_client",
+ "columnsFrom": [
+ "client_id"
+ ],
+ "columnsTo": [
+ "client_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "oauth_client_resource_resource_id_oauth_resource_identifier_fk": {
+ "name": "oauth_client_resource_resource_id_oauth_resource_identifier_fk",
+ "tableFrom": "oauth_client_resource",
+ "tableTo": "oauth_resource",
+ "columnsFrom": [
+ "resource_id"
+ ],
+ "columnsTo": [
+ "identifier"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.oauth_consent": {
+ "name": "oauth_consent",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reference_id": {
+ "name": "reference_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resources": {
+ "name": "resources",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "requested_user_info_claims": {
+ "name": "requested_user_info_claims",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scopes": {
+ "name": "scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "oauthConsent_clientId_idx": {
+ "name": "oauthConsent_clientId_idx",
+ "columns": [
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "oauthConsent_userId_idx": {
+ "name": "oauthConsent_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "oauth_consent_client_id_oauth_client_client_id_fk": {
+ "name": "oauth_consent_client_id_oauth_client_client_id_fk",
+ "tableFrom": "oauth_consent",
+ "tableTo": "oauth_client",
+ "columnsFrom": [
+ "client_id"
+ ],
+ "columnsTo": [
+ "client_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "oauth_consent_user_id_user_id_fk": {
+ "name": "oauth_consent_user_id_user_id_fk",
+ "tableFrom": "oauth_consent",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.oauth_refresh_token": {
+ "name": "oauth_refresh_token",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reference_id": {
+ "name": "reference_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "authorization_code_id": {
+ "name": "authorization_code_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resources": {
+ "name": "resources",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "requested_user_info_claims": {
+ "name": "requested_user_info_claims",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revoked": {
+ "name": "revoked",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rotated_at": {
+ "name": "rotated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rotation_replay_response": {
+ "name": "rotation_replay_response",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rotation_replay_expires_at": {
+ "name": "rotation_replay_expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "auth_time": {
+ "name": "auth_time",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "confirmation": {
+ "name": "confirmation",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scopes": {
+ "name": "scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "oauthRefreshToken_clientId_idx": {
+ "name": "oauthRefreshToken_clientId_idx",
+ "columns": [
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "oauthRefreshToken_sessionId_idx": {
+ "name": "oauthRefreshToken_sessionId_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "oauthRefreshToken_userId_idx": {
+ "name": "oauthRefreshToken_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "oauthRefreshToken_authorizationCodeId_idx": {
+ "name": "oauthRefreshToken_authorizationCodeId_idx",
+ "columns": [
+ {
+ "expression": "authorization_code_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "oauth_refresh_token_client_id_oauth_client_client_id_fk": {
+ "name": "oauth_refresh_token_client_id_oauth_client_client_id_fk",
+ "tableFrom": "oauth_refresh_token",
+ "tableTo": "oauth_client",
+ "columnsFrom": [
+ "client_id"
+ ],
+ "columnsTo": [
+ "client_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "oauth_refresh_token_session_id_session_id_fk": {
+ "name": "oauth_refresh_token_session_id_session_id_fk",
+ "tableFrom": "oauth_refresh_token",
+ "tableTo": "session",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "oauth_refresh_token_user_id_user_id_fk": {
+ "name": "oauth_refresh_token_user_id_user_id_fk",
+ "tableFrom": "oauth_refresh_token",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "oauth_refresh_token_token_unique": {
+ "name": "oauth_refresh_token_token_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "token"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.oauth_resource": {
+ "name": "oauth_resource",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "access_token_ttl": {
+ "name": "access_token_ttl",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token_ttl": {
+ "name": "refresh_token_ttl",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "signing_algorithm": {
+ "name": "signing_algorithm",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "signing_key_id": {
+ "name": "signing_key_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "allowed_scopes": {
+ "name": "allowed_scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "custom_claims": {
+ "name": "custom_claims",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dpop_bound_access_tokens_required": {
+ "name": "dpop_bound_access_tokens_required",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "disabled": {
+ "name": "disabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "policy_version": {
+ "name": "policy_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 1
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "oauth_resource_identifier_unique": {
+ "name": "oauth_resource_identifier_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "identifier"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.session": {
+ "name": "session",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ip_address": {
+ "name": "ip_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_agent": {
+ "name": "user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "session_userId_idx": {
+ "name": "session_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "session_user_id_user_id_fk": {
+ "name": "session_user_id_user_id_fk",
+ "tableFrom": "session",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "session_token_unique": {
+ "name": "session_token_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "token"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.user": {
+ "name": "user",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email_verified": {
+ "name": "email_verified",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "image": {
+ "name": "image",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_email_unique": {
+ "name": "user_email_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "email"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.verification": {
+ "name": "verification",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "verification_identifier_idx": {
+ "name": "verification_identifier_idx",
+ "columns": [
+ {
+ "expression": "identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ }
+ },
+ "enums": {},
+ "schemas": {},
+ "sequences": {},
+ "roles": {},
+ "policies": {},
+ "views": {},
+ "_meta": {
+ "columns": {},
+ "schemas": {},
+ "tables": {}
+ }
+}
\ No newline at end of file
diff --git a/drizzle/meta/0026_snapshot.json b/drizzle/meta/0026_snapshot.json
new file mode 100644
index 00000000..4a9d6f7f
--- /dev/null
+++ b/drizzle/meta/0026_snapshot.json
@@ -0,0 +1,9154 @@
+{
+ "id": "065ead66-7187-40c5-8d05-73e461262c0f",
+ "prevId": "e9d16b77-7a90-4ceb-84f0-78ace310f6fe",
+ "version": "7",
+ "dialect": "postgresql",
+ "tables": {
+ "public.actions": {
+ "name": "actions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "relationship_id": {
+ "name": "relationship_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "enrollment_id": {
+ "name": "enrollment_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_conversation_id": {
+ "name": "source_conversation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reason": {
+ "name": "reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reason_source": {
+ "name": "reason_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owed_by": {
+ "name": "owed_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "channel": {
+ "name": "channel",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "due_at": {
+ "name": "due_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'open'"
+ },
+ "draft": {
+ "name": "draft",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "draft_hash": {
+ "name": "draft_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "approved_hash": {
+ "name": "approved_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "approved_by": {
+ "name": "approved_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "actions_organization_id_product_id_status_due_at_index": {
+ "name": "actions_organization_id_product_id_status_due_at_index",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "product_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "due_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "actions_organization_id_organizations_id_fk": {
+ "name": "actions_organization_id_organizations_id_fk",
+ "tableFrom": "actions",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "actions_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk": {
+ "name": "actions_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk",
+ "tableFrom": "actions",
+ "tableTo": "relationships",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "relationship_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "actions_organization_id_product_id_enrollment_id_enrollments_organization_id_product_id_id_fk": {
+ "name": "actions_organization_id_product_id_enrollment_id_enrollments_organization_id_product_id_id_fk",
+ "tableFrom": "actions",
+ "tableTo": "enrollments",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "enrollment_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "actions_organization_id_product_id_source_conversation_id_conversations_organization_id_product_id_id_fk": {
+ "name": "actions_organization_id_product_id_source_conversation_id_conversations_organization_id_product_id_id_fk",
+ "tableFrom": "actions",
+ "tableTo": "conversations",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "source_conversation_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "actions_organization_id_owner_id_memberships_organization_id_user_id_fk": {
+ "name": "actions_organization_id_owner_id_memberships_organization_id_user_id_fk",
+ "tableFrom": "actions",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "owner_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "actions_organization_id_product_id_id_unique": {
+ "name": "actions_organization_id_product_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "product_id",
+ "id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.asset_stages": {
+ "name": "asset_stages",
+ "schema": "",
+ "columns": {
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "asset_id": {
+ "name": "asset_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "stage_id": {
+ "name": "stage_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "asset_stages_organization_id_organizations_id_fk": {
+ "name": "asset_stages_organization_id_organizations_id_fk",
+ "tableFrom": "asset_stages",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "asset_stages_organization_id_product_id_asset_id_assets_organization_id_product_id_id_fk": {
+ "name": "asset_stages_organization_id_product_id_asset_id_assets_organization_id_product_id_id_fk",
+ "tableFrom": "asset_stages",
+ "tableTo": "assets",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "asset_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "asset_stages_organization_id_product_id_stage_id_stages_organization_id_product_id_id_fk": {
+ "name": "asset_stages_organization_id_product_id_stage_id_stages_organization_id_product_id_id_fk",
+ "tableFrom": "asset_stages",
+ "tableTo": "stages",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "stage_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "asset_stages_asset_id_stage_id_unique": {
+ "name": "asset_stages_asset_id_stage_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "asset_id",
+ "stage_id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.assets": {
+ "name": "assets",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "folder_id": {
+ "name": "folder_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "storage_key": {
+ "name": "storage_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mime_type": {
+ "name": "mime_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "size": {
+ "name": "size",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sha256": {
+ "name": "sha256",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'draft'"
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "uploaded_by": {
+ "name": "uploaded_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "assets_organization_id_organizations_id_fk": {
+ "name": "assets_organization_id_organizations_id_fk",
+ "tableFrom": "assets",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "assets_organization_id_product_id_folder_id_folders_organization_id_product_id_id_fk": {
+ "name": "assets_organization_id_product_id_folder_id_folders_organization_id_product_id_id_fk",
+ "tableFrom": "assets",
+ "tableTo": "folders",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "folder_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "assets_organization_id_uploaded_by_memberships_organization_id_user_id_fk": {
+ "name": "assets_organization_id_uploaded_by_memberships_organization_id_user_id_fk",
+ "tableFrom": "assets",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "uploaded_by"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "assets_organization_id_product_id_id_unique": {
+ "name": "assets_organization_id_product_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "product_id",
+ "id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {
+ "asset_size_valid": {
+ "name": "asset_size_valid",
+ "value": "\"assets\".\"size\" > 0 AND \"assets\".\"size\" <= 10485760"
+ }
+ },
+ "isRLSEnabled": true
+ },
+ "public.change_events": {
+ "name": "change_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_conversation_id": {
+ "name": "source_conversation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_id": {
+ "name": "actor_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "entity_id": {
+ "name": "entity_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "change_events_organization_id_created_at_index": {
+ "name": "change_events_organization_id_created_at_index",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "change_events_organization_id_organizations_id_fk": {
+ "name": "change_events_organization_id_organizations_id_fk",
+ "tableFrom": "change_events",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "change_events_organization_id_product_id_source_conversation_id_conversations_organization_id_product_id_id_fk": {
+ "name": "change_events_organization_id_product_id_source_conversation_id_conversations_organization_id_product_id_id_fk",
+ "tableFrom": "change_events",
+ "tableTo": "conversations",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "source_conversation_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "change_events_organization_id_product_id_products_organization_id_id_fk": {
+ "name": "change_events_organization_id_product_id_products_organization_id_id_fk",
+ "tableFrom": "change_events",
+ "tableTo": "products",
+ "columnsFrom": [
+ "organization_id",
+ "product_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.companies": {
+ "name": "companies",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "domain": {
+ "name": "domain",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "tags": {
+ "name": "tags",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "amount_minor": {
+ "name": "amount_minor",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "currency": {
+ "name": "currency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'USD'"
+ }
+ },
+ "indexes": {
+ "companies_browse": {
+ "name": "companies_browse",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "companies_organization_id_organizations_id_fk": {
+ "name": "companies_organization_id_organizations_id_fk",
+ "tableFrom": "companies",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "companies_organization_id_id_unique": {
+ "name": "companies_organization_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {
+ "company_amount_nonnegative": {
+ "name": "company_amount_nonnegative",
+ "value": "\"companies\".\"amount_minor\" IS NULL OR \"companies\".\"amount_minor\" >= 0"
+ },
+ "company_currency_valid": {
+ "name": "company_currency_valid",
+ "value": "\"companies\".\"currency\" ~ '^[A-Z]{3}$'"
+ }
+ },
+ "isRLSEnabled": true
+ },
+ "public.connections": {
+ "name": "connections",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "external_account_id": {
+ "name": "external_account_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_configuration_id": {
+ "name": "provider_configuration_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "display_name": {
+ "name": "display_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "encrypted_credentials": {
+ "name": "encrypted_credentials",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scopes": {
+ "name": "scopes",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "sync_cursor": {
+ "name": "sync_cursor",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "last_synced_at": {
+ "name": "last_synced_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error_code": {
+ "name": "error_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lease_id": {
+ "name": "lease_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lease_until": {
+ "name": "lease_until",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "webhook_secret": {
+ "name": "webhook_secret",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'disconnected'"
+ },
+ "self_email": {
+ "name": "self_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "inbox_folder_ids": {
+ "name": "inbox_folder_ids",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "sent_folder_ids": {
+ "name": "sent_folder_ids",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ }
+ },
+ "indexes": {
+ "connections_legacy_provider_account": {
+ "name": "connections_legacy_provider_account",
+ "columns": [
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "external_account_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"connections\".\"provider_configuration_id\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "connections_organization_id_organizations_id_fk": {
+ "name": "connections_organization_id_organizations_id_fk",
+ "tableFrom": "connections",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "connections_organization_id_product_id_products_organization_id_id_fk": {
+ "name": "connections_organization_id_product_id_products_organization_id_id_fk",
+ "tableFrom": "connections",
+ "tableTo": "products",
+ "columnsFrom": [
+ "organization_id",
+ "product_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "connections_organization_id_owner_id_provider_configuration_id_provider_configurations_organization_id_owner_id_id_fk": {
+ "name": "connections_organization_id_owner_id_provider_configuration_id_provider_configurations_organization_id_owner_id_id_fk",
+ "tableFrom": "connections",
+ "tableTo": "provider_configurations",
+ "columnsFrom": [
+ "organization_id",
+ "owner_id",
+ "provider_configuration_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "owner_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "connections_organization_id_owner_id_memberships_organization_id_user_id_fk": {
+ "name": "connections_organization_id_owner_id_memberships_organization_id_user_id_fk",
+ "tableFrom": "connections",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "owner_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "connections_organization_id_id_unique": {
+ "name": "connections_organization_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "id"
+ ]
+ },
+ "connections_provider_provider_configuration_id_external_account_id_unique": {
+ "name": "connections_provider_provider_configuration_id_external_account_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "provider",
+ "provider_configuration_id",
+ "external_account_id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.connector_events": {
+ "name": "connector_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "connection_id": {
+ "name": "connection_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_event_id": {
+ "name": "provider_event_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "connector_events_organization_id_organizations_id_fk": {
+ "name": "connector_events_organization_id_organizations_id_fk",
+ "tableFrom": "connector_events",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "connector_events_organization_id_connection_id_connections_organization_id_id_fk": {
+ "name": "connector_events_organization_id_connection_id_connections_organization_id_id_fk",
+ "tableFrom": "connector_events",
+ "tableTo": "connections",
+ "columnsFrom": [
+ "organization_id",
+ "connection_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "connector_events_connection_id_provider_event_id_unique": {
+ "name": "connector_events_connection_id_provider_event_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "connection_id",
+ "provider_event_id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.contact_contributions": {
+ "name": "contact_contributions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "person_id": {
+ "name": "person_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_id": {
+ "name": "actor_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_member_id": {
+ "name": "source_member_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "transport": {
+ "name": "transport",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "grant_id": {
+ "name": "grant_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "batch_id": {
+ "name": "batch_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_record_id": {
+ "name": "source_record_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "request_hash": {
+ "name": "request_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "connection_id": {
+ "name": "connection_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_conversation_id": {
+ "name": "source_conversation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "contact_contributions_person": {
+ "name": "contact_contributions_person",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "person_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "contact_contributions_actor": {
+ "name": "contact_contributions_actor",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "actor_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "person_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "contact_contributions_batch_row": {
+ "name": "contact_contributions_batch_row",
+ "columns": [
+ {
+ "expression": "batch_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_record_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "contact_contributions_provider_row": {
+ "name": "contact_contributions_provider_row",
+ "columns": [
+ {
+ "expression": "connection_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_record_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "contact_contributions_original_creator": {
+ "name": "contact_contributions_original_creator",
+ "columns": [
+ {
+ "expression": "person_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"contact_contributions\".\"kind\" = 'created'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "contact_contributions_organization_id_organizations_id_fk": {
+ "name": "contact_contributions_organization_id_organizations_id_fk",
+ "tableFrom": "contact_contributions",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "contact_contributions_organization_id_person_id_people_organization_id_id_fk": {
+ "name": "contact_contributions_organization_id_person_id_people_organization_id_id_fk",
+ "tableFrom": "contact_contributions",
+ "tableTo": "people",
+ "columnsFrom": [
+ "organization_id",
+ "person_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "contact_contributions_organization_id_product_id_products_organization_id_id_fk": {
+ "name": "contact_contributions_organization_id_product_id_products_organization_id_id_fk",
+ "tableFrom": "contact_contributions",
+ "tableTo": "products",
+ "columnsFrom": [
+ "organization_id",
+ "product_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "contact_contributions_organization_id_actor_id_memberships_organization_id_user_id_fk": {
+ "name": "contact_contributions_organization_id_actor_id_memberships_organization_id_user_id_fk",
+ "tableFrom": "contact_contributions",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "actor_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "contact_contributions_organization_id_source_member_id_memberships_organization_id_user_id_fk": {
+ "name": "contact_contributions_organization_id_source_member_id_memberships_organization_id_user_id_fk",
+ "tableFrom": "contact_contributions",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "source_member_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "contact_contributions_organization_id_product_id_batch_id_contact_import_batches_organization_id_product_id_id_fk": {
+ "name": "contact_contributions_organization_id_product_id_batch_id_contact_import_batches_organization_id_product_id_id_fk",
+ "tableFrom": "contact_contributions",
+ "tableTo": "contact_import_batches",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "batch_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "contact_contributions_organization_id_connection_id_connections_organization_id_id_fk": {
+ "name": "contact_contributions_organization_id_connection_id_connections_organization_id_id_fk",
+ "tableFrom": "contact_contributions",
+ "tableTo": "connections",
+ "columnsFrom": [
+ "organization_id",
+ "connection_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "contact_contributions_organization_id_product_id_source_conversation_id_conversations_organization_id_product_id_id_fk": {
+ "name": "contact_contributions_organization_id_product_id_source_conversation_id_conversations_organization_id_product_id_id_fk",
+ "tableFrom": "contact_contributions",
+ "tableTo": "conversations",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "source_conversation_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {
+ "contact_contribution_batch_row": {
+ "name": "contact_contribution_batch_row",
+ "value": "((\"contact_contributions\".\"batch_id\" IS NULL) = (\"contact_contributions\".\"request_hash\" IS NULL)) AND (\"contact_contributions\".\"batch_id\" IS NULL OR (\"contact_contributions\".\"product_id\" IS NOT NULL AND \"contact_contributions\".\"source_record_id\" IS NOT NULL))"
+ }
+ },
+ "isRLSEnabled": true
+ },
+ "public.contact_import_batches": {
+ "name": "contact_import_batches",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "submitted_by": {
+ "name": "submitted_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_member_id": {
+ "name": "source_member_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_kind": {
+ "name": "source_kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "label": {
+ "name": "label",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "submission_key": {
+ "name": "submission_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "transport": {
+ "name": "transport",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "grant_id": {
+ "name": "grant_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "contact_import_batches_organization_id_organizations_id_fk": {
+ "name": "contact_import_batches_organization_id_organizations_id_fk",
+ "tableFrom": "contact_import_batches",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "contact_import_batches_organization_id_product_id_products_organization_id_id_fk": {
+ "name": "contact_import_batches_organization_id_product_id_products_organization_id_id_fk",
+ "tableFrom": "contact_import_batches",
+ "tableTo": "products",
+ "columnsFrom": [
+ "organization_id",
+ "product_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "contact_import_batches_organization_id_submitted_by_memberships_organization_id_user_id_fk": {
+ "name": "contact_import_batches_organization_id_submitted_by_memberships_organization_id_user_id_fk",
+ "tableFrom": "contact_import_batches",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "submitted_by"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "contact_import_batches_organization_id_source_member_id_memberships_organization_id_user_id_fk": {
+ "name": "contact_import_batches_organization_id_source_member_id_memberships_organization_id_user_id_fk",
+ "tableFrom": "contact_import_batches",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "source_member_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "contact_import_batches_organization_id_product_id_id_unique": {
+ "name": "contact_import_batches_organization_id_product_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "product_id",
+ "id"
+ ]
+ },
+ "contact_import_batches_organization_id_submitted_by_submission_key_unique": {
+ "name": "contact_import_batches_organization_id_submitted_by_submission_key_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "submitted_by",
+ "submission_key"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.contact_rules": {
+ "name": "contact_rules",
+ "schema": "",
+ "columns": {
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "cooldown_days": {
+ "name": "cooldown_days",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "daily_cap_per_sender": {
+ "name": "daily_cap_per_sender",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "quiet_hours_start": {
+ "name": "quiet_hours_start",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "quiet_hours_end": {
+ "name": "quiet_hours_end",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "contact_rules_organization_id_organizations_id_fk": {
+ "name": "contact_rules_organization_id_organizations_id_fk",
+ "tableFrom": "contact_rules",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {
+ "contact_rules_cooldown": {
+ "name": "contact_rules_cooldown",
+ "value": "\"contact_rules\".\"cooldown_days\" BETWEEN 0 AND 365"
+ },
+ "contact_rules_cap": {
+ "name": "contact_rules_cap",
+ "value": "\"contact_rules\".\"daily_cap_per_sender\" BETWEEN 1 AND 10000"
+ },
+ "contact_rules_quiet_hours": {
+ "name": "contact_rules_quiet_hours",
+ "value": "\"contact_rules\".\"quiet_hours_start\" BETWEEN 0 AND 23 AND \"contact_rules\".\"quiet_hours_end\" BETWEEN 0 AND 23"
+ }
+ },
+ "isRLSEnabled": true
+ },
+ "public.conversations": {
+ "name": "conversations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "relationship_id": {
+ "name": "relationship_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "connection_id": {
+ "name": "connection_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provenance": {
+ "name": "provenance",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'provider'"
+ },
+ "external_thread_id": {
+ "name": "external_thread_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "visibility": {
+ "name": "visibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'private'"
+ },
+ "channel": {
+ "name": "channel",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "conversations_native_source": {
+ "name": "conversations_native_source",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "channel",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "external_thread_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"conversations\".\"provenance\" = 'native'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "conversations_organization_id_organizations_id_fk": {
+ "name": "conversations_organization_id_organizations_id_fk",
+ "tableFrom": "conversations",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "conversations_organization_id_connection_id_connections_organization_id_id_fk": {
+ "name": "conversations_organization_id_connection_id_connections_organization_id_id_fk",
+ "tableFrom": "conversations",
+ "tableTo": "connections",
+ "columnsFrom": [
+ "organization_id",
+ "connection_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "conversations_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk": {
+ "name": "conversations_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk",
+ "tableFrom": "conversations",
+ "tableTo": "relationships",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "relationship_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "conversations_organization_id_owner_id_memberships_organization_id_user_id_fk": {
+ "name": "conversations_organization_id_owner_id_memberships_organization_id_user_id_fk",
+ "tableFrom": "conversations",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "owner_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "conversations_organization_id_product_id_id_unique": {
+ "name": "conversations_organization_id_product_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "product_id",
+ "id"
+ ]
+ },
+ "conversations_connection_id_external_thread_id_unique": {
+ "name": "conversations_connection_id_external_thread_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "connection_id",
+ "external_thread_id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {
+ "conversation_provenance": {
+ "name": "conversation_provenance",
+ "value": "(\"conversations\".\"provenance\" = 'provider') = (\"conversations\".\"connection_id\" IS NOT NULL)"
+ }
+ },
+ "isRLSEnabled": true
+ },
+ "public.deliveries": {
+ "name": "deliveries",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "relationship_id": {
+ "name": "relationship_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "connection_id": {
+ "name": "connection_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "touch_id": {
+ "name": "touch_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "action_id": {
+ "name": "action_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_version": {
+ "name": "source_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "idempotency_key": {
+ "name": "idempotency_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "request_hash": {
+ "name": "request_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "channel": {
+ "name": "channel",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "recipient": {
+ "name": "recipient",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "draft": {
+ "name": "draft",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "subject": {
+ "name": "subject",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "external_thread_id": {
+ "name": "external_thread_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "external_message_id": {
+ "name": "external_message_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "error_code": {
+ "name": "error_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "sent_at": {
+ "name": "sent_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "deliveries_touch_claim": {
+ "name": "deliveries_touch_claim",
+ "columns": [
+ {
+ "expression": "touch_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"deliveries\".\"status\" <> 'failed'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "deliveries_action_claim": {
+ "name": "deliveries_action_claim",
+ "columns": [
+ {
+ "expression": "action_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_version",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"deliveries\".\"status\" <> 'failed'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "deliveries_sender_day": {
+ "name": "deliveries_sender_day",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "deliveries_organization_id_organizations_id_fk": {
+ "name": "deliveries_organization_id_organizations_id_fk",
+ "tableFrom": "deliveries",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "deliveries_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk": {
+ "name": "deliveries_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk",
+ "tableFrom": "deliveries",
+ "tableTo": "relationships",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "relationship_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "deliveries_organization_id_product_id_touch_id_touches_organization_id_product_id_id_fk": {
+ "name": "deliveries_organization_id_product_id_touch_id_touches_organization_id_product_id_id_fk",
+ "tableFrom": "deliveries",
+ "tableTo": "touches",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "touch_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "deliveries_organization_id_product_id_action_id_actions_organization_id_product_id_id_fk": {
+ "name": "deliveries_organization_id_product_id_action_id_actions_organization_id_product_id_id_fk",
+ "tableFrom": "deliveries",
+ "tableTo": "actions",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "action_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "deliveries_organization_id_connection_id_connections_organization_id_id_fk": {
+ "name": "deliveries_organization_id_connection_id_connections_organization_id_id_fk",
+ "tableFrom": "deliveries",
+ "tableTo": "connections",
+ "columnsFrom": [
+ "organization_id",
+ "connection_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "deliveries_organization_id_owner_id_memberships_organization_id_user_id_fk": {
+ "name": "deliveries_organization_id_owner_id_memberships_organization_id_user_id_fk",
+ "tableFrom": "deliveries",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "owner_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "deliveries_organization_id_owner_id_idempotency_key_unique": {
+ "name": "deliveries_organization_id_owner_id_idempotency_key_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "owner_id",
+ "idempotency_key"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {
+ "delivery_source": {
+ "name": "delivery_source",
+ "value": "(\"deliveries\".\"touch_id\" IS NOT NULL) <> (\"deliveries\".\"action_id\" IS NOT NULL)"
+ },
+ "delivery_status": {
+ "name": "delivery_status",
+ "value": "\"deliveries\".\"status\" IN ('sending', 'unknown', 'accepted', 'sent', 'failed')"
+ }
+ },
+ "isRLSEnabled": true
+ },
+ "public.enrollments": {
+ "name": "enrollments",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "relationship_id": {
+ "name": "relationship_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sequence_id": {
+ "name": "sequence_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pause_reason": {
+ "name": "pause_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "step": {
+ "name": "step",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "enrolled_at": {
+ "name": "enrolled_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ }
+ },
+ "indexes": {
+ "enrollments_active_relationship_sequence": {
+ "name": "enrollments_active_relationship_sequence",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "relationship_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "sequence_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"enrollments\".\"status\" IN ('running', 'paused')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "enrollments_organization_id_organizations_id_fk": {
+ "name": "enrollments_organization_id_organizations_id_fk",
+ "tableFrom": "enrollments",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "enrollments_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk": {
+ "name": "enrollments_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk",
+ "tableFrom": "enrollments",
+ "tableTo": "relationships",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "relationship_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "enrollments_organization_id_product_id_sequence_id_sequences_organization_id_product_id_id_fk": {
+ "name": "enrollments_organization_id_product_id_sequence_id_sequences_organization_id_product_id_id_fk",
+ "tableFrom": "enrollments",
+ "tableTo": "sequences",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "sequence_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "enrollments_organization_id_product_id_id_unique": {
+ "name": "enrollments_organization_id_product_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "product_id",
+ "id"
+ ]
+ },
+ "enrollments_organization_id_product_id_relationship_id_id_unique": {
+ "name": "enrollments_organization_id_product_id_relationship_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "product_id",
+ "relationship_id",
+ "id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {
+ "enrollment_pause_reason": {
+ "name": "enrollment_pause_reason",
+ "value": "(\"enrollments\".\"status\" = 'paused') = (\"enrollments\".\"pause_reason\" IS NOT NULL)"
+ }
+ },
+ "isRLSEnabled": true
+ },
+ "public.evidence": {
+ "name": "evidence",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "relationship_id": {
+ "name": "relationship_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "excerpt": {
+ "name": "excerpt",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "classification": {
+ "name": "classification",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "evidence_organization_id_organizations_id_fk": {
+ "name": "evidence_organization_id_organizations_id_fk",
+ "tableFrom": "evidence",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "evidence_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk": {
+ "name": "evidence_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk",
+ "tableFrom": "evidence",
+ "tableTo": "relationships",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "relationship_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.file_entry": {
+ "name": "file_entry",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "parent_id": {
+ "name": "parent_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "visibility": {
+ "name": "visibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'private'"
+ },
+ "grants": {
+ "name": "grants",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "public_token": {
+ "name": "public_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "storage_key": {
+ "name": "storage_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mime_type": {
+ "name": "mime_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "size": {
+ "name": "size",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "sync_id": {
+ "name": "sync_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "file_entry_parent_idx": {
+ "name": "file_entry_parent_idx",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "product_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "parent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "file_entry_name_unique": {
+ "name": "file_entry_name_unique",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "product_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "coalesce(\"parent_id\"::text, '')",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "lower(\"name\")",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "file_entry_public_token_unique": {
+ "name": "file_entry_public_token_unique",
+ "columns": [
+ {
+ "expression": "public_token",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "file_entry_organization_id_organizations_id_fk": {
+ "name": "file_entry_organization_id_organizations_id_fk",
+ "tableFrom": "file_entry",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "file_entry_organization_id_product_id_products_organization_id_id_fk": {
+ "name": "file_entry_organization_id_product_id_products_organization_id_id_fk",
+ "tableFrom": "file_entry",
+ "tableTo": "products",
+ "columnsFrom": [
+ "organization_id",
+ "product_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "file_entry_organization_id_owner_id_memberships_organization_id_user_id_fk": {
+ "name": "file_entry_organization_id_owner_id_memberships_organization_id_user_id_fk",
+ "tableFrom": "file_entry",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "owner_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "file_entry_organization_id_product_id_parent_id_file_entry_organization_id_product_id_id_fk": {
+ "name": "file_entry_organization_id_product_id_parent_id_file_entry_organization_id_product_id_id_fk",
+ "tableFrom": "file_entry",
+ "tableTo": "file_entry",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "parent_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "file_entry_scope_id": {
+ "name": "file_entry_scope_id",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "product_id",
+ "id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {
+ "file_entry_kind": {
+ "name": "file_entry_kind",
+ "value": "\"file_entry\".\"kind\" in ('folder','markdown','file')"
+ },
+ "file_entry_visibility": {
+ "name": "file_entry_visibility",
+ "value": "\"file_entry\".\"visibility\" in ('private','workspace','public','shared','inherit')"
+ },
+ "file_entry_inherit_parent": {
+ "name": "file_entry_inherit_parent",
+ "value": "\"file_entry\".\"visibility\" <> 'inherit' or \"file_entry\".\"parent_id\" is not null"
+ },
+ "file_entry_no_self_parent": {
+ "name": "file_entry_no_self_parent",
+ "value": "\"file_entry\".\"parent_id\" is distinct from \"file_entry\".\"id\""
+ },
+ "file_entry_size": {
+ "name": "file_entry_size",
+ "value": "\"file_entry\".\"size\" between 0 and 104857600"
+ }
+ },
+ "isRLSEnabled": true
+ },
+ "public.file_upload": {
+ "name": "file_upload",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "parent_id": {
+ "name": "parent_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mime_type": {
+ "name": "mime_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "size": {
+ "name": "size",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "storage_key": {
+ "name": "storage_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "file_upload_organization_id_organizations_id_fk": {
+ "name": "file_upload_organization_id_organizations_id_fk",
+ "tableFrom": "file_upload",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "file_upload_organization_id_product_id_products_organization_id_id_fk": {
+ "name": "file_upload_organization_id_product_id_products_organization_id_id_fk",
+ "tableFrom": "file_upload",
+ "tableTo": "products",
+ "columnsFrom": [
+ "organization_id",
+ "product_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "file_upload_organization_id_owner_id_memberships_organization_id_user_id_fk": {
+ "name": "file_upload_organization_id_owner_id_memberships_organization_id_user_id_fk",
+ "tableFrom": "file_upload",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "owner_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "file_upload_organization_id_product_id_parent_id_file_entry_organization_id_product_id_id_fk": {
+ "name": "file_upload_organization_id_product_id_parent_id_file_entry_organization_id_product_id_id_fk",
+ "tableFrom": "file_upload",
+ "tableTo": "file_entry",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "parent_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {
+ "file_upload_size": {
+ "name": "file_upload_size",
+ "value": "\"file_upload\".\"size\" between 0 and 104857600"
+ }
+ },
+ "isRLSEnabled": true
+ },
+ "public.folders": {
+ "name": "folders",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "parent_id": {
+ "name": "parent_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "folders_organization_id_organizations_id_fk": {
+ "name": "folders_organization_id_organizations_id_fk",
+ "tableFrom": "folders",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "folders_organization_id_product_id_products_organization_id_id_fk": {
+ "name": "folders_organization_id_product_id_products_organization_id_id_fk",
+ "tableFrom": "folders",
+ "tableTo": "products",
+ "columnsFrom": [
+ "organization_id",
+ "product_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "folders_organization_id_product_id_parent_id_folders_organization_id_product_id_id_fk": {
+ "name": "folders_organization_id_product_id_parent_id_folders_organization_id_product_id_id_fk",
+ "tableFrom": "folders",
+ "tableTo": "folders",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "parent_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "folders_organization_id_product_id_id_unique": {
+ "name": "folders_organization_id_product_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "product_id",
+ "id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {
+ "folder_not_self_parent": {
+ "name": "folder_not_self_parent",
+ "value": "\"folders\".\"parent_id\" IS NULL OR \"folders\".\"parent_id\" <> \"folders\".\"id\""
+ }
+ },
+ "isRLSEnabled": true
+ },
+ "public.integration_flows": {
+ "name": "integration_flows",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "state_hash": {
+ "name": "state_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_verifier": {
+ "name": "encrypted_verifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "connection_id": {
+ "name": "connection_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "consumed_at": {
+ "name": "consumed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "integration_flows_organization_id_organizations_id_fk": {
+ "name": "integration_flows_organization_id_organizations_id_fk",
+ "tableFrom": "integration_flows",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "integration_flows_organization_id_product_id_products_organization_id_id_fk": {
+ "name": "integration_flows_organization_id_product_id_products_organization_id_id_fk",
+ "tableFrom": "integration_flows",
+ "tableTo": "products",
+ "columnsFrom": [
+ "organization_id",
+ "product_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "integration_flows_organization_id_owner_id_memberships_organization_id_user_id_fk": {
+ "name": "integration_flows_organization_id_owner_id_memberships_organization_id_user_id_fk",
+ "tableFrom": "integration_flows",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "owner_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "integration_flows_organization_id_connection_id_connections_organization_id_id_fk": {
+ "name": "integration_flows_organization_id_connection_id_connections_organization_id_id_fk",
+ "tableFrom": "integration_flows",
+ "tableTo": "connections",
+ "columnsFrom": [
+ "organization_id",
+ "connection_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "integration_flows_state_hash_unique": {
+ "name": "integration_flows_state_hash_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "state_hash"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.integration_items": {
+ "name": "integration_items",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "connection_id": {
+ "name": "connection_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "external_id": {
+ "name": "external_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "record": {
+ "name": "record",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'unmatched'"
+ },
+ "relationship_id": {
+ "name": "relationship_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "entity_id": {
+ "name": "entity_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "integration_items_organization_id_connection_id_status_index": {
+ "name": "integration_items_organization_id_connection_id_status_index",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "connection_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "integration_items_organization_id_organizations_id_fk": {
+ "name": "integration_items_organization_id_organizations_id_fk",
+ "tableFrom": "integration_items",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "integration_items_organization_id_connection_id_connections_organization_id_id_fk": {
+ "name": "integration_items_organization_id_connection_id_connections_organization_id_id_fk",
+ "tableFrom": "integration_items",
+ "tableTo": "connections",
+ "columnsFrom": [
+ "organization_id",
+ "connection_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "integration_items_organization_id_product_id_products_organization_id_id_fk": {
+ "name": "integration_items_organization_id_product_id_products_organization_id_id_fk",
+ "tableFrom": "integration_items",
+ "tableTo": "products",
+ "columnsFrom": [
+ "organization_id",
+ "product_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "integration_items_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk": {
+ "name": "integration_items_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk",
+ "tableFrom": "integration_items",
+ "tableTo": "relationships",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "relationship_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "integration_items_connection_id_external_id_unique": {
+ "name": "integration_items_connection_id_external_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "connection_id",
+ "external_id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.integration_receipts": {
+ "name": "integration_receipts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "connection_id": {
+ "name": "connection_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "external_id": {
+ "name": "external_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "attempts": {
+ "name": "attempts",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "error_code": {
+ "name": "error_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "next_attempt_at": {
+ "name": "next_attempt_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "lease_until": {
+ "name": "lease_until",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "processed_at": {
+ "name": "processed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "integration_receipts_processed_at_next_attempt_at_index": {
+ "name": "integration_receipts_processed_at_next_attempt_at_index",
+ "columns": [
+ {
+ "expression": "processed_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "next_attempt_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "integration_receipts_organization_id_organizations_id_fk": {
+ "name": "integration_receipts_organization_id_organizations_id_fk",
+ "tableFrom": "integration_receipts",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "integration_receipts_organization_id_connection_id_connections_organization_id_id_fk": {
+ "name": "integration_receipts_organization_id_connection_id_connections_organization_id_id_fk",
+ "tableFrom": "integration_receipts",
+ "tableTo": "connections",
+ "columnsFrom": [
+ "organization_id",
+ "connection_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "integration_receipts_connection_id_external_id_unique": {
+ "name": "integration_receipts_connection_id_external_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "connection_id",
+ "external_id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.internal_tasks": {
+ "name": "internal_tasks",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "relationship_id": {
+ "name": "relationship_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "due_at": {
+ "name": "due_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "time_zone": {
+ "name": "time_zone",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "recurrence": {
+ "name": "recurrence",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'open'"
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "internal_tasks_organization_id_product_id_status_due_at_index": {
+ "name": "internal_tasks_organization_id_product_id_status_due_at_index",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "product_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "due_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "internal_tasks_organization_id_organizations_id_fk": {
+ "name": "internal_tasks_organization_id_organizations_id_fk",
+ "tableFrom": "internal_tasks",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "internal_tasks_organization_id_product_id_products_organization_id_id_fk": {
+ "name": "internal_tasks_organization_id_product_id_products_organization_id_id_fk",
+ "tableFrom": "internal_tasks",
+ "tableTo": "products",
+ "columnsFrom": [
+ "organization_id",
+ "product_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "internal_tasks_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk": {
+ "name": "internal_tasks_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk",
+ "tableFrom": "internal_tasks",
+ "tableTo": "relationships",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "relationship_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "internal_tasks_organization_id_owner_id_memberships_organization_id_user_id_fk": {
+ "name": "internal_tasks_organization_id_owner_id_memberships_organization_id_user_id_fk",
+ "tableFrom": "internal_tasks",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "owner_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "internal_tasks_organization_id_product_id_id_unique": {
+ "name": "internal_tasks_organization_id_product_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "product_id",
+ "id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.invitations": {
+ "name": "invitations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_ids": {
+ "name": "product_ids",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token_hash": {
+ "name": "token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "inviter_id": {
+ "name": "inviter_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "accepted_at": {
+ "name": "accepted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "invitations_organization_idx": {
+ "name": "invitations_organization_idx",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "invitations_pending_email": {
+ "name": "invitations_pending_email",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "email",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"invitations\".\"accepted_at\" IS NULL AND \"invitations\".\"revoked_at\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "invitations_organization_id_organizations_id_fk": {
+ "name": "invitations_organization_id_organizations_id_fk",
+ "tableFrom": "invitations",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "invitations_inviter_id_user_id_fk": {
+ "name": "invitations_inviter_id_user_id_fk",
+ "tableFrom": "invitations",
+ "tableTo": "user",
+ "columnsFrom": [
+ "inviter_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "invitations_token_hash_unique": {
+ "name": "invitations_token_hash_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "token_hash"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {
+ "invitation_email_lowercase": {
+ "name": "invitation_email_lowercase",
+ "value": "\"invitations\".\"email\" = lower(\"invitations\".\"email\")"
+ },
+ "invitation_single_outcome": {
+ "name": "invitation_single_outcome",
+ "value": "\"invitations\".\"accepted_at\" IS NULL OR \"invitations\".\"revoked_at\" IS NULL"
+ }
+ },
+ "isRLSEnabled": true
+ },
+ "public.mcp_grants": {
+ "name": "mcp_grants",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_ids": {
+ "name": "product_ids",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "active": {
+ "name": "active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "mcp_grants_organization_id_organizations_id_fk": {
+ "name": "mcp_grants_organization_id_organizations_id_fk",
+ "tableFrom": "mcp_grants",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "mcp_grants_user_id_user_id_fk": {
+ "name": "mcp_grants_user_id_user_id_fk",
+ "tableFrom": "mcp_grants",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "mcp_grants_organization_id_user_id_memberships_organization_id_user_id_fk": {
+ "name": "mcp_grants_organization_id_user_id_memberships_organization_id_user_id_fk",
+ "tableFrom": "mcp_grants",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "user_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.meetings": {
+ "name": "meetings",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "relationship_id": {
+ "name": "relationship_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "starts_at": {
+ "name": "starts_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "summary": {
+ "name": "summary",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "proposed_commitment": {
+ "name": "proposed_commitment",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "commitment_action_id": {
+ "name": "commitment_action_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "meetings_organization_id_organizations_id_fk": {
+ "name": "meetings_organization_id_organizations_id_fk",
+ "tableFrom": "meetings",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "meetings_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk": {
+ "name": "meetings_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk",
+ "tableFrom": "meetings",
+ "tableTo": "relationships",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "relationship_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "meetings_organization_id_product_id_commitment_action_id_actions_organization_id_product_id_id_fk": {
+ "name": "meetings_organization_id_product_id_commitment_action_id_actions_organization_id_product_id_id_fk",
+ "tableFrom": "meetings",
+ "tableTo": "actions",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "commitment_action_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.memberships": {
+ "name": "memberships",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "active": {
+ "name": "active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "memberships_organization_id_organizations_id_fk": {
+ "name": "memberships_organization_id_organizations_id_fk",
+ "tableFrom": "memberships",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "memberships_user_id_user_id_fk": {
+ "name": "memberships_user_id_user_id_fk",
+ "tableFrom": "memberships",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "memberships_organization_id_user_id_unique": {
+ "name": "memberships_organization_id_user_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "user_id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.messages": {
+ "name": "messages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "conversation_id": {
+ "name": "conversation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "connection_id": {
+ "name": "connection_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider_message_id": {
+ "name": "provider_message_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "direction": {
+ "name": "direction",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "occurred_at": {
+ "name": "occurred_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "messages_native_source": {
+ "name": "messages_native_source",
+ "columns": [
+ {
+ "expression": "conversation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider_message_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"messages\".\"connection_id\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "messages_activity_idx": {
+ "name": "messages_activity_idx",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "product_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "occurred_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "messages_organization_id_organizations_id_fk": {
+ "name": "messages_organization_id_organizations_id_fk",
+ "tableFrom": "messages",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "messages_organization_id_product_id_conversation_id_conversations_organization_id_product_id_id_fk": {
+ "name": "messages_organization_id_product_id_conversation_id_conversations_organization_id_product_id_id_fk",
+ "tableFrom": "messages",
+ "tableTo": "conversations",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "conversation_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "messages_organization_id_connection_id_connections_organization_id_id_fk": {
+ "name": "messages_organization_id_connection_id_connections_organization_id_id_fk",
+ "tableFrom": "messages",
+ "tableTo": "connections",
+ "columnsFrom": [
+ "organization_id",
+ "connection_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "messages_connection_id_provider_message_id_unique": {
+ "name": "messages_connection_id_provider_message_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "connection_id",
+ "provider_message_id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {
+ "message_body_source": {
+ "name": "message_body_source",
+ "value": "\"messages\".\"provider_message_id\" <> ''"
+ }
+ },
+ "isRLSEnabled": true
+ },
+ "public.native_drafts": {
+ "name": "native_drafts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "relationship_id": {
+ "name": "relationship_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_conversation_id": {
+ "name": "source_conversation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "channel": {
+ "name": "channel",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reason": {
+ "name": "reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_id": {
+ "name": "source_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_hash": {
+ "name": "source_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scheduled_action_id": {
+ "name": "scheduled_action_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "native_drafts_source": {
+ "name": "native_drafts_source",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "native_drafts_organization_id_organizations_id_fk": {
+ "name": "native_drafts_organization_id_organizations_id_fk",
+ "tableFrom": "native_drafts",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "native_drafts_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk": {
+ "name": "native_drafts_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk",
+ "tableFrom": "native_drafts",
+ "tableTo": "relationships",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "relationship_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "native_drafts_organization_id_owner_id_memberships_organization_id_user_id_fk": {
+ "name": "native_drafts_organization_id_owner_id_memberships_organization_id_user_id_fk",
+ "tableFrom": "native_drafts",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "owner_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "native_drafts_organization_id_product_id_source_conversation_id_conversations_organization_id_product_id_id_fk": {
+ "name": "native_drafts_organization_id_product_id_source_conversation_id_conversations_organization_id_product_id_id_fk",
+ "tableFrom": "native_drafts",
+ "tableTo": "conversations",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "source_conversation_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "native_drafts_organization_id_product_id_scheduled_action_id_actions_organization_id_product_id_id_fk": {
+ "name": "native_drafts_organization_id_product_id_scheduled_action_id_actions_organization_id_product_id_id_fk",
+ "tableFrom": "native_drafts",
+ "tableTo": "actions",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "scheduled_action_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "native_drafts_organization_id_product_id_id_unique": {
+ "name": "native_drafts_organization_id_product_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "product_id",
+ "id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {
+ "native_draft_source_hash": {
+ "name": "native_draft_source_hash",
+ "value": "\"native_drafts\".\"source_hash\" ~ '^[a-f0-9]{64}$'"
+ }
+ },
+ "isRLSEnabled": true
+ },
+ "public.oauth_selections": {
+ "name": "oauth_selections",
+ "schema": "",
+ "columns": {
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "flow_key": {
+ "name": "flow_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "grant_id": {
+ "name": "grant_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "oauth_selections_grant_id_mcp_grants_id_fk": {
+ "name": "oauth_selections_grant_id_mcp_grants_id_fk",
+ "tableFrom": "oauth_selections",
+ "tableTo": "mcp_grants",
+ "columnsFrom": [
+ "grant_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "oauth_selections_session_id_flow_key_pk": {
+ "name": "oauth_selections_session_id_flow_key_pk",
+ "columns": [
+ "session_id",
+ "flow_key"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.opportunities": {
+ "name": "opportunities",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "relationship_id": {
+ "name": "relationship_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "stage_id": {
+ "name": "stage_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "amount_minor": {
+ "name": "amount_minor",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "currency": {
+ "name": "currency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'USD'"
+ },
+ "tags": {
+ "name": "tags",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'open'"
+ },
+ "probability": {
+ "name": "probability",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expected_close_date": {
+ "name": "expected_close_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "closed_at": {
+ "name": "closed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "lost_reason": {
+ "name": "lost_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "opportunities_organization_id_organizations_id_fk": {
+ "name": "opportunities_organization_id_organizations_id_fk",
+ "tableFrom": "opportunities",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "opportunities_organization_id_owner_id_memberships_organization_id_user_id_fk": {
+ "name": "opportunities_organization_id_owner_id_memberships_organization_id_user_id_fk",
+ "tableFrom": "opportunities",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "owner_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "opportunities_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk": {
+ "name": "opportunities_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk",
+ "tableFrom": "opportunities",
+ "tableTo": "relationships",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "relationship_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "opportunities_organization_id_product_id_stage_id_stages_organization_id_product_id_id_fk": {
+ "name": "opportunities_organization_id_product_id_stage_id_stages_organization_id_product_id_id_fk",
+ "tableFrom": "opportunities",
+ "tableTo": "stages",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "stage_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {
+ "deal_amount_nonnegative": {
+ "name": "deal_amount_nonnegative",
+ "value": "\"opportunities\".\"amount_minor\" IS NULL OR \"opportunities\".\"amount_minor\" >= 0"
+ },
+ "deal_probability_valid": {
+ "name": "deal_probability_valid",
+ "value": "\"opportunities\".\"probability\" IS NULL OR (\"opportunities\".\"probability\" >= 0 AND \"opportunities\".\"probability\" <= 100)"
+ },
+ "deal_status_valid": {
+ "name": "deal_status_valid",
+ "value": "\"opportunities\".\"status\" IN ('open', 'won', 'lost')"
+ },
+ "deal_currency_valid": {
+ "name": "deal_currency_valid",
+ "value": "\"opportunities\".\"currency\" ~ '^[A-Z]{3}$'"
+ }
+ },
+ "isRLSEnabled": true
+ },
+ "public.organizations": {
+ "name": "organizations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "timezone": {
+ "name": "timezone",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'UTC'"
+ },
+ "allowed_email_domains": {
+ "name": "allowed_email_domains",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "organizations_slug_unique": {
+ "name": "organizations_slug_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "slug"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.people": {
+ "name": "people",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "company_id": {
+ "name": "company_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "other_emails": {
+ "name": "other_emails",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "phone": {
+ "name": "phone",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "linkedin_url": {
+ "name": "linkedin_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "summary": {
+ "name": "summary",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "do_not_contact": {
+ "name": "do_not_contact",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "time_zone": {
+ "name": "time_zone",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "tags": {
+ "name": "tags",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "amount_minor": {
+ "name": "amount_minor",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "currency": {
+ "name": "currency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'USD'"
+ }
+ },
+ "indexes": {
+ "people_company_browse": {
+ "name": "people_company_browse",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "company_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "archived_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "people_name_browse": {
+ "name": "people_name_browse",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "people_organization_linkedin_url": {
+ "name": "people_organization_linkedin_url",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "lower(\"linkedin_url\")",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"people\".\"linkedin_url\" <> ''",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "people_organization_id_organizations_id_fk": {
+ "name": "people_organization_id_organizations_id_fk",
+ "tableFrom": "people",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "people_organization_id_company_id_companies_organization_id_id_fk": {
+ "name": "people_organization_id_company_id_companies_organization_id_id_fk",
+ "tableFrom": "people",
+ "tableTo": "companies",
+ "columnsFrom": [
+ "organization_id",
+ "company_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "people_organization_id_id_unique": {
+ "name": "people_organization_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {
+ "person_amount_nonnegative": {
+ "name": "person_amount_nonnegative",
+ "value": "\"people\".\"amount_minor\" IS NULL OR \"people\".\"amount_minor\" >= 0"
+ },
+ "person_currency_valid": {
+ "name": "person_currency_valid",
+ "value": "\"people\".\"currency\" ~ '^[A-Z]{3}$'"
+ }
+ },
+ "isRLSEnabled": true
+ },
+ "public.pipelines": {
+ "name": "pipelines",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "pipelines_organization_id_organizations_id_fk": {
+ "name": "pipelines_organization_id_organizations_id_fk",
+ "tableFrom": "pipelines",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "pipelines_organization_id_product_id_products_organization_id_id_fk": {
+ "name": "pipelines_organization_id_product_id_products_organization_id_id_fk",
+ "tableFrom": "pipelines",
+ "tableTo": "products",
+ "columnsFrom": [
+ "organization_id",
+ "product_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "pipelines_organization_id_product_id_id_unique": {
+ "name": "pipelines_organization_id_product_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "product_id",
+ "id"
+ ]
+ },
+ "pipelines_organization_id_product_id_name_unique": {
+ "name": "pipelines_organization_id_product_id_name_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "product_id",
+ "name"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.product_memberships": {
+ "name": "product_memberships",
+ "schema": "",
+ "columns": {
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "product_memberships_organization_id_organizations_id_fk": {
+ "name": "product_memberships_organization_id_organizations_id_fk",
+ "tableFrom": "product_memberships",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "product_memberships_user_id_user_id_fk": {
+ "name": "product_memberships_user_id_user_id_fk",
+ "tableFrom": "product_memberships",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "product_memberships_organization_id_product_id_products_organization_id_id_fk": {
+ "name": "product_memberships_organization_id_product_id_products_organization_id_id_fk",
+ "tableFrom": "product_memberships",
+ "tableTo": "products",
+ "columnsFrom": [
+ "organization_id",
+ "product_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "product_memberships_organization_id_user_id_memberships_organization_id_user_id_fk": {
+ "name": "product_memberships_organization_id_user_id_memberships_organization_id_user_id_fk",
+ "tableFrom": "product_memberships",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "user_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "product_memberships_organization_id_product_id_user_id_unique": {
+ "name": "product_memberships_organization_id_product_id_user_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "product_id",
+ "user_id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.products": {
+ "name": "products",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "color": {
+ "name": "color",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'#7565cf'"
+ },
+ "color_key": {
+ "name": "color_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'violet'"
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "products_organization_id_organizations_id_fk": {
+ "name": "products_organization_id_organizations_id_fk",
+ "tableFrom": "products",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "products_organization_id_id_unique": {
+ "name": "products_organization_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "id"
+ ]
+ },
+ "products_organization_id_name_unique": {
+ "name": "products_organization_id_name_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "name"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {
+ "product_color_key": {
+ "name": "product_color_key",
+ "value": "\"products\".\"color_key\" IN ('violet', 'blue', 'teal', 'green', 'yellow', 'orange', 'red', 'pink', 'gray')"
+ }
+ },
+ "isRLSEnabled": true
+ },
+ "public.provider_configurations": {
+ "name": "provider_configurations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_credentials": {
+ "name": "encrypted_credentials",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "webhook_ready": {
+ "name": "webhook_ready",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "active": {
+ "name": "active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "provider_configurations_active_owner": {
+ "name": "provider_configurations_active_owner",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"provider_configurations\".\"active\" = true",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "provider_configurations_organization_id_organizations_id_fk": {
+ "name": "provider_configurations_organization_id_organizations_id_fk",
+ "tableFrom": "provider_configurations",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "provider_configurations_organization_id_owner_id_memberships_organization_id_user_id_fk": {
+ "name": "provider_configurations_organization_id_owner_id_memberships_organization_id_user_id_fk",
+ "tableFrom": "provider_configurations",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "owner_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "provider_configurations_organization_id_owner_id_id_unique": {
+ "name": "provider_configurations_organization_id_owner_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "owner_id",
+ "id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.relationships": {
+ "name": "relationships",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "person_id": {
+ "name": "person_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "purpose": {
+ "name": "purpose",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'buyer'"
+ },
+ "qualification": {
+ "name": "qualification",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'unverified'"
+ },
+ "context": {
+ "name": "context",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "context_details": {
+ "name": "context_details",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{\"background\":\"\",\"needs\":\"\",\"timing\":\"\",\"budget\":\"\",\"decisionProcess\":\"\",\"risks\":\"\",\"history\":\"\",\"signals\":[],\"fields\":[]}'::jsonb"
+ },
+ "context_source": {
+ "name": "context_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stage_id": {
+ "name": "stage_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stage_pipeline": {
+ "name": "stage_pipeline",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'outreach'"
+ },
+ "priority": {
+ "name": "priority",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'normal'"
+ },
+ "next_step": {
+ "name": "next_step",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "next_step_due_at": {
+ "name": "next_step_due_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_outbound_at": {
+ "name": "last_outbound_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_inbound_at": {
+ "name": "last_inbound_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "touch_count": {
+ "name": "touch_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "tags": {
+ "name": "tags",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "amount_minor": {
+ "name": "amount_minor",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "currency": {
+ "name": "currency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'USD'"
+ }
+ },
+ "indexes": {
+ "relationships_person_browse": {
+ "name": "relationships_person_browse",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "person_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "product_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "relationships_organization_id_organizations_id_fk": {
+ "name": "relationships_organization_id_organizations_id_fk",
+ "tableFrom": "relationships",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "relationships_organization_id_product_id_stage_id_stage_pipeline_stages_organization_id_product_id_id_pipeline_fk": {
+ "name": "relationships_organization_id_product_id_stage_id_stage_pipeline_stages_organization_id_product_id_id_pipeline_fk",
+ "tableFrom": "relationships",
+ "tableTo": "stages",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "stage_id",
+ "stage_pipeline"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id",
+ "pipeline"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "relationships_organization_id_product_id_products_organization_id_id_fk": {
+ "name": "relationships_organization_id_product_id_products_organization_id_id_fk",
+ "tableFrom": "relationships",
+ "tableTo": "products",
+ "columnsFrom": [
+ "organization_id",
+ "product_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "relationships_organization_id_person_id_people_organization_id_id_fk": {
+ "name": "relationships_organization_id_person_id_people_organization_id_id_fk",
+ "tableFrom": "relationships",
+ "tableTo": "people",
+ "columnsFrom": [
+ "organization_id",
+ "person_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "relationships_organization_id_owner_id_memberships_organization_id_user_id_fk": {
+ "name": "relationships_organization_id_owner_id_memberships_organization_id_user_id_fk",
+ "tableFrom": "relationships",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "owner_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "relationships_organization_id_id_unique": {
+ "name": "relationships_organization_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "id"
+ ]
+ },
+ "relationships_organization_id_product_id_id_unique": {
+ "name": "relationships_organization_id_product_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "product_id",
+ "id"
+ ]
+ },
+ "relationships_organization_id_product_id_person_id_purpose_unique": {
+ "name": "relationships_organization_id_product_id_person_id_purpose_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "product_id",
+ "person_id",
+ "purpose"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {
+ "relationship_amount_nonnegative": {
+ "name": "relationship_amount_nonnegative",
+ "value": "\"relationships\".\"amount_minor\" IS NULL OR \"relationships\".\"amount_minor\" >= 0"
+ },
+ "relationship_currency_valid": {
+ "name": "relationship_currency_valid",
+ "value": "\"relationships\".\"currency\" ~ '^[A-Z]{3}$'"
+ },
+ "relationship_stage_outreach": {
+ "name": "relationship_stage_outreach",
+ "value": "\"relationships\".\"stage_pipeline\" = 'outreach'"
+ },
+ "relationship_touch_count": {
+ "name": "relationship_touch_count",
+ "value": "\"relationships\".\"touch_count\" >= 0"
+ }
+ },
+ "isRLSEnabled": true
+ },
+ "public.sequences": {
+ "name": "sequences",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "steps": {
+ "name": "steps",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "sequences_organization_id_organizations_id_fk": {
+ "name": "sequences_organization_id_organizations_id_fk",
+ "tableFrom": "sequences",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "sequences_organization_id_product_id_products_organization_id_id_fk": {
+ "name": "sequences_organization_id_product_id_products_organization_id_id_fk",
+ "tableFrom": "sequences",
+ "tableTo": "products",
+ "columnsFrom": [
+ "organization_id",
+ "product_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "sequences_organization_id_product_id_id_unique": {
+ "name": "sequences_organization_id_product_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "product_id",
+ "id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.stages": {
+ "name": "stages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pipeline_id": {
+ "name": "pipeline_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "position": {
+ "name": "position",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pipeline": {
+ "name": "pipeline",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'deal'"
+ },
+ "category": {
+ "name": "category",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'open'"
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "stages_organization_id_organizations_id_fk": {
+ "name": "stages_organization_id_organizations_id_fk",
+ "tableFrom": "stages",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "stages_organization_id_product_id_pipeline_id_pipelines_organization_id_product_id_id_fk": {
+ "name": "stages_organization_id_product_id_pipeline_id_pipelines_organization_id_product_id_id_fk",
+ "tableFrom": "stages",
+ "tableTo": "pipelines",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "pipeline_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "stages_organization_id_product_id_products_organization_id_id_fk": {
+ "name": "stages_organization_id_product_id_products_organization_id_id_fk",
+ "tableFrom": "stages",
+ "tableTo": "products",
+ "columnsFrom": [
+ "organization_id",
+ "product_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "stages_organization_id_product_id_id_unique": {
+ "name": "stages_organization_id_product_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "product_id",
+ "id"
+ ]
+ },
+ "stages_organization_id_product_id_id_pipeline_unique": {
+ "name": "stages_organization_id_product_id_id_pipeline_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "product_id",
+ "id",
+ "pipeline"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.touches": {
+ "name": "touches",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "relationship_id": {
+ "name": "relationship_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "enrollment_id": {
+ "name": "enrollment_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "step_number": {
+ "name": "step_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "follow_up": {
+ "name": "follow_up",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "channel": {
+ "name": "channel",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sender_id": {
+ "name": "sender_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "due_at": {
+ "name": "due_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'planned'"
+ },
+ "draft": {
+ "name": "draft",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "draft_hash": {
+ "name": "draft_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "approved_hash": {
+ "name": "approved_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "approved_by": {
+ "name": "approved_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sent_by": {
+ "name": "sent_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sent_at": {
+ "name": "sent_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "external_message_id": {
+ "name": "external_message_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sent_warnings": {
+ "name": "sent_warnings",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "skip_reason": {
+ "name": "skip_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "closed_at": {
+ "name": "closed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "touches_enrollment_step": {
+ "name": "touches_enrollment_step",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "relationship_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "enrollment_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "step_number",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "touches_external_message": {
+ "name": "touches_external_message",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "channel",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "external_message_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"touches\".\"external_message_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "touches_organization_id_product_id_status_due_at_index": {
+ "name": "touches_organization_id_product_id_status_due_at_index",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "product_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "due_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "touches_organization_id_organizations_id_fk": {
+ "name": "touches_organization_id_organizations_id_fk",
+ "tableFrom": "touches",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "touches_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk": {
+ "name": "touches_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk",
+ "tableFrom": "touches",
+ "tableTo": "relationships",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "relationship_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "touches_organization_id_product_id_relationship_id_enrollment_id_enrollments_organization_id_product_id_relationship_id_id_fk": {
+ "name": "touches_organization_id_product_id_relationship_id_enrollment_id_enrollments_organization_id_product_id_relationship_id_id_fk",
+ "tableFrom": "touches",
+ "tableTo": "enrollments",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "relationship_id",
+ "enrollment_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "relationship_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "touches_organization_id_sender_id_memberships_organization_id_user_id_fk": {
+ "name": "touches_organization_id_sender_id_memberships_organization_id_user_id_fk",
+ "tableFrom": "touches",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "sender_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "touches_organization_id_approved_by_memberships_organization_id_user_id_fk": {
+ "name": "touches_organization_id_approved_by_memberships_organization_id_user_id_fk",
+ "tableFrom": "touches",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "approved_by"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "touches_organization_id_sent_by_memberships_organization_id_user_id_fk": {
+ "name": "touches_organization_id_sent_by_memberships_organization_id_user_id_fk",
+ "tableFrom": "touches",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "sent_by"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "touches_organization_id_product_id_id_unique": {
+ "name": "touches_organization_id_product_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "product_id",
+ "id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {
+ "touch_follow_up": {
+ "name": "touch_follow_up",
+ "value": "\"touches\".\"follow_up\" BETWEEN 0 AND 3"
+ },
+ "touch_sent_report": {
+ "name": "touch_sent_report",
+ "value": "(\"touches\".\"status\" = 'sent') = (\"touches\".\"sent_at\" IS NOT NULL AND \"touches\".\"sent_by\" IS NOT NULL)"
+ },
+ "touch_approval": {
+ "name": "touch_approval",
+ "value": "\"touches\".\"status\" <> 'approved' OR (\"touches\".\"approved_hash\" IS NOT NULL AND \"touches\".\"approved_hash\" = \"touches\".\"draft_hash\")"
+ }
+ },
+ "isRLSEnabled": true
+ },
+ "public.yodu_bindings": {
+ "name": "yodu_bindings",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_id": {
+ "name": "source_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "external_subject_id": {
+ "name": "external_subject_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "relationship_id": {
+ "name": "relationship_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "yodu_bindings_organization_id_organizations_id_fk": {
+ "name": "yodu_bindings_organization_id_organizations_id_fk",
+ "tableFrom": "yodu_bindings",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "yodu_bindings_organization_id_product_id_source_id_yodu_sources_organization_id_product_id_id_fk": {
+ "name": "yodu_bindings_organization_id_product_id_source_id_yodu_sources_organization_id_product_id_id_fk",
+ "tableFrom": "yodu_bindings",
+ "tableTo": "yodu_sources",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "source_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "yodu_bindings_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk": {
+ "name": "yodu_bindings_organization_id_product_id_relationship_id_relationships_organization_id_product_id_id_fk",
+ "tableFrom": "yodu_bindings",
+ "tableTo": "relationships",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "relationship_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "yodu_bindings_organization_id_created_by_memberships_organization_id_user_id_fk": {
+ "name": "yodu_bindings_organization_id_created_by_memberships_organization_id_user_id_fk",
+ "tableFrom": "yodu_bindings",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "created_by"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "yodu_bindings_source_id_external_subject_id_unique": {
+ "name": "yodu_bindings_source_id_external_subject_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "source_id",
+ "external_subject_id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.yodu_events": {
+ "name": "yodu_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_id": {
+ "name": "source_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "external_subject_id": {
+ "name": "external_subject_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_event_id": {
+ "name": "provider_event_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "occurred_at": {
+ "name": "occurred_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "received_at": {
+ "name": "received_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payload_hash": {
+ "name": "payload_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_version": {
+ "name": "source_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "yodu_events_product_received": {
+ "name": "yodu_events_product_received",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "product_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "received_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "yodu_events_organization_id_organizations_id_fk": {
+ "name": "yodu_events_organization_id_organizations_id_fk",
+ "tableFrom": "yodu_events",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "yodu_events_organization_id_product_id_source_id_yodu_sources_organization_id_product_id_id_fk": {
+ "name": "yodu_events_organization_id_product_id_source_id_yodu_sources_organization_id_product_id_id_fk",
+ "tableFrom": "yodu_events",
+ "tableTo": "yodu_sources",
+ "columnsFrom": [
+ "organization_id",
+ "product_id",
+ "source_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "product_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "yodu_events_source_id_provider_event_id_unique": {
+ "name": "yodu_events_source_id_provider_event_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "source_id",
+ "provider_event_id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {
+ "yodu_event_kind": {
+ "name": "yodu_event_kind",
+ "value": "\"yodu_events\".\"kind\" IN ('signup', 'onboarding', 'payment', 'activation')"
+ },
+ "yodu_event_hash": {
+ "name": "yodu_event_hash",
+ "value": "\"yodu_events\".\"payload_hash\" ~ '^[a-f0-9]{64}$'"
+ },
+ "yodu_event_source_version": {
+ "name": "yodu_event_source_version",
+ "value": "\"yodu_events\".\"source_version\" > 0"
+ }
+ },
+ "isRLSEnabled": true
+ },
+ "public.yodu_sources": {
+ "name": "yodu_sources",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "product_id": {
+ "name": "product_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "label": {
+ "name": "label",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "encrypted_secret": {
+ "name": "encrypted_secret",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "yodu_sources_organization_id_organizations_id_fk": {
+ "name": "yodu_sources_organization_id_organizations_id_fk",
+ "tableFrom": "yodu_sources",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "yodu_sources_organization_id_product_id_products_organization_id_id_fk": {
+ "name": "yodu_sources_organization_id_product_id_products_organization_id_id_fk",
+ "tableFrom": "yodu_sources",
+ "tableTo": "products",
+ "columnsFrom": [
+ "organization_id",
+ "product_id"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "yodu_sources_organization_id_created_by_memberships_organization_id_user_id_fk": {
+ "name": "yodu_sources_organization_id_created_by_memberships_organization_id_user_id_fk",
+ "tableFrom": "yodu_sources",
+ "tableTo": "memberships",
+ "columnsFrom": [
+ "organization_id",
+ "created_by"
+ ],
+ "columnsTo": [
+ "organization_id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "yodu_sources_organization_id_product_id_id_unique": {
+ "name": "yodu_sources_organization_id_product_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "organization_id",
+ "product_id",
+ "id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.account": {
+ "name": "account",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "account_id": {
+ "name": "account_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_id": {
+ "name": "provider_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "access_token": {
+ "name": "access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token": {
+ "name": "refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "id_token": {
+ "name": "id_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_token_expires_at": {
+ "name": "access_token_expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token_expires_at": {
+ "name": "refresh_token_expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "password": {
+ "name": "password",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "account_userId_idx": {
+ "name": "account_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "account_user_id_user_id_fk": {
+ "name": "account_user_id_user_id_fk",
+ "tableFrom": "account",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.jwks": {
+ "name": "jwks",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "public_key": {
+ "name": "public_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "private_key": {
+ "name": "private_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alg": {
+ "name": "alg",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "crv": {
+ "name": "crv",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.oauth_access_token": {
+ "name": "oauth_access_token",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reference_id": {
+ "name": "reference_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "authorization_code_id": {
+ "name": "authorization_code_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resources": {
+ "name": "resources",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "requested_user_info_claims": {
+ "name": "requested_user_info_claims",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_id": {
+ "name": "refresh_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revoked": {
+ "name": "revoked",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "confirmation": {
+ "name": "confirmation",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scopes": {
+ "name": "scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "oauthAccessToken_clientId_idx": {
+ "name": "oauthAccessToken_clientId_idx",
+ "columns": [
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "oauthAccessToken_sessionId_idx": {
+ "name": "oauthAccessToken_sessionId_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "oauthAccessToken_userId_idx": {
+ "name": "oauthAccessToken_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "oauthAccessToken_authorizationCodeId_idx": {
+ "name": "oauthAccessToken_authorizationCodeId_idx",
+ "columns": [
+ {
+ "expression": "authorization_code_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "oauthAccessToken_refreshId_idx": {
+ "name": "oauthAccessToken_refreshId_idx",
+ "columns": [
+ {
+ "expression": "refresh_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "oauth_access_token_client_id_oauth_client_client_id_fk": {
+ "name": "oauth_access_token_client_id_oauth_client_client_id_fk",
+ "tableFrom": "oauth_access_token",
+ "tableTo": "oauth_client",
+ "columnsFrom": [
+ "client_id"
+ ],
+ "columnsTo": [
+ "client_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "oauth_access_token_session_id_session_id_fk": {
+ "name": "oauth_access_token_session_id_session_id_fk",
+ "tableFrom": "oauth_access_token",
+ "tableTo": "session",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "oauth_access_token_user_id_user_id_fk": {
+ "name": "oauth_access_token_user_id_user_id_fk",
+ "tableFrom": "oauth_access_token",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "oauth_access_token_refresh_id_oauth_refresh_token_id_fk": {
+ "name": "oauth_access_token_refresh_id_oauth_refresh_token_id_fk",
+ "tableFrom": "oauth_access_token",
+ "tableTo": "oauth_refresh_token",
+ "columnsFrom": [
+ "refresh_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "oauth_access_token_token_unique": {
+ "name": "oauth_access_token_token_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "token"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.oauth_client": {
+ "name": "oauth_client",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_secret": {
+ "name": "client_secret",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "client_discovery_id": {
+ "name": "client_discovery_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "disabled": {
+ "name": "disabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "skip_consent": {
+ "name": "skip_consent",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enable_end_session": {
+ "name": "enable_end_session",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "subject_type": {
+ "name": "subject_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scopes": {
+ "name": "scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "client_credentials_scopes": {
+ "name": "client_credentials_scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'{}'"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uri": {
+ "name": "uri",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "icon": {
+ "name": "icon",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "contacts": {
+ "name": "contacts",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tos": {
+ "name": "tos",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "policy": {
+ "name": "policy",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "software_id": {
+ "name": "software_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "software_version": {
+ "name": "software_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "software_statement": {
+ "name": "software_statement",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "redirect_uris": {
+ "name": "redirect_uris",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "post_logout_redirect_uris": {
+ "name": "post_logout_redirect_uris",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "backchannel_logout_uri": {
+ "name": "backchannel_logout_uri",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "backchannel_logout_session_required": {
+ "name": "backchannel_logout_session_required",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "token_endpoint_auth_method": {
+ "name": "token_endpoint_auth_method",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "application_type": {
+ "name": "application_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "jwks": {
+ "name": "jwks",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "jwks_uri": {
+ "name": "jwks_uri",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "grant_types": {
+ "name": "grant_types",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "response_types": {
+ "name": "response_types",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "require_pkce": {
+ "name": "require_pkce",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dpop_bound_access_tokens": {
+ "name": "dpop_bound_access_tokens",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "reference_id": {
+ "name": "reference_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "oauthClient_userId_idx": {
+ "name": "oauthClient_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "oauth_client_user_id_user_id_fk": {
+ "name": "oauth_client_user_id_user_id_fk",
+ "tableFrom": "oauth_client",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "oauth_client_client_id_unique": {
+ "name": "oauth_client_client_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "client_id"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.oauth_client_assertion": {
+ "name": "oauth_client_assertion",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.oauth_client_resource": {
+ "name": "oauth_client_resource",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "resource_id": {
+ "name": "resource_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "oauthClientResource_clientId_resourceId_uidx": {
+ "name": "oauthClientResource_clientId_resourceId_uidx",
+ "columns": [
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "resource_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "oauthClientResource_clientId_idx": {
+ "name": "oauthClientResource_clientId_idx",
+ "columns": [
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "oauthClientResource_resourceId_idx": {
+ "name": "oauthClientResource_resourceId_idx",
+ "columns": [
+ {
+ "expression": "resource_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "oauth_client_resource_client_id_oauth_client_client_id_fk": {
+ "name": "oauth_client_resource_client_id_oauth_client_client_id_fk",
+ "tableFrom": "oauth_client_resource",
+ "tableTo": "oauth_client",
+ "columnsFrom": [
+ "client_id"
+ ],
+ "columnsTo": [
+ "client_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "oauth_client_resource_resource_id_oauth_resource_identifier_fk": {
+ "name": "oauth_client_resource_resource_id_oauth_resource_identifier_fk",
+ "tableFrom": "oauth_client_resource",
+ "tableTo": "oauth_resource",
+ "columnsFrom": [
+ "resource_id"
+ ],
+ "columnsTo": [
+ "identifier"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.oauth_consent": {
+ "name": "oauth_consent",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reference_id": {
+ "name": "reference_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resources": {
+ "name": "resources",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "requested_user_info_claims": {
+ "name": "requested_user_info_claims",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scopes": {
+ "name": "scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "oauthConsent_clientId_idx": {
+ "name": "oauthConsent_clientId_idx",
+ "columns": [
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "oauthConsent_userId_idx": {
+ "name": "oauthConsent_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "oauth_consent_client_id_oauth_client_client_id_fk": {
+ "name": "oauth_consent_client_id_oauth_client_client_id_fk",
+ "tableFrom": "oauth_consent",
+ "tableTo": "oauth_client",
+ "columnsFrom": [
+ "client_id"
+ ],
+ "columnsTo": [
+ "client_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "oauth_consent_user_id_user_id_fk": {
+ "name": "oauth_consent_user_id_user_id_fk",
+ "tableFrom": "oauth_consent",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.oauth_refresh_token": {
+ "name": "oauth_refresh_token",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reference_id": {
+ "name": "reference_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "authorization_code_id": {
+ "name": "authorization_code_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resources": {
+ "name": "resources",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "requested_user_info_claims": {
+ "name": "requested_user_info_claims",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revoked": {
+ "name": "revoked",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rotated_at": {
+ "name": "rotated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rotation_replay_response": {
+ "name": "rotation_replay_response",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rotation_replay_expires_at": {
+ "name": "rotation_replay_expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "auth_time": {
+ "name": "auth_time",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "confirmation": {
+ "name": "confirmation",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scopes": {
+ "name": "scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "oauthRefreshToken_clientId_idx": {
+ "name": "oauthRefreshToken_clientId_idx",
+ "columns": [
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "oauthRefreshToken_sessionId_idx": {
+ "name": "oauthRefreshToken_sessionId_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "oauthRefreshToken_userId_idx": {
+ "name": "oauthRefreshToken_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "oauthRefreshToken_authorizationCodeId_idx": {
+ "name": "oauthRefreshToken_authorizationCodeId_idx",
+ "columns": [
+ {
+ "expression": "authorization_code_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "oauth_refresh_token_client_id_oauth_client_client_id_fk": {
+ "name": "oauth_refresh_token_client_id_oauth_client_client_id_fk",
+ "tableFrom": "oauth_refresh_token",
+ "tableTo": "oauth_client",
+ "columnsFrom": [
+ "client_id"
+ ],
+ "columnsTo": [
+ "client_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "oauth_refresh_token_session_id_session_id_fk": {
+ "name": "oauth_refresh_token_session_id_session_id_fk",
+ "tableFrom": "oauth_refresh_token",
+ "tableTo": "session",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "oauth_refresh_token_user_id_user_id_fk": {
+ "name": "oauth_refresh_token_user_id_user_id_fk",
+ "tableFrom": "oauth_refresh_token",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "oauth_refresh_token_token_unique": {
+ "name": "oauth_refresh_token_token_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "token"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.oauth_resource": {
+ "name": "oauth_resource",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "access_token_ttl": {
+ "name": "access_token_ttl",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token_ttl": {
+ "name": "refresh_token_ttl",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "signing_algorithm": {
+ "name": "signing_algorithm",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "signing_key_id": {
+ "name": "signing_key_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "allowed_scopes": {
+ "name": "allowed_scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "custom_claims": {
+ "name": "custom_claims",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dpop_bound_access_tokens_required": {
+ "name": "dpop_bound_access_tokens_required",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "disabled": {
+ "name": "disabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "policy_version": {
+ "name": "policy_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 1
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "oauth_resource_identifier_unique": {
+ "name": "oauth_resource_identifier_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "identifier"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.session": {
+ "name": "session",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ip_address": {
+ "name": "ip_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_agent": {
+ "name": "user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "session_userId_idx": {
+ "name": "session_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "session_user_id_user_id_fk": {
+ "name": "session_user_id_user_id_fk",
+ "tableFrom": "session",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "session_token_unique": {
+ "name": "session_token_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "token"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.user": {
+ "name": "user",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email_verified": {
+ "name": "email_verified",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "image": {
+ "name": "image",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_email_unique": {
+ "name": "user_email_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "email"
+ ]
+ }
+ },
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ },
+ "public.verification": {
+ "name": "verification",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "verification_identifier_idx": {
+ "name": "verification_identifier_idx",
+ "columns": [
+ {
+ "expression": "identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {
+ "gravity_server_access": {
+ "name": "gravity_server_access",
+ "as": "PERMISSIVE",
+ "for": "ALL",
+ "to": [
+ "gravity_app"
+ ],
+ "using": "true",
+ "withCheck": "true"
+ }
+ },
+ "checkConstraints": {},
+ "isRLSEnabled": true
+ }
+ },
+ "enums": {},
+ "schemas": {},
+ "sequences": {},
+ "roles": {},
+ "policies": {},
+ "views": {},
+ "_meta": {
+ "columns": {},
+ "schemas": {},
+ "tables": {}
+ }
+}
\ No newline at end of file
diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json
index 4226e0ff..d56ac5d2 100644
--- a/drizzle/meta/_journal.json
+++ b/drizzle/meta/_journal.json
@@ -176,6 +176,20 @@
"when": 1791316608067,
"tag": "0024_stiff_namorita",
"breakpoints": true
+ },
+ {
+ "idx": 25,
+ "version": "7",
+ "when": 1791466373186,
+ "tag": "0025_remaining_crm_features",
+ "breakpoints": true
+ },
+ {
+ "idx": 26,
+ "version": "7",
+ "when": 1791471931369,
+ "tag": "0026_deal_archiving",
+ "breakpoints": true
}
]
}
\ No newline at end of file
diff --git a/packages/connectors/outbound.ts b/packages/connectors/outbound.ts
index 70ddfc0a..35657f20 100644
--- a/packages/connectors/outbound.ts
+++ b/packages/connectors/outbound.ts
@@ -1,7 +1,12 @@
import { createHash, randomUUID } from "node:crypto";
-import { and, asc, eq, inArray, sql } from "drizzle-orm";
+import { and, asc, eq, inArray, isNull, or, sql } from "drizzle-orm";
import { z } from "zod";
import { publishChange } from "../core/changes";
+import {
+ contactHistoryChecks,
+ contactIdentityIds,
+ lockContactDirectory,
+} from "../core/contact-history";
import { scopeSchema } from "../core/crm";
import { draftHash, draftSubject } from "../core/drafts";
import { OutreachService, outboundGate } from "../core/outreach";
@@ -159,7 +164,13 @@ export class OutboundService {
: [];
const found = touch ?? action;
if (!found) throw new DomainError("NOT_FOUND", 404);
- await authorize(db, principal, input.organizationId, found.productId, lock);
+ let permission = await authorize(
+ db,
+ principal,
+ input.organizationId,
+ found.productId,
+ lock,
+ );
if (input.productId && input.productId !== found.productId)
throw new DomainError("FORBIDDEN", 403);
if ((touch?.senderId ?? action?.ownerId) !== principal.userId)
@@ -175,6 +186,7 @@ export class OutboundService {
),
);
if (!relationship) throw new DomainError("NOT_FOUND", 404);
+ if (lock) await lockContactDirectory(db, input.organizationId);
const peopleQuery = db
.select()
.from(s.people)
@@ -184,8 +196,27 @@ export class OutboundService {
eq(s.people.organizationId, input.organizationId),
),
);
- const [person] = await (lock ? peopleQuery.for("update") : peopleQuery);
+ let [person] = await peopleQuery;
if (!person) throw new DomainError("NOT_FOUND", 404);
+ if (lock) {
+ const identities = await contactIdentityIds(
+ db,
+ input.organizationId,
+ person,
+ );
+ const people = await db
+ .select()
+ .from(s.people)
+ .where(
+ and(
+ eq(s.people.organizationId, input.organizationId),
+ inArray(s.people.id, identities),
+ ),
+ )
+ .orderBy(asc(s.people.id))
+ .for("update");
+ person = people.find((row) => row.id === person.id) ?? person;
+ }
await assertActiveRelationships(db, input.organizationId, [
relationship.id,
]);
@@ -204,7 +235,7 @@ export class OutboundService {
// Recheck membership after waiting for the quota lock: revocation may have
// committed since the first authorization read.
if (lock)
- await authorize(
+ permission = await authorize(
db,
principal,
input.organizationId,
@@ -315,7 +346,13 @@ export class OutboundService {
eq(s.conversations.organizationId, input.organizationId),
eq(s.conversations.productId, record.productId),
eq(s.conversations.relationshipId, relationship.id),
- eq(s.conversations.connectionId, connection.id),
+ or(
+ eq(s.conversations.connectionId, connection.id),
+ and(
+ eq(s.conversations.provenance, "native"),
+ isNull(s.conversations.connectionId),
+ ),
+ ),
eq(s.conversations.ownerId, principal.userId),
eq(
s.conversations.channel,
@@ -326,6 +363,8 @@ export class OutboundService {
: [];
if (conversationId && !conversation)
throw new DomainError("FORBIDDEN", 403);
+ const providerConversation =
+ conversation?.provenance === "native" ? undefined : conversation;
const hash = draftHash({
draft: record.draft,
...(await draftSubject(db, person)),
@@ -344,6 +383,13 @@ export class OutboundService {
input.organizationId,
person,
);
+ const history = await contactHistoryChecks(
+ db,
+ principal,
+ input.organizationId,
+ person,
+ permission.products.map((product) => product.id),
+ );
return {
touch: !!touch,
identityOptedOut,
@@ -351,7 +397,8 @@ export class OutboundService {
relationship,
person,
connection,
- conversation,
+ conversation: providerConversation,
+ history,
hash,
gate,
enrollment,
@@ -376,6 +423,8 @@ export class OutboundService {
throw new DomainError("SOURCE_NOT_SENDABLE", 409);
if (person.doNotContact || source.identityOptedOut)
throw new DomainError("DO_NOT_CONTACT", 409);
+ if (source.history.blockedBy)
+ throw new DomainError(source.history.blockedBy, 409);
if (
touch
? record.status !== "approved" || enrollment?.status !== "running"
@@ -431,7 +480,7 @@ export class OutboundService {
.where(
and(
eq(s.deliveries.organizationId, input.organizationId),
- eq(s.relationships.personId, source.person.id),
+ inArray(s.relationships.personId, source.history.identities),
inArray(s.deliveries.status, ["sending", "unknown", "accepted"]),
),
);
@@ -453,21 +502,38 @@ export class OutboundService {
draft: source.record.draft,
connectionId: source.connection.id,
conversationId: source.conversation?.id ?? null,
- policy: {
- ...source.gate,
- sendAfter:
- source.gate.sendAfter === null
- ? null
- : new Date(source.gate.sendAfter).toISOString(),
- reasons: source.gate.reasons.map((reason) => ({
- ...reason,
- ...("until" in reason
- ? { until: new Date(reason.until).toISOString() }
- : {}),
- })),
- },
+ // Cooldown arithmetic can disclose the exact time of a private message.
+ // Keep the full gate for dispatch, but withhold its public timing details
+ // until the caller can review all relevant history.
+ policy: source.history.blockedBy
+ ? { allowed: false, sendAfter: null, reasons: [] }
+ : {
+ ...source.gate,
+ sendAfter:
+ source.gate.sendAfter === null
+ ? null
+ : new Date(source.gate.sendAfter).toISOString(),
+ reasons: source.gate.reasons.map((reason) => ({
+ ...reason,
+ ...("until" in reason
+ ? { until: new Date(reason.until).toISOString() }
+ : {}),
+ })),
+ },
providerAuthorizationRequired:
blockedBy === "GMAIL_SEND_CONSENT_REQUIRED",
+ history: {
+ messages: source.history.messages,
+ coverage: source.history.coverage,
+ },
+ checks: {
+ exclusions: !source.person.doNotContact && !source.identityOptedOut,
+ crossChannel:
+ source.history.blockedBy === null &&
+ source.gate.allowed &&
+ blockedBy !== "DELIVERY_IN_PROGRESS",
+ history: source.history.blockedBy === null,
+ },
};
}
private async credentials(connection: typeof s.connections.$inferSelect) {
@@ -704,7 +770,7 @@ export class OutboundService {
.where(
and(
eq(s.deliveries.organizationId, input.organizationId),
- eq(s.relationships.personId, current.person.id),
+ inArray(s.relationships.personId, current.history.identities),
inArray(s.deliveries.status, ["sending", "unknown", "accepted"]),
),
);
diff --git a/packages/connectors/receipts.ts b/packages/connectors/receipts.ts
index 1c1a3585..59ae625c 100644
--- a/packages/connectors/receipts.ts
+++ b/packages/connectors/receipts.ts
@@ -1,6 +1,7 @@
import { and, eq, isNull, lt, lte, or, sql } from "drizzle-orm";
import { z } from "zod";
import { publishChange } from "../core/changes";
+import { lockContactDirectory } from "../core/contact-history";
import { authorize, DomainError } from "../core/policy";
import type { Database } from "../database/client";
import * as s from "../database/schema";
@@ -29,16 +30,81 @@ export async function saveReceipt(
!connection.encryptedCredentials
)
throw new DomainError("CONNECTION_UNAVAILABLE", 422);
- await db
- .insert(s.integrationReceipts)
- .values({
- organizationId: connection.organizationId,
- connectionId: connection.id,
- externalId: z.string().min(1).max(1000).parse(externalId),
- provider,
- payload,
- })
- .onConflictDoNothing();
+ await db.transaction(async (tx) => {
+ await lockContactDirectory(tx, connection.organizationId);
+ const [active] = await tx
+ .select()
+ .from(s.connections)
+ .where(
+ and(
+ eq(s.connections.id, connection.id),
+ eq(s.connections.organizationId, connection.organizationId),
+ eq(s.connections.ownerId, connection.ownerId),
+ ),
+ )
+ .for("update");
+ if (
+ !active?.productId ||
+ active.status !== "connected" ||
+ !active.encryptedCredentials
+ )
+ throw new DomainError("CONNECTION_UNAVAILABLE", 422);
+ await authorize(
+ tx,
+ { userId: active.ownerId, source: "session" },
+ active.organizationId,
+ active.productId,
+ true,
+ );
+ const [created] = await tx
+ .insert(s.integrationReceipts)
+ .values({
+ organizationId: active.organizationId,
+ connectionId: active.id,
+ externalId: z.string().min(1).max(1000).parse(externalId),
+ provider,
+ payload,
+ })
+ .onConflictDoNothing()
+ .returning();
+ const [receipt] = created
+ ? [created]
+ : await tx
+ .select()
+ .from(s.integrationReceipts)
+ .where(
+ and(
+ eq(s.integrationReceipts.connectionId, active.id),
+ eq(s.integrationReceipts.externalId, externalId),
+ ),
+ );
+ if (!receipt || receipt.processedAt || receipt.provider !== "unipile")
+ return;
+ try {
+ // LinkedIn message normalization needs no provider request. Make its
+ // history/inbox and approval invalidation durable before acknowledging
+ // the webhook, instead of leaving an unprotected cron-processing gap.
+ const record = normalizeLinkedIn(receipt.payload);
+ if (record) await new IntegrationService(tx).importRecord(active, record);
+ await tx
+ .update(s.integrationReceipts)
+ .set({ processedAt: new Date(), leaseUntil: null, errorCode: null })
+ .where(eq(s.integrationReceipts.id, receipt.id));
+ } catch (error) {
+ // Retain the original signed receipt for retry and keep matching raw
+ // history fail-closed when local normalization/materialization fails.
+ await tx
+ .update(s.integrationReceipts)
+ .set({
+ errorCode:
+ error instanceof DomainError
+ ? error.code
+ : "PROVIDER_RESPONSE_INVALID",
+ })
+ .where(eq(s.integrationReceipts.id, receipt.id));
+ }
+ });
+ publishChange(connection.organizationId);
}
export async function processReceipts(
db: Database,
@@ -77,6 +143,14 @@ export async function processReceipts(
return claimed;
});
if (!receipt) break;
+ const ownsClaim = and(
+ eq(s.integrationReceipts.id, receipt.id),
+ isNull(s.integrationReceipts.processedAt),
+ eq(s.integrationReceipts.attempts, receipt.attempts),
+ receipt.leaseUntil
+ ? eq(s.integrationReceipts.leaseUntil, receipt.leaseUntil)
+ : isNull(s.integrationReceipts.leaseUntil),
+ );
try {
const [connection] = await db
.select()
@@ -87,6 +161,7 @@ export async function processReceipts(
eq(s.connections.organizationId, receipt.organizationId),
),
);
+ let record: ImportRecord | null = null;
if (
connection?.status === "connected" &&
connection.productId &&
@@ -99,7 +174,6 @@ export async function processReceipts(
connection.productId,
true,
);
- let record: ImportRecord | null;
if (receipt.provider === "unipile")
record = normalizeLinkedIn(receipt.payload);
else {
@@ -120,21 +194,52 @@ export async function processReceipts(
throw new DomainError("FORBIDDEN", 403);
record = normalizeFireflies(result.transcript);
}
- if (record)
- await new IntegrationService(db, transport).importRecord(
- connection,
+ }
+ const completed = await db.transaction(async (tx) => {
+ // Stabilize organization authority before connection/receipt locks.
+ await lockContactDirectory(tx, receipt.organizationId);
+ // An expired worker must
+ // not import after an explicit discard or another worker's newer claim.
+ const [active] = await tx
+ .select()
+ .from(s.connections)
+ .where(
+ and(
+ eq(s.connections.id, receipt.connectionId),
+ eq(s.connections.organizationId, receipt.organizationId),
+ ),
+ )
+ .for("update");
+ const [claimed] = await tx
+ .select({ id: s.integrationReceipts.id })
+ .from(s.integrationReceipts)
+ .where(ownsClaim)
+ .for("update");
+ if (!claimed) return false;
+ if (
+ record &&
+ active?.status === "connected" &&
+ active.productId &&
+ active.encryptedCredentials &&
+ active.externalAccountId === connection?.externalAccountId
+ )
+ await new IntegrationService(tx, transport).importRecord(
+ active,
record,
);
- publishChange(connection.organizationId);
+ // Disconnects intentionally discard pending deliveries instead of reactivating access.
+ await tx
+ .update(s.integrationReceipts)
+ .set({ processedAt: new Date(), leaseUntil: null, errorCode: null })
+ .where(ownsClaim);
+ return true;
+ });
+ if (completed) {
+ publishChange(receipt.organizationId);
+ processed++;
}
- // Disconnects intentionally discard pending deliveries instead of reactivating access.
- await db
- .update(s.integrationReceipts)
- .set({ processedAt: new Date(), leaseUntil: null, errorCode: null })
- .where(eq(s.integrationReceipts.id, receipt.id));
- processed++;
} catch (error) {
- await db
+ const [updated] = await db
.update(s.integrationReceipts)
.set({
leaseUntil: null,
@@ -146,8 +251,9 @@ export async function processReceipts(
? error.code
: "PROVIDER_RESPONSE_INVALID",
})
- .where(eq(s.integrationReceipts.id, receipt.id));
- failed++;
+ .where(ownsClaim)
+ .returning({ id: s.integrationReceipts.id });
+ if (updated) failed++;
}
}
return { processed, failed };
diff --git a/packages/connectors/replies.ts b/packages/connectors/replies.ts
index 1952a333..03553e69 100644
--- a/packages/connectors/replies.ts
+++ b/packages/connectors/replies.ts
@@ -2,8 +2,13 @@ import { createHmac, timingSafeEqual } from "node:crypto";
import { and, desc, eq, inArray, isNotNull, or } from "drizzle-orm";
import { z } from "zod";
import { recordProviderContribution } from "../core/contact-attribution";
+import {
+ contactIdentityIds,
+ lockContactDirectory,
+} from "../core/contact-history";
import { pauseForReply, peopleByEmail } from "../core/outreach";
import { DomainError } from "../core/policy";
+import { clearApprovals } from "../core/visibility";
import type { Database } from "../database/client";
import * as s from "../database/schema";
import t from "../i18n/translations/en.json";
@@ -119,24 +124,34 @@ export function normalizeUnipileV2(
return null;
}
export async function ingestReply(db: Database, input: ReplyEvent) {
- const event = replySchema.parse(input);
+ let event = replySchema.parse(input);
+ const matchesAccount = and(
+ eq(s.connections.provider, event.provider),
+ eq(s.connections.externalAccountId, event.accountId),
+ event.connectionId ? eq(s.connections.id, event.connectionId) : undefined,
+ );
+ const found = await db
+ .select({ organizationId: s.connections.organizationId })
+ .from(s.connections)
+ .where(matchesAccount)
+ .limit(2);
+ if (found.length !== 1) throw new DomainError("CONNECTION_UNAVAILABLE", 422);
return db.transaction(async (tx) => {
+ // Discover the account before locking, then stabilize its organization
+ // before taking connection/contact locks, as membership changes do.
+ await lockContactDirectory(tx, found[0].organizationId);
const candidates = await tx
.select()
.from(s.connections)
- .where(
- and(
- eq(s.connections.provider, event.provider),
- eq(s.connections.externalAccountId, event.accountId),
- event.connectionId
- ? eq(s.connections.id, event.connectionId)
- : undefined,
- ),
- )
+ .where(matchesAccount)
.limit(2)
.for("update");
const connection = candidates.length === 1 ? candidates[0] : undefined;
- if (!connection || !["connected", "demo"].includes(connection.status))
+ if (
+ !connection ||
+ connection.organizationId !== found[0].organizationId ||
+ !["connected", "demo"].includes(connection.status)
+ )
throw new DomainError("CONNECTION_UNAVAILABLE", 422);
const [receipt] = await tx
.insert(s.connectorEvents)
@@ -148,9 +163,10 @@ export async function ingestReply(db: Database, input: ReplyEvent) {
})
.onConflictDoNothing()
.returning();
+ let receiptId = receipt?.id;
if (!receipt) {
const [previous] = await tx
- .select({ status: s.connectorEvents.status })
+ .select()
.from(s.connectorEvents)
.where(
and(
@@ -158,7 +174,12 @@ export async function ingestReply(db: Database, input: ReplyEvent) {
eq(s.connectorEvents.providerEventId, event.messageId),
),
);
- return { duplicate: true, matched: previous?.status === "processed" };
+ if (!previous || previous.status === "processed")
+ return { duplicate: true, matched: previous?.status === "processed" };
+ // A retained unmatched event becomes processable after its owner links
+ // the thread. Always materialize the original authenticated payload.
+ event = replySchema.parse(previous.payload);
+ receiptId = previous.id;
}
const [conversation] = await tx
.select()
@@ -174,7 +195,52 @@ export async function ingestReply(db: Database, input: ReplyEvent) {
event.direction === "inbound" && event.from
? await peopleByEmail(tx, connection.organizationId, event.from)
: [];
+ const [relationship] = conversation
+ ? await tx
+ .select()
+ .from(s.relationships)
+ .where(
+ and(
+ eq(s.relationships.id, conversation.relationshipId),
+ eq(s.relationships.organizationId, connection.organizationId),
+ ),
+ )
+ : [];
+ const [person] = relationship
+ ? await tx
+ .select()
+ .from(s.people)
+ .where(eq(s.people.id, relationship.personId))
+ : [];
+ const identities = [
+ ...new Set([
+ ...senders,
+ ...(person
+ ? await contactIdentityIds(tx, connection.organizationId, person)
+ : []),
+ ]),
+ ].sort();
+ if (identities.length)
+ await tx
+ .select({ id: s.people.id })
+ .from(s.people)
+ .where(
+ and(
+ eq(s.people.organizationId, connection.organizationId),
+ inArray(s.people.id, identities),
+ ),
+ )
+ .orderBy(s.people.id)
+ .for("update");
if (!conversation || conversation.channel !== event.channel) {
+ if (!receipt) return { duplicate: true, matched: false };
+ for (const personId of identities)
+ await clearApprovals(
+ tx,
+ { userId: connection.ownerId, source: "session" },
+ connection.organizationId,
+ personId,
+ );
if (!event.historical)
await pauseForReply(tx, {
organizationId: connection.organizationId,
@@ -183,10 +249,31 @@ export async function ingestReply(db: Database, input: ReplyEvent) {
actorId: connection.ownerId,
pause: true,
});
+ if (connection.productId)
+ await tx
+ .insert(s.integrationItems)
+ .values({
+ organizationId: connection.organizationId,
+ productId: connection.productId,
+ connectionId: connection.id,
+ externalId: event.messageId,
+ record: {
+ externalId: event.messageId,
+ threadId: event.threadId,
+ kind: "message",
+ title: t.newReplyAction,
+ body: event.body,
+ occurredAt: event.occurredAt,
+ participants: event.from ? [event.from] : [],
+ direction: event.direction,
+ ...(event.from ? { from: event.from } : {}),
+ },
+ })
+ .onConflictDoNothing();
await tx
.update(s.connectorEvents)
.set({ status: "unmatched" })
- .where(eq(s.connectorEvents.id, receipt.id));
+ .where(eq(s.connectorEvents.id, receiptId ?? ""));
return { duplicate: false, matched: false };
}
const [message] = await tx
@@ -220,6 +307,18 @@ export async function ingestReply(db: Database, input: ReplyEvent) {
sourceRecordId: `message:${event.messageId}`,
sourceConversationId: conversation.id,
});
+ if (event.direction === "outbound")
+ await tx
+ .update(s.relationships)
+ .set({
+ lastOutboundAt: sql`greatest(coalesce(${s.relationships.lastOutboundAt}, ${event.occurredAt}::timestamptz), ${event.occurredAt}::timestamptz)`,
+ })
+ .where(
+ and(
+ eq(s.relationships.organizationId, connection.organizationId),
+ inArray(s.relationships.personId, identities),
+ ),
+ );
}
const [latest] = await tx
.select()
@@ -228,6 +327,7 @@ export async function ingestReply(db: Database, input: ReplyEvent) {
.orderBy(desc(s.messages.occurredAt), desc(s.messages.createdAt))
.limit(1);
if (
+ !event.historical &&
message &&
latest?.id === message.id &&
event.direction === "outbound"
@@ -346,10 +446,20 @@ export async function ingestReply(db: Database, input: ReplyEvent) {
dueAt: new Date(),
});
}
+ // Preserve the live-reply transition's approval predicate before clearing
+ // remaining approvals across other products and legacy identity aliases.
+ if (message)
+ for (const personId of identities)
+ await clearApprovals(
+ tx,
+ { userId: connection.ownerId, source: "session" },
+ connection.organizationId,
+ personId,
+ );
await tx
.update(s.connectorEvents)
.set({ status: "processed" })
- .where(eq(s.connectorEvents.id, receipt.id));
+ .where(eq(s.connectorEvents.id, receiptId ?? ""));
if (message)
await tx.insert(s.changeEvents).values({
organizationId: connection.organizationId,
diff --git a/packages/connectors/service.ts b/packages/connectors/service.ts
index 0e2100c5..d5f79d8b 100644
--- a/packages/connectors/service.ts
+++ b/packages/connectors/service.ts
@@ -6,6 +6,7 @@ import {
desc,
eq,
inArray,
+ isNotNull,
isNull,
lt,
or,
@@ -15,10 +16,16 @@ import { z } from "zod";
import { appUrl } from "../auth/options";
import { publishChange } from "../core/changes";
import { recordProviderContribution } from "../core/contact-attribution";
+import {
+ contactIdentityIds,
+ contactIdsForParticipants,
+ lockContactDirectory,
+} from "../core/contact-history";
+import { cursorInstantSchema } from "../core/datetime";
import { pauseForReply, peopleByEmail } from "../core/outreach";
import { authorize, DomainError, type Principal } from "../core/policy";
import { assertProductActive } from "../core/products";
-import { assertActiveRelationships } from "../core/visibility";
+import { assertActiveRelationships, clearApprovals } from "../core/visibility";
import type { Database } from "../database/client";
import * as s from "../database/schema";
import {
@@ -56,9 +63,23 @@ export const integrationOverviewInput = integrationScope.extend({
reviewQuery: z.string().trim().max(120).optional(),
reviewProvider: integrationProvider.optional(),
reviewCursor: z.string().min(1).max(1000).optional(),
+ failedReceiptCursor: z.string().min(1).max(1000).optional(),
+});
+const reviewPosition = z.object({
+ id: z.uuid(),
+ createdAt: cursorInstantSchema,
});
-const reviewPosition = z.object({ id: z.uuid(), createdAt: z.iso.datetime() });
const reviewPageSize = 20;
+function cursorPosition(cursor?: string) {
+ if (!cursor) return undefined;
+ try {
+ return reviewPosition.parse(
+ JSON.parse(Buffer.from(cursor, "base64url").toString()),
+ );
+ } catch {
+ throw new DomainError("INVALID_INPUT", 400);
+ }
+}
export const connectInput = integrationScope.extend({
productId: z.uuid(),
provider: integrationProvider,
@@ -162,6 +183,20 @@ export interface ConnectionOverview {
}[];
reviewTotal: number;
nextReviewCursor: string | null;
+ failedReceipts: {
+ id: string;
+ connectionId: string;
+ productId: string;
+ externalId: string;
+ errorCode: string;
+ attempts: number;
+ createdAt: string;
+ conversationId: string | null;
+ threadId: string | null;
+ canDiscard: boolean;
+ }[];
+ failedReceiptTotal: number;
+ nextFailedReceiptCursor: string | null;
}
export class IntegrationService {
constructor(
@@ -174,16 +209,8 @@ export class IntegrationService {
): Promise {t.failedReceipts.hint} {t.failedReceipts.empty}
+ {t.errors[receipt.errorCode as keyof typeof t.errors] ??
+ t.errors.PROVIDER_RESPONSE_INVALID}
+ {t.failedReceipts.processing} {t.failedReceipts.confirmation}{t.failedReceipts.heading}
+ {overview.failedReceiptTotal ?? 0}
+
{message.body.slice(0, 1000)}
+{t.nativeIngestion.noVisibleHistory}
+ )} +{t.nativeIngestion.historyCoverage}
+ {recipient && ( + + {t.openPersonRecord.replace("{name}", recipient.name)} + + )} +{t.nativeIngestion.exclusionChecked}
+ )} > ); return ( diff --git a/src/components/records/action-reason.tsx b/src/components/records/action-reason.tsx new file mode 100644 index 00000000..f354aec3 --- /dev/null +++ b/src/components/records/action-reason.tsx @@ -0,0 +1,101 @@ +"use client"; +import type { ClientSnapshot } from "@crm/core/dto"; +import t from "@crm/i18n/translations/en.json"; +import { useState } from "react"; +import { useCrm } from "../crm/crm-context"; +import { submitOnSaveKey } from "../modal-lifecycle"; +import { ImportedContext } from "./imported-context"; +import { RecordText } from "./record-text"; + +export function ActionReason({ + action, +}: { + action: ClientSnapshot["actions"][number]; +}) { + const { busy, send, organizationId } = useCrm(); + const [editing, setEditing] = useState(false); + const [reason, setReason] = useState(action.reason); + const [original, setOriginal] = useState({ + reason: action.reason, + version: action.version, + }); + const [error, setError] = useState(""); + return ( +{error}
}{t.partialHistory}
); diff --git a/src/components/records/internal-tasks.tsx b/src/components/records/internal-tasks.tsx new file mode 100644 index 00000000..5f260e58 --- /dev/null +++ b/src/components/records/internal-tasks.tsx @@ -0,0 +1,340 @@ +"use client"; +import { + instantFromZonedInput, + preciseDateLabel, + zonedInputValue, +} from "@crm/core/calendar"; +import type { ClientSnapshot } from "@crm/core/dto"; +import { createInternalTaskSchema } from "@crm/core/internal-tasks"; +import t from "@crm/i18n/translations/en.json"; +import { useState } from "react"; +import { useWorkspaceData } from "../crm/crm-context"; +import { RecordDialog, text } from "./record-dialog"; +import { RecordText } from "./record-text"; + +type InternalTask = ClientSnapshot["internalTasks"][number]; +const recurrenceUnits = { + daily: ["day", "days"], + weekly: ["week", "weeks"], + monthly: ["month", "months"], +} as const; +function InternalTaskEditor({ + task, + onClose, +}: { + task: InternalTask | null; + onClose: () => void; +}) { + const crm = useWorkspaceData(); + const [productId, setProductId] = useState( + task?.productId || crm.productId || crm.data.products[0]?.id || "", + ); + const [timeZone, setTimeZone] = useState(task?.timeZone || crm.timeZone); + const [frequency, setFrequency] = useState(task?.recurrence?.frequency ?? ""); + return ( +{t.internalTasks.note}
+{t.internalTasks.empty}
} + {tasks.map((task) => ( ++ {crm.product(task.productId)?.name} · {crm.member(task.ownerId)} ·{" "} + +
+ {task.description &&+ {t.internalTasks.recurs + .replace("{interval}", String(task.recurrence.interval)) + .replace( + "{frequency}", + t.internalTasks[ + recurrenceUnits[task.recurrence.frequency][ + task.recurrence.interval === 1 ? 0 : 1 + ] + ], + )} +
+ )} +{t.nativeIngestion.privateHint}
+{error}
} + {!drafts.length && !error && ( +{t.nativeIngestion.noDrafts}
+ )} + {drafts.map((draft) => ( +{draft.body}
+ {draft.reason &&{draft.reason}
} ++ {draft.scheduledActionId + ? t.nativeIngestion.scheduled + : t.nativeIngestion.undated} +
+ {!draft.scheduledActionId && ( +{t.nativeIngestion.sourceHint}
+ + + > + ) : ( + <> + {!editor.draft && ( + <> + ++ {t.nativeIngestion.sourceHint} +
+ > + )} + + + > + )} + + > + )} + {editor.kind === "schedule" && ( + + )} + {editor.kind !== "draft" && ( + <> + ++ {t.nativeIngestion.zone.replace("{zone}", inputTimeZone)} +
+ > + )} +
{
@@ -574,6 +616,98 @@ export function OpportunitiesView() {
{layout === "list" && browser.rows.length > 0 && (
{t.yodu.setupNote} {t.yodu.verificationNote} {t.integrationDemo} {t.loading}
+ {error}
+ {t.integrationConfigRequired} {t.yodu.adminNote} {t.yodu.secretNote} {t.yodu.noSources} {t.yodu.rebindNote} {t.yodu.noEvents}
+ {t.archivedDeals}
+ {records.length}
+
+
+ {page.items.map((record) => {
+ const stages = crm.data.stages.filter(
+ (stage) =>
+ stage.productId === record.productId &&
+ stage.pipeline === "deal" &&
+ !stage.archivedAt &&
+ (record.status === "open"
+ ? stage.category === "open" || stage.category === "hold"
+ : stage.category === record.status),
+ );
+ const originalAvailable = stages.some(
+ (stage) => stage.id === record.stageId,
+ );
+ const stageId = originalAvailable
+ ? undefined
+ : replacementStages[record.id];
+ return (
+
+ {t.yodu.setupTitle}
+ {t.yodu.mapping}
+ {t.yodu.events}
+
+