- @settlekit/sdk: typed fetch HTTP client over the REST API; one resource client per /v1 resource (products, checkout, payments, entitlements, licenseKeys, apiKeys, bundles, github, discord, saas, escrow, agentServices…), AbortController timeouts, idempotency keys, SettleKitApiError envelope mapping. - @settlekit/react: SettleKitProvider, useEntitlement/useCheckout/useCredits hooks, <Paywall> + <UpgradeButton> (React 18, plan §4). - database: drizzle.config.ts + generated drizzle/0000_init.sql (48 tables, indexes, FKs) + db:generate/migrate/push/studio scripts. - infra: README, ARCHITECTURE, CONTRIBUTING, .env.example, .dockerignore, docker-compose.yml, per-app Dockerfiles + Dockerfile.next, Makefile. No tests. No CI/CD pipelines.
790 lines
48 KiB
SQL
790 lines
48 KiB
SQL
CREATE TABLE "customers" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"merchant_id" text NOT NULL,
|
|
"email" text NOT NULL,
|
|
"name" text,
|
|
"wallet_address" text,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "merchants" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"organization_id" text NOT NULL,
|
|
"display_name" text NOT NULL,
|
|
"support_email" text,
|
|
"default_currency" text DEFAULT 'USDC' NOT NULL,
|
|
"payout_wallet_id" text,
|
|
"status" text DEFAULT 'active' NOT NULL,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "organizations" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"name" text NOT NULL,
|
|
"slug" text NOT NULL,
|
|
"status" text DEFAULT 'active' NOT NULL,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
CONSTRAINT "organizations_slug_unique" UNIQUE("slug")
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "payout_wallets" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"merchant_id" text NOT NULL,
|
|
"network" text NOT NULL,
|
|
"address" text NOT NULL,
|
|
"label" text,
|
|
"is_default" boolean DEFAULT false NOT NULL,
|
|
"verified_at" timestamp with time zone,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "users" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"organization_id" text NOT NULL,
|
|
"email" text NOT NULL,
|
|
"name" text,
|
|
"role" text DEFAULT 'member' NOT NULL,
|
|
"email_verified_at" timestamp with time zone,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "bundle_items" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"bundle_id" text NOT NULL,
|
|
"product_id" text NOT NULL,
|
|
"price_id" text,
|
|
"quantity" integer DEFAULT 1 NOT NULL,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "bundles" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"merchant_id" text NOT NULL,
|
|
"name" text NOT NULL,
|
|
"description" text,
|
|
"currency" text DEFAULT 'USDC' NOT NULL,
|
|
"total_amount" text NOT NULL,
|
|
"status" text DEFAULT 'draft' NOT NULL,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "file_assets" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"merchant_id" text NOT NULL,
|
|
"product_id" text,
|
|
"filename" text NOT NULL,
|
|
"content_type" text NOT NULL,
|
|
"size_bytes" integer DEFAULT 0 NOT NULL,
|
|
"storage_key" text NOT NULL,
|
|
"checksum" text,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "prices" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"product_id" text NOT NULL,
|
|
"currency" text DEFAULT 'USDC' NOT NULL,
|
|
"unit_amount" text NOT NULL,
|
|
"interval" text,
|
|
"interval_count" integer,
|
|
"usage_meter_id" text,
|
|
"active" boolean DEFAULT true NOT NULL,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "products" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"merchant_id" text NOT NULL,
|
|
"name" text NOT NULL,
|
|
"description" text,
|
|
"type" text NOT NULL,
|
|
"status" text DEFAULT 'draft' NOT NULL,
|
|
"delivery_mode" text DEFAULT 'none' NOT NULL,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "checkout_sessions" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"merchant_id" text NOT NULL,
|
|
"customer_id" text,
|
|
"status" text DEFAULT 'open' NOT NULL,
|
|
"currency" text DEFAULT 'USDC' NOT NULL,
|
|
"amount_total" text NOT NULL,
|
|
"line_items" jsonb DEFAULT '[]'::jsonb NOT NULL,
|
|
"success_url" text,
|
|
"cancel_url" text,
|
|
"expires_at" timestamp with time zone,
|
|
"completed_at" timestamp with time zone,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "credit_balances" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"merchant_id" text NOT NULL,
|
|
"customer_id" text NOT NULL,
|
|
"currency" text DEFAULT 'USDC' NOT NULL,
|
|
"balance" text NOT NULL,
|
|
"reserved" text NOT NULL,
|
|
"version" integer DEFAULT 0 NOT NULL,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "payments" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"merchant_id" text NOT NULL,
|
|
"customer_id" text,
|
|
"checkout_session_id" text,
|
|
"status" text DEFAULT 'pending' NOT NULL,
|
|
"network" text NOT NULL,
|
|
"currency" text DEFAULT 'USDC' NOT NULL,
|
|
"amount" text NOT NULL,
|
|
"tx_hash" text,
|
|
"from_address" text,
|
|
"to_address" text,
|
|
"confirmed_at" timestamp with time zone,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "subscriptions" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"merchant_id" text NOT NULL,
|
|
"customer_id" text NOT NULL,
|
|
"price_id" text NOT NULL,
|
|
"status" text DEFAULT 'active' NOT NULL,
|
|
"current_period_start" timestamp with time zone NOT NULL,
|
|
"current_period_end" timestamp with time zone NOT NULL,
|
|
"cancel_at_period_end" boolean DEFAULT false NOT NULL,
|
|
"canceled_at" timestamp with time zone,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "usage_meters" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"merchant_id" text NOT NULL,
|
|
"name" text NOT NULL,
|
|
"event_name" text NOT NULL,
|
|
"aggregation" text DEFAULT 'sum' NOT NULL,
|
|
"unit_label" text,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "api_keys" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"merchant_id" text NOT NULL,
|
|
"name" text NOT NULL,
|
|
"prefix" text NOT NULL,
|
|
"hashed_key" text NOT NULL,
|
|
"scopes" jsonb DEFAULT '[]'::jsonb NOT NULL,
|
|
"status" text DEFAULT 'active' NOT NULL,
|
|
"last_used_at" timestamp with time zone,
|
|
"expires_at" timestamp with time zone,
|
|
"revoked_at" timestamp with time zone,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
CONSTRAINT "api_keys_hashed_key_unique" UNIQUE("hashed_key")
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "entitlements" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"merchant_id" text NOT NULL,
|
|
"customer_id" text NOT NULL,
|
|
"product_id" text,
|
|
"type" text NOT NULL,
|
|
"status" text DEFAULT 'active' NOT NULL,
|
|
"feature_key" text,
|
|
"quantity" integer,
|
|
"expires_at" timestamp with time zone,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "license_keys" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"merchant_id" text NOT NULL,
|
|
"entitlement_id" text,
|
|
"key" text NOT NULL,
|
|
"status" text DEFAULT 'active' NOT NULL,
|
|
"max_activations" integer,
|
|
"activation_count" integer DEFAULT 0 NOT NULL,
|
|
"activations" jsonb DEFAULT '[]'::jsonb NOT NULL,
|
|
"expires_at" timestamp with time zone,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
CONSTRAINT "license_keys_key_unique" UNIQUE("key")
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "delivery_actions" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"delivery_plan_id" text NOT NULL,
|
|
"type" text NOT NULL,
|
|
"position" integer DEFAULT 0 NOT NULL,
|
|
"config" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "delivery_logs" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"delivery_run_id" text NOT NULL,
|
|
"action_id" text,
|
|
"level" text DEFAULT 'info' NOT NULL,
|
|
"message" text NOT NULL,
|
|
"data" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "delivery_plans" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"merchant_id" text NOT NULL,
|
|
"product_id" text,
|
|
"name" text NOT NULL,
|
|
"status" text DEFAULT 'active' NOT NULL,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "delivery_runs" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"delivery_plan_id" text NOT NULL,
|
|
"merchant_id" text NOT NULL,
|
|
"entitlement_id" text,
|
|
"payment_id" text,
|
|
"status" text DEFAULT 'pending' NOT NULL,
|
|
"attempt" integer DEFAULT 0 NOT NULL,
|
|
"action_runs" jsonb DEFAULT '[]'::jsonb NOT NULL,
|
|
"started_at" timestamp with time zone,
|
|
"completed_at" timestamp with time zone,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "webhook_endpoints" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"merchant_id" text NOT NULL,
|
|
"url" text NOT NULL,
|
|
"secret" text NOT NULL,
|
|
"enabled_events" jsonb DEFAULT '[]'::jsonb NOT NULL,
|
|
"status" text DEFAULT 'active' NOT NULL,
|
|
"disabled_at" timestamp with time zone,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "webhook_events" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"merchant_id" text NOT NULL,
|
|
"endpoint_id" text,
|
|
"type" text NOT NULL,
|
|
"payload" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"delivered" boolean DEFAULT false NOT NULL,
|
|
"attempts" integer DEFAULT 0 NOT NULL,
|
|
"last_error" text,
|
|
"next_attempt_at" timestamp with time zone,
|
|
"delivered_at" timestamp with time zone,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "github_access_sync_runs" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"installation_id" text NOT NULL,
|
|
"status" text DEFAULT 'pending' NOT NULL,
|
|
"granted" integer DEFAULT 0 NOT NULL,
|
|
"revoked" integer DEFAULT 0 NOT NULL,
|
|
"failed" integer DEFAULT 0 NOT NULL,
|
|
"result" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"started_at" timestamp with time zone,
|
|
"completed_at" timestamp with time zone,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "github_installations" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"merchant_id" text NOT NULL,
|
|
"installation_id" integer NOT NULL,
|
|
"account_login" text NOT NULL,
|
|
"account_type" text DEFAULT 'Organization' NOT NULL,
|
|
"status" text DEFAULT 'active' NOT NULL,
|
|
"suspended_at" timestamp with time zone,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "github_repo_access_grants" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"installation_id" text NOT NULL,
|
|
"customer_id" text NOT NULL,
|
|
"entitlement_id" text,
|
|
"repository_id" text,
|
|
"team_id" text,
|
|
"github_username" text,
|
|
"permission" text DEFAULT 'pull' NOT NULL,
|
|
"status" text DEFAULT 'pending' NOT NULL,
|
|
"granted_at" timestamp with time zone,
|
|
"revoked_at" timestamp with time zone,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "github_repositories" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"installation_id" text NOT NULL,
|
|
"repo_id" integer NOT NULL,
|
|
"full_name" text NOT NULL,
|
|
"private" text DEFAULT 'true' NOT NULL,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "github_teams" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"installation_id" text NOT NULL,
|
|
"team_id" integer NOT NULL,
|
|
"slug" text NOT NULL,
|
|
"name" text NOT NULL,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "discord_connections" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"merchant_id" text NOT NULL,
|
|
"bot_token" text NOT NULL,
|
|
"application_id" text NOT NULL,
|
|
"status" text DEFAULT 'active' NOT NULL,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "discord_guilds" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"connection_id" text NOT NULL,
|
|
"guild_id" text NOT NULL,
|
|
"name" text NOT NULL,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "discord_role_grants" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"role_id" text NOT NULL,
|
|
"customer_id" text NOT NULL,
|
|
"entitlement_id" text,
|
|
"discord_user_id" text,
|
|
"status" text DEFAULT 'pending' NOT NULL,
|
|
"granted_at" timestamp with time zone,
|
|
"revoked_at" timestamp with time zone,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "discord_roles" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"guild_id" text NOT NULL,
|
|
"role_id" text NOT NULL,
|
|
"name" text NOT NULL,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "saas_entitlement_rules" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"plan_id" text NOT NULL,
|
|
"feature_key" text NOT NULL,
|
|
"entitlement_type" text NOT NULL,
|
|
"quantity" integer,
|
|
"config" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "saas_features" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"plan_id" text NOT NULL,
|
|
"key" text NOT NULL,
|
|
"name" text NOT NULL,
|
|
"type" text DEFAULT 'boolean' NOT NULL,
|
|
"value" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"limit" integer,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "saas_plans" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"merchant_id" text NOT NULL,
|
|
"name" text NOT NULL,
|
|
"code" text NOT NULL,
|
|
"price_id" text,
|
|
"status" text DEFAULT 'active' NOT NULL,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "saas_seats" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"subscription_id" text NOT NULL,
|
|
"customer_id" text,
|
|
"email" text,
|
|
"status" text DEFAULT 'active' NOT NULL,
|
|
"assigned" boolean DEFAULT false NOT NULL,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "agent_buyers" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"merchant_id" text NOT NULL,
|
|
"wallet_address" text NOT NULL,
|
|
"label" text,
|
|
"status" text DEFAULT 'active' NOT NULL,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "agent_service_metadata" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"agent_service_id" text NOT NULL,
|
|
"schema" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"capabilities" jsonb DEFAULT '[]'::jsonb NOT NULL,
|
|
"rate_limit" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "agent_services" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"merchant_id" text NOT NULL,
|
|
"name" text NOT NULL,
|
|
"slug" text NOT NULL,
|
|
"description" text,
|
|
"endpoint_url" text NOT NULL,
|
|
"currency" text DEFAULT 'USDC' NOT NULL,
|
|
"price_per_call" text NOT NULL,
|
|
"status" text DEFAULT 'active' NOT NULL,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "agent_usage_events" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"agent_service_id" text NOT NULL,
|
|
"agent_buyer_id" text NOT NULL,
|
|
"payment_id" text,
|
|
"currency" text DEFAULT 'USDC' NOT NULL,
|
|
"amount" text NOT NULL,
|
|
"occurred_at" timestamp with time zone NOT NULL,
|
|
"request" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "escrow_disputes" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"escrow_task_id" text NOT NULL,
|
|
"raised_by" text,
|
|
"status" text DEFAULT 'open' NOT NULL,
|
|
"reason" text NOT NULL,
|
|
"resolution" text,
|
|
"evidence" jsonb DEFAULT '[]'::jsonb NOT NULL,
|
|
"resolved_at" timestamp with time zone,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "escrow_fundings" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"escrow_task_id" text NOT NULL,
|
|
"payment_id" text,
|
|
"currency" text DEFAULT 'USDC' NOT NULL,
|
|
"amount" text NOT NULL,
|
|
"tx_hash" text,
|
|
"funded_at" timestamp with time zone NOT NULL,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "escrow_releases" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"escrow_task_id" text NOT NULL,
|
|
"submission_id" text,
|
|
"currency" text DEFAULT 'USDC' NOT NULL,
|
|
"amount" text NOT NULL,
|
|
"tx_hash" text,
|
|
"released_at" timestamp with time zone NOT NULL,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "escrow_submissions" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"escrow_task_id" text NOT NULL,
|
|
"submitted_by" text,
|
|
"status" text DEFAULT 'submitted' NOT NULL,
|
|
"artifacts" jsonb DEFAULT '[]'::jsonb NOT NULL,
|
|
"notes" text,
|
|
"submitted_at" timestamp with time zone NOT NULL,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "escrow_tasks" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"merchant_id" text NOT NULL,
|
|
"buyer_customer_id" text NOT NULL,
|
|
"seller_customer_id" text,
|
|
"title" text NOT NULL,
|
|
"description" text,
|
|
"status" text DEFAULT 'created' NOT NULL,
|
|
"currency" text DEFAULT 'USDC' NOT NULL,
|
|
"amount" text NOT NULL,
|
|
"acceptance_criteria" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"deadline_at" timestamp with time zone,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "marketplace_listings" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"merchant_id" text NOT NULL,
|
|
"product_id" text NOT NULL,
|
|
"slug" text NOT NULL,
|
|
"title" text NOT NULL,
|
|
"summary" text,
|
|
"category" text,
|
|
"tags" jsonb DEFAULT '[]'::jsonb NOT NULL,
|
|
"currency" text DEFAULT 'USDC' NOT NULL,
|
|
"display_price" text,
|
|
"status" text DEFAULT 'draft' NOT NULL,
|
|
"published_at" timestamp with time zone,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
CONSTRAINT "marketplace_listings_slug_unique" UNIQUE("slug")
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "risk_profiles" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"merchant_id" text,
|
|
"customer_id" text,
|
|
"subject_type" text NOT NULL,
|
|
"score" integer DEFAULT 0 NOT NULL,
|
|
"level" text DEFAULT 'low' NOT NULL,
|
|
"signals" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"last_evaluated_at" timestamp with time zone,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
ALTER TABLE "customers" ADD CONSTRAINT "customers_merchant_id_merchants_id_fk" FOREIGN KEY ("merchant_id") REFERENCES "public"."merchants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "merchants" ADD CONSTRAINT "merchants_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 "payout_wallets" ADD CONSTRAINT "payout_wallets_merchant_id_merchants_id_fk" FOREIGN KEY ("merchant_id") REFERENCES "public"."merchants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "users" ADD CONSTRAINT "users_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 "bundle_items" ADD CONSTRAINT "bundle_items_bundle_id_bundles_id_fk" FOREIGN KEY ("bundle_id") REFERENCES "public"."bundles"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "bundle_items" ADD CONSTRAINT "bundle_items_product_id_products_id_fk" FOREIGN KEY ("product_id") REFERENCES "public"."products"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "bundle_items" ADD CONSTRAINT "bundle_items_price_id_prices_id_fk" FOREIGN KEY ("price_id") REFERENCES "public"."prices"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "bundles" ADD CONSTRAINT "bundles_merchant_id_merchants_id_fk" FOREIGN KEY ("merchant_id") REFERENCES "public"."merchants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "file_assets" ADD CONSTRAINT "file_assets_merchant_id_merchants_id_fk" FOREIGN KEY ("merchant_id") REFERENCES "public"."merchants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "file_assets" ADD CONSTRAINT "file_assets_product_id_products_id_fk" FOREIGN KEY ("product_id") REFERENCES "public"."products"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "prices" ADD CONSTRAINT "prices_product_id_products_id_fk" FOREIGN KEY ("product_id") REFERENCES "public"."products"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "products" ADD CONSTRAINT "products_merchant_id_merchants_id_fk" FOREIGN KEY ("merchant_id") REFERENCES "public"."merchants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "checkout_sessions" ADD CONSTRAINT "checkout_sessions_merchant_id_merchants_id_fk" FOREIGN KEY ("merchant_id") REFERENCES "public"."merchants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "checkout_sessions" ADD CONSTRAINT "checkout_sessions_customer_id_customers_id_fk" FOREIGN KEY ("customer_id") REFERENCES "public"."customers"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "credit_balances" ADD CONSTRAINT "credit_balances_merchant_id_merchants_id_fk" FOREIGN KEY ("merchant_id") REFERENCES "public"."merchants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "credit_balances" ADD CONSTRAINT "credit_balances_customer_id_customers_id_fk" FOREIGN KEY ("customer_id") REFERENCES "public"."customers"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "payments" ADD CONSTRAINT "payments_merchant_id_merchants_id_fk" FOREIGN KEY ("merchant_id") REFERENCES "public"."merchants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "payments" ADD CONSTRAINT "payments_customer_id_customers_id_fk" FOREIGN KEY ("customer_id") REFERENCES "public"."customers"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "payments" ADD CONSTRAINT "payments_checkout_session_id_checkout_sessions_id_fk" FOREIGN KEY ("checkout_session_id") REFERENCES "public"."checkout_sessions"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "subscriptions" ADD CONSTRAINT "subscriptions_merchant_id_merchants_id_fk" FOREIGN KEY ("merchant_id") REFERENCES "public"."merchants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "subscriptions" ADD CONSTRAINT "subscriptions_customer_id_customers_id_fk" FOREIGN KEY ("customer_id") REFERENCES "public"."customers"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "subscriptions" ADD CONSTRAINT "subscriptions_price_id_prices_id_fk" FOREIGN KEY ("price_id") REFERENCES "public"."prices"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "usage_meters" ADD CONSTRAINT "usage_meters_merchant_id_merchants_id_fk" FOREIGN KEY ("merchant_id") REFERENCES "public"."merchants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "api_keys" ADD CONSTRAINT "api_keys_merchant_id_merchants_id_fk" FOREIGN KEY ("merchant_id") REFERENCES "public"."merchants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "entitlements" ADD CONSTRAINT "entitlements_merchant_id_merchants_id_fk" FOREIGN KEY ("merchant_id") REFERENCES "public"."merchants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "entitlements" ADD CONSTRAINT "entitlements_customer_id_customers_id_fk" FOREIGN KEY ("customer_id") REFERENCES "public"."customers"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "entitlements" ADD CONSTRAINT "entitlements_product_id_products_id_fk" FOREIGN KEY ("product_id") REFERENCES "public"."products"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "license_keys" ADD CONSTRAINT "license_keys_merchant_id_merchants_id_fk" FOREIGN KEY ("merchant_id") REFERENCES "public"."merchants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "license_keys" ADD CONSTRAINT "license_keys_entitlement_id_entitlements_id_fk" FOREIGN KEY ("entitlement_id") REFERENCES "public"."entitlements"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "delivery_actions" ADD CONSTRAINT "delivery_actions_delivery_plan_id_delivery_plans_id_fk" FOREIGN KEY ("delivery_plan_id") REFERENCES "public"."delivery_plans"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "delivery_logs" ADD CONSTRAINT "delivery_logs_delivery_run_id_delivery_runs_id_fk" FOREIGN KEY ("delivery_run_id") REFERENCES "public"."delivery_runs"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "delivery_plans" ADD CONSTRAINT "delivery_plans_merchant_id_merchants_id_fk" FOREIGN KEY ("merchant_id") REFERENCES "public"."merchants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "delivery_plans" ADD CONSTRAINT "delivery_plans_product_id_products_id_fk" FOREIGN KEY ("product_id") REFERENCES "public"."products"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "delivery_runs" ADD CONSTRAINT "delivery_runs_delivery_plan_id_delivery_plans_id_fk" FOREIGN KEY ("delivery_plan_id") REFERENCES "public"."delivery_plans"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "delivery_runs" ADD CONSTRAINT "delivery_runs_merchant_id_merchants_id_fk" FOREIGN KEY ("merchant_id") REFERENCES "public"."merchants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "webhook_endpoints" ADD CONSTRAINT "webhook_endpoints_merchant_id_merchants_id_fk" FOREIGN KEY ("merchant_id") REFERENCES "public"."merchants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "webhook_events" ADD CONSTRAINT "webhook_events_merchant_id_merchants_id_fk" FOREIGN KEY ("merchant_id") REFERENCES "public"."merchants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "webhook_events" ADD CONSTRAINT "webhook_events_endpoint_id_webhook_endpoints_id_fk" FOREIGN KEY ("endpoint_id") REFERENCES "public"."webhook_endpoints"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "github_access_sync_runs" ADD CONSTRAINT "github_access_sync_runs_installation_id_github_installations_id_fk" FOREIGN KEY ("installation_id") REFERENCES "public"."github_installations"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "github_installations" ADD CONSTRAINT "github_installations_merchant_id_merchants_id_fk" FOREIGN KEY ("merchant_id") REFERENCES "public"."merchants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "github_repo_access_grants" ADD CONSTRAINT "github_repo_access_grants_installation_id_github_installations_id_fk" FOREIGN KEY ("installation_id") REFERENCES "public"."github_installations"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "github_repo_access_grants" ADD CONSTRAINT "github_repo_access_grants_customer_id_customers_id_fk" FOREIGN KEY ("customer_id") REFERENCES "public"."customers"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "github_repo_access_grants" ADD CONSTRAINT "github_repo_access_grants_repository_id_github_repositories_id_fk" FOREIGN KEY ("repository_id") REFERENCES "public"."github_repositories"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "github_repo_access_grants" ADD CONSTRAINT "github_repo_access_grants_team_id_github_teams_id_fk" FOREIGN KEY ("team_id") REFERENCES "public"."github_teams"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "github_repositories" ADD CONSTRAINT "github_repositories_installation_id_github_installations_id_fk" FOREIGN KEY ("installation_id") REFERENCES "public"."github_installations"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "github_teams" ADD CONSTRAINT "github_teams_installation_id_github_installations_id_fk" FOREIGN KEY ("installation_id") REFERENCES "public"."github_installations"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "discord_connections" ADD CONSTRAINT "discord_connections_merchant_id_merchants_id_fk" FOREIGN KEY ("merchant_id") REFERENCES "public"."merchants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "discord_guilds" ADD CONSTRAINT "discord_guilds_connection_id_discord_connections_id_fk" FOREIGN KEY ("connection_id") REFERENCES "public"."discord_connections"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "discord_role_grants" ADD CONSTRAINT "discord_role_grants_role_id_discord_roles_id_fk" FOREIGN KEY ("role_id") REFERENCES "public"."discord_roles"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "discord_role_grants" ADD CONSTRAINT "discord_role_grants_customer_id_customers_id_fk" FOREIGN KEY ("customer_id") REFERENCES "public"."customers"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "discord_roles" ADD CONSTRAINT "discord_roles_guild_id_discord_guilds_id_fk" FOREIGN KEY ("guild_id") REFERENCES "public"."discord_guilds"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "saas_entitlement_rules" ADD CONSTRAINT "saas_entitlement_rules_plan_id_saas_plans_id_fk" FOREIGN KEY ("plan_id") REFERENCES "public"."saas_plans"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "saas_features" ADD CONSTRAINT "saas_features_plan_id_saas_plans_id_fk" FOREIGN KEY ("plan_id") REFERENCES "public"."saas_plans"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "saas_plans" ADD CONSTRAINT "saas_plans_merchant_id_merchants_id_fk" FOREIGN KEY ("merchant_id") REFERENCES "public"."merchants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "saas_plans" ADD CONSTRAINT "saas_plans_price_id_prices_id_fk" FOREIGN KEY ("price_id") REFERENCES "public"."prices"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "saas_seats" ADD CONSTRAINT "saas_seats_subscription_id_subscriptions_id_fk" FOREIGN KEY ("subscription_id") REFERENCES "public"."subscriptions"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "saas_seats" ADD CONSTRAINT "saas_seats_customer_id_customers_id_fk" FOREIGN KEY ("customer_id") REFERENCES "public"."customers"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "agent_buyers" ADD CONSTRAINT "agent_buyers_merchant_id_merchants_id_fk" FOREIGN KEY ("merchant_id") REFERENCES "public"."merchants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "agent_service_metadata" ADD CONSTRAINT "agent_service_metadata_agent_service_id_agent_services_id_fk" FOREIGN KEY ("agent_service_id") REFERENCES "public"."agent_services"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "agent_services" ADD CONSTRAINT "agent_services_merchant_id_merchants_id_fk" FOREIGN KEY ("merchant_id") REFERENCES "public"."merchants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "agent_usage_events" ADD CONSTRAINT "agent_usage_events_agent_service_id_agent_services_id_fk" FOREIGN KEY ("agent_service_id") REFERENCES "public"."agent_services"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "agent_usage_events" ADD CONSTRAINT "agent_usage_events_agent_buyer_id_agent_buyers_id_fk" FOREIGN KEY ("agent_buyer_id") REFERENCES "public"."agent_buyers"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "escrow_disputes" ADD CONSTRAINT "escrow_disputes_escrow_task_id_escrow_tasks_id_fk" FOREIGN KEY ("escrow_task_id") REFERENCES "public"."escrow_tasks"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "escrow_disputes" ADD CONSTRAINT "escrow_disputes_raised_by_customers_id_fk" FOREIGN KEY ("raised_by") REFERENCES "public"."customers"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "escrow_fundings" ADD CONSTRAINT "escrow_fundings_escrow_task_id_escrow_tasks_id_fk" FOREIGN KEY ("escrow_task_id") REFERENCES "public"."escrow_tasks"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "escrow_releases" ADD CONSTRAINT "escrow_releases_escrow_task_id_escrow_tasks_id_fk" FOREIGN KEY ("escrow_task_id") REFERENCES "public"."escrow_tasks"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "escrow_releases" ADD CONSTRAINT "escrow_releases_submission_id_escrow_submissions_id_fk" FOREIGN KEY ("submission_id") REFERENCES "public"."escrow_submissions"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "escrow_submissions" ADD CONSTRAINT "escrow_submissions_escrow_task_id_escrow_tasks_id_fk" FOREIGN KEY ("escrow_task_id") REFERENCES "public"."escrow_tasks"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "escrow_submissions" ADD CONSTRAINT "escrow_submissions_submitted_by_customers_id_fk" FOREIGN KEY ("submitted_by") REFERENCES "public"."customers"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "escrow_tasks" ADD CONSTRAINT "escrow_tasks_merchant_id_merchants_id_fk" FOREIGN KEY ("merchant_id") REFERENCES "public"."merchants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "escrow_tasks" ADD CONSTRAINT "escrow_tasks_buyer_customer_id_customers_id_fk" FOREIGN KEY ("buyer_customer_id") REFERENCES "public"."customers"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "escrow_tasks" ADD CONSTRAINT "escrow_tasks_seller_customer_id_customers_id_fk" FOREIGN KEY ("seller_customer_id") REFERENCES "public"."customers"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "marketplace_listings" ADD CONSTRAINT "marketplace_listings_merchant_id_merchants_id_fk" FOREIGN KEY ("merchant_id") REFERENCES "public"."merchants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "marketplace_listings" ADD CONSTRAINT "marketplace_listings_product_id_products_id_fk" FOREIGN KEY ("product_id") REFERENCES "public"."products"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "risk_profiles" ADD CONSTRAINT "risk_profiles_merchant_id_merchants_id_fk" FOREIGN KEY ("merchant_id") REFERENCES "public"."merchants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "risk_profiles" ADD CONSTRAINT "risk_profiles_customer_id_customers_id_fk" FOREIGN KEY ("customer_id") REFERENCES "public"."customers"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
CREATE INDEX "customers_merchant_id_idx" ON "customers" USING btree ("merchant_id");--> statement-breakpoint
|
|
CREATE INDEX "customers_email_idx" ON "customers" USING btree ("email");--> statement-breakpoint
|
|
CREATE INDEX "merchants_organization_id_idx" ON "merchants" USING btree ("organization_id");--> statement-breakpoint
|
|
CREATE INDEX "payout_wallets_merchant_id_idx" ON "payout_wallets" USING btree ("merchant_id");--> statement-breakpoint
|
|
CREATE INDEX "users_organization_id_idx" ON "users" USING btree ("organization_id");--> statement-breakpoint
|
|
CREATE INDEX "users_email_idx" ON "users" USING btree ("email");--> statement-breakpoint
|
|
CREATE INDEX "bundle_items_bundle_id_idx" ON "bundle_items" USING btree ("bundle_id");--> statement-breakpoint
|
|
CREATE INDEX "bundle_items_product_id_idx" ON "bundle_items" USING btree ("product_id");--> statement-breakpoint
|
|
CREATE INDEX "bundles_merchant_id_idx" ON "bundles" USING btree ("merchant_id");--> statement-breakpoint
|
|
CREATE INDEX "file_assets_merchant_id_idx" ON "file_assets" USING btree ("merchant_id");--> statement-breakpoint
|
|
CREATE INDEX "file_assets_product_id_idx" ON "file_assets" USING btree ("product_id");--> statement-breakpoint
|
|
CREATE INDEX "prices_product_id_idx" ON "prices" USING btree ("product_id");--> statement-breakpoint
|
|
CREATE INDEX "products_merchant_id_idx" ON "products" USING btree ("merchant_id");--> statement-breakpoint
|
|
CREATE INDEX "checkout_sessions_merchant_id_idx" ON "checkout_sessions" USING btree ("merchant_id");--> statement-breakpoint
|
|
CREATE INDEX "checkout_sessions_customer_id_idx" ON "checkout_sessions" USING btree ("customer_id");--> statement-breakpoint
|
|
CREATE INDEX "credit_balances_merchant_id_idx" ON "credit_balances" USING btree ("merchant_id");--> statement-breakpoint
|
|
CREATE INDEX "credit_balances_customer_id_idx" ON "credit_balances" USING btree ("customer_id");--> statement-breakpoint
|
|
CREATE INDEX "payments_merchant_id_idx" ON "payments" USING btree ("merchant_id");--> statement-breakpoint
|
|
CREATE INDEX "payments_customer_id_idx" ON "payments" USING btree ("customer_id");--> statement-breakpoint
|
|
CREATE INDEX "payments_checkout_session_id_idx" ON "payments" USING btree ("checkout_session_id");--> statement-breakpoint
|
|
CREATE INDEX "payments_tx_hash_idx" ON "payments" USING btree ("tx_hash");--> statement-breakpoint
|
|
CREATE INDEX "subscriptions_merchant_id_idx" ON "subscriptions" USING btree ("merchant_id");--> statement-breakpoint
|
|
CREATE INDEX "subscriptions_customer_id_idx" ON "subscriptions" USING btree ("customer_id");--> statement-breakpoint
|
|
CREATE INDEX "subscriptions_price_id_idx" ON "subscriptions" USING btree ("price_id");--> statement-breakpoint
|
|
CREATE INDEX "usage_meters_merchant_id_idx" ON "usage_meters" USING btree ("merchant_id");--> statement-breakpoint
|
|
CREATE INDEX "api_keys_merchant_id_idx" ON "api_keys" USING btree ("merchant_id");--> statement-breakpoint
|
|
CREATE INDEX "api_keys_prefix_idx" ON "api_keys" USING btree ("prefix");--> statement-breakpoint
|
|
CREATE INDEX "entitlements_merchant_id_idx" ON "entitlements" USING btree ("merchant_id");--> statement-breakpoint
|
|
CREATE INDEX "entitlements_customer_id_idx" ON "entitlements" USING btree ("customer_id");--> statement-breakpoint
|
|
CREATE INDEX "entitlements_product_id_idx" ON "entitlements" USING btree ("product_id");--> statement-breakpoint
|
|
CREATE INDEX "license_keys_merchant_id_idx" ON "license_keys" USING btree ("merchant_id");--> statement-breakpoint
|
|
CREATE INDEX "license_keys_entitlement_id_idx" ON "license_keys" USING btree ("entitlement_id");--> statement-breakpoint
|
|
CREATE INDEX "delivery_actions_delivery_plan_id_idx" ON "delivery_actions" USING btree ("delivery_plan_id");--> statement-breakpoint
|
|
CREATE INDEX "delivery_logs_delivery_run_id_idx" ON "delivery_logs" USING btree ("delivery_run_id");--> statement-breakpoint
|
|
CREATE INDEX "delivery_plans_merchant_id_idx" ON "delivery_plans" USING btree ("merchant_id");--> statement-breakpoint
|
|
CREATE INDEX "delivery_plans_product_id_idx" ON "delivery_plans" USING btree ("product_id");--> statement-breakpoint
|
|
CREATE INDEX "delivery_runs_delivery_plan_id_idx" ON "delivery_runs" USING btree ("delivery_plan_id");--> statement-breakpoint
|
|
CREATE INDEX "delivery_runs_merchant_id_idx" ON "delivery_runs" USING btree ("merchant_id");--> statement-breakpoint
|
|
CREATE INDEX "webhook_endpoints_merchant_id_idx" ON "webhook_endpoints" USING btree ("merchant_id");--> statement-breakpoint
|
|
CREATE INDEX "webhook_events_merchant_id_idx" ON "webhook_events" USING btree ("merchant_id");--> statement-breakpoint
|
|
CREATE INDEX "webhook_events_endpoint_id_idx" ON "webhook_events" USING btree ("endpoint_id");--> statement-breakpoint
|
|
CREATE INDEX "webhook_events_type_idx" ON "webhook_events" USING btree ("type");--> statement-breakpoint
|
|
CREATE INDEX "github_access_sync_runs_installation_id_idx" ON "github_access_sync_runs" USING btree ("installation_id");--> statement-breakpoint
|
|
CREATE INDEX "github_installations_merchant_id_idx" ON "github_installations" USING btree ("merchant_id");--> statement-breakpoint
|
|
CREATE INDEX "github_installations_installation_id_idx" ON "github_installations" USING btree ("installation_id");--> statement-breakpoint
|
|
CREATE INDEX "github_repo_access_grants_installation_id_idx" ON "github_repo_access_grants" USING btree ("installation_id");--> statement-breakpoint
|
|
CREATE INDEX "github_repo_access_grants_customer_id_idx" ON "github_repo_access_grants" USING btree ("customer_id");--> statement-breakpoint
|
|
CREATE INDEX "github_repositories_installation_id_idx" ON "github_repositories" USING btree ("installation_id");--> statement-breakpoint
|
|
CREATE INDEX "github_teams_installation_id_idx" ON "github_teams" USING btree ("installation_id");--> statement-breakpoint
|
|
CREATE INDEX "discord_connections_merchant_id_idx" ON "discord_connections" USING btree ("merchant_id");--> statement-breakpoint
|
|
CREATE INDEX "discord_guilds_connection_id_idx" ON "discord_guilds" USING btree ("connection_id");--> statement-breakpoint
|
|
CREATE INDEX "discord_role_grants_role_id_idx" ON "discord_role_grants" USING btree ("role_id");--> statement-breakpoint
|
|
CREATE INDEX "discord_role_grants_customer_id_idx" ON "discord_role_grants" USING btree ("customer_id");--> statement-breakpoint
|
|
CREATE INDEX "discord_roles_guild_id_idx" ON "discord_roles" USING btree ("guild_id");--> statement-breakpoint
|
|
CREATE INDEX "saas_entitlement_rules_plan_id_idx" ON "saas_entitlement_rules" USING btree ("plan_id");--> statement-breakpoint
|
|
CREATE INDEX "saas_features_plan_id_idx" ON "saas_features" USING btree ("plan_id");--> statement-breakpoint
|
|
CREATE INDEX "saas_plans_merchant_id_idx" ON "saas_plans" USING btree ("merchant_id");--> statement-breakpoint
|
|
CREATE INDEX "saas_seats_subscription_id_idx" ON "saas_seats" USING btree ("subscription_id");--> statement-breakpoint
|
|
CREATE INDEX "agent_buyers_merchant_id_idx" ON "agent_buyers" USING btree ("merchant_id");--> statement-breakpoint
|
|
CREATE INDEX "agent_buyers_wallet_address_idx" ON "agent_buyers" USING btree ("wallet_address");--> statement-breakpoint
|
|
CREATE INDEX "agent_service_metadata_agent_service_id_idx" ON "agent_service_metadata" USING btree ("agent_service_id");--> statement-breakpoint
|
|
CREATE INDEX "agent_services_merchant_id_idx" ON "agent_services" USING btree ("merchant_id");--> statement-breakpoint
|
|
CREATE INDEX "agent_usage_events_agent_service_id_idx" ON "agent_usage_events" USING btree ("agent_service_id");--> statement-breakpoint
|
|
CREATE INDEX "agent_usage_events_agent_buyer_id_idx" ON "agent_usage_events" USING btree ("agent_buyer_id");--> statement-breakpoint
|
|
CREATE INDEX "escrow_disputes_escrow_task_id_idx" ON "escrow_disputes" USING btree ("escrow_task_id");--> statement-breakpoint
|
|
CREATE INDEX "escrow_fundings_escrow_task_id_idx" ON "escrow_fundings" USING btree ("escrow_task_id");--> statement-breakpoint
|
|
CREATE INDEX "escrow_releases_escrow_task_id_idx" ON "escrow_releases" USING btree ("escrow_task_id");--> statement-breakpoint
|
|
CREATE INDEX "escrow_submissions_escrow_task_id_idx" ON "escrow_submissions" USING btree ("escrow_task_id");--> statement-breakpoint
|
|
CREATE INDEX "escrow_tasks_merchant_id_idx" ON "escrow_tasks" USING btree ("merchant_id");--> statement-breakpoint
|
|
CREATE INDEX "escrow_tasks_buyer_customer_id_idx" ON "escrow_tasks" USING btree ("buyer_customer_id");--> statement-breakpoint
|
|
CREATE INDEX "escrow_tasks_seller_customer_id_idx" ON "escrow_tasks" USING btree ("seller_customer_id");--> statement-breakpoint
|
|
CREATE INDEX "marketplace_listings_merchant_id_idx" ON "marketplace_listings" USING btree ("merchant_id");--> statement-breakpoint
|
|
CREATE INDEX "marketplace_listings_product_id_idx" ON "marketplace_listings" USING btree ("product_id");--> statement-breakpoint
|
|
CREATE INDEX "risk_profiles_merchant_id_idx" ON "risk_profiles" USING btree ("merchant_id");--> statement-breakpoint
|
|
CREATE INDEX "risk_profiles_customer_id_idx" ON "risk_profiles" USING btree ("customer_id"); |