diff --git a/controlplane/migrations/0133_foamy_vargas.sql b/controlplane/migrations/0133_foamy_vargas.sql new file mode 100644 index 0000000000..61a2a203de --- /dev/null +++ b/controlplane/migrations/0133_foamy_vargas.sql @@ -0,0 +1,2 @@ +ALTER TABLE "organization_invitations" ADD COLUMN "last_sent_at" timestamp with time zone;--> statement-breakpoint +ALTER TABLE "organization_members" ADD COLUMN "active" boolean DEFAULT true NOT NULL; \ No newline at end of file diff --git a/controlplane/migrations/meta/0133_snapshot.json b/controlplane/migrations/meta/0133_snapshot.json new file mode 100644 index 0000000000..357e97de9f --- /dev/null +++ b/controlplane/migrations/meta/0133_snapshot.json @@ -0,0 +1,8651 @@ +{ + "id": "781ded1a-9a7d-4d9e-b443-51651c9f154e", + "prevId": "3904e4bd-f2e7-4364-a807-c3000b7d0f56", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.api_key_permissions": { + "name": "api_key_permissions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "api_key_id": { + "name": "api_key_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "permission": { + "name": "permission", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "akp_api_key_id_idx": { + "name": "akp_api_key_id_idx", + "columns": [ + { + "expression": "api_key_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "api_key_permissions_api_key_id_api_keys_id_fk": { + "name": "api_key_permissions_api_key_id_api_keys_id_fk", + "tableFrom": "api_key_permissions", + "tableTo": "api_keys", + "columnsFrom": [ + "api_key_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.api_key_resources": { + "name": "api_key_resources", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "api_key_id": { + "name": "api_key_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "target_id": { + "name": "target_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "akr_api_key_id_idx": { + "name": "akr_api_key_id_idx", + "columns": [ + { + "expression": "api_key_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "akr_target_id_idx": { + "name": "akr_target_id_idx", + "columns": [ + { + "expression": "target_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "api_key_resources_api_key_id_api_keys_id_fk": { + "name": "api_key_resources_api_key_id_api_keys_id_fk", + "tableFrom": "api_key_resources", + "tableTo": "api_keys", + "columnsFrom": [ + "api_key_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "api_key_resources_target_id_targets_id_fk": { + "name": "api_key_resources_target_id_targets_id_fk", + "tableFrom": "api_key_resources", + "tableTo": "targets", + "columnsFrom": [ + "target_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.api_keys": { + "name": "api_keys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "group_id": { + "name": "group_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "last_used_at": { + "name": "last_used_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()" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "apikey_name_idx": { + "name": "apikey_name_idx", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ak_user_id_idx": { + "name": "ak_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ak_organization_id_idx": { + "name": "ak_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "api_keys_user_id_users_id_fk": { + "name": "api_keys_user_id_users_id_fk", + "tableFrom": "api_keys", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "api_keys_organization_id_organizations_id_fk": { + "name": "api_keys_organization_id_organizations_id_fk", + "tableFrom": "api_keys", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "api_keys_group_id_organization_groups_id_fk": { + "name": "api_keys_group_id_organization_groups_id_fk", + "tableFrom": "api_keys", + "tableTo": "organization_groups", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "api_keys_key_unique": { + "name": "api_keys_key_unique", + "nullsNotDistinct": false, + "columns": [ + "key" + ] + } + }, + "checkConstraints": {} + }, + "public.audit_logs": { + "name": "audit_logs", + "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 + }, + "organization_slug": { + "name": "organization_slug", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "action": { + "name": "action", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "audit_action": { + "name": "audit_action", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "auditable_type": { + "name": "auditable_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "auditable_display_name": { + "name": "auditable_display_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "target_id": { + "name": "target_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "target_type": { + "name": "target_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "target_display_name": { + "name": "target_display_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "target_namespace_id": { + "name": "target_namespace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "target_namespace": { + "name": "target_namespace", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "actor_id": { + "name": "actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "actor_display_name": { + "name": "actor_display_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "actor_type": { + "name": "actor_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "api_key_name": { + "name": "api_key_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "auditlogs_organization_idx": { + "name": "auditlogs_organization_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "auditlogs_created_at_idx": { + "name": "auditlogs_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.billing_plans": { + "name": "billing_plans", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "features": { + "name": "features", + "type": "json", + "primaryKey": false, + "notNull": true + }, + "stripe_price_id": { + "name": "stripe_price_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "weight": { + "name": "weight", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.billing_subscriptions": { + "name": "billing_subscriptions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "metadata": { + "name": "metadata", + "type": "json", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "price_id": { + "name": "price_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "cancel_at_period_end": { + "name": "cancel_at_period_end", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "cancel_at": { + "name": "cancel_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "canceled_at": { + "name": "canceled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "current_period_start": { + "name": "current_period_start", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "current_period_end": { + "name": "current_period_end", + "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()" + }, + "ended_at": { + "name": "ended_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "trial_start": { + "name": "trial_start", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "trial_end": { + "name": "trial_end", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "billsubs_organization_id_idx": { + "name": "billsubs_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "billing_subscriptions_organization_id_organizations_id_fk": { + "name": "billing_subscriptions_organization_id_organizations_id_fk", + "tableFrom": "billing_subscriptions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.cache_warmer_operations": { + "name": "cache_warmer_operations", + "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 + }, + "federated_graph_id": { + "name": "federated_graph_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "operation_content": { + "name": "operation_content", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "operation_hash": { + "name": "operation_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "operation_persisted_id": { + "name": "operation_persisted_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "operation_name": { + "name": "operation_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "client_name": { + "name": "client_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "client_version": { + "name": "client_version", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "planning_time": { + "name": "planning_time", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "is_manually_added": { + "name": "is_manually_added", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_by_id": { + "name": "created_by_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "cwo_organization_id_idx": { + "name": "cwo_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "cwo_federated_graph_id_idx": { + "name": "cwo_federated_graph_id_idx", + "columns": [ + { + "expression": "federated_graph_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "cwo_created_by_id_idx": { + "name": "cwo_created_by_id_idx", + "columns": [ + { + "expression": "created_by_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "cache_warmer_operations_organization_id_organizations_id_fk": { + "name": "cache_warmer_operations_organization_id_organizations_id_fk", + "tableFrom": "cache_warmer_operations", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "cache_warmer_operations_federated_graph_id_federated_graphs_id_fk": { + "name": "cache_warmer_operations_federated_graph_id_federated_graphs_id_fk", + "tableFrom": "cache_warmer_operations", + "tableTo": "federated_graphs", + "columnsFrom": [ + "federated_graph_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "cache_warmer_operations_created_by_id_users_id_fk": { + "name": "cache_warmer_operations_created_by_id_users_id_fk", + "tableFrom": "cache_warmer_operations", + "tableTo": "users", + "columnsFrom": [ + "created_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.contracts": { + "name": "contracts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "source_federated_graph_id": { + "name": "source_federated_graph_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "downstream_federated_graph_id": { + "name": "downstream_federated_graph_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "exclude_tags": { + "name": "exclude_tags", + "type": "text[]", + "primaryKey": false, + "notNull": true + }, + "include_tags": { + "name": "include_tags", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "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": false + }, + "created_by_id": { + "name": "created_by_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_by_id": { + "name": "updated_by_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "contracts_created_by_id_idx": { + "name": "contracts_created_by_id_idx", + "columns": [ + { + "expression": "created_by_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "contracts_updated_by_id_idx": { + "name": "contracts_updated_by_id_idx", + "columns": [ + { + "expression": "updated_by_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "contracts_downstream_federated_graph_id_idx": { + "name": "contracts_downstream_federated_graph_id_idx", + "columns": [ + { + "expression": "downstream_federated_graph_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "contracts_source_federated_graph_id_federated_graphs_id_fk": { + "name": "contracts_source_federated_graph_id_federated_graphs_id_fk", + "tableFrom": "contracts", + "tableTo": "federated_graphs", + "columnsFrom": [ + "source_federated_graph_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "contracts_downstream_federated_graph_id_federated_graphs_id_fk": { + "name": "contracts_downstream_federated_graph_id_federated_graphs_id_fk", + "tableFrom": "contracts", + "tableTo": "federated_graphs", + "columnsFrom": [ + "downstream_federated_graph_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "contracts_created_by_id_users_id_fk": { + "name": "contracts_created_by_id_users_id_fk", + "tableFrom": "contracts", + "tableTo": "users", + "columnsFrom": [ + "created_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "contracts_updated_by_id_users_id_fk": { + "name": "contracts_updated_by_id_users_id_fk", + "tableFrom": "contracts", + "tableTo": "users", + "columnsFrom": [ + "updated_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "federated_graph_source_downstream_id": { + "name": "federated_graph_source_downstream_id", + "nullsNotDistinct": false, + "columns": [ + "source_federated_graph_id", + "downstream_federated_graph_id" + ] + } + }, + "checkConstraints": {} + }, + "public.feature_flags_to_feature_subgraphs": { + "name": "feature_flags_to_feature_subgraphs", + "schema": "", + "columns": { + "feature_flag_id": { + "name": "feature_flag_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "feature_subgraph_id": { + "name": "feature_subgraph_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "fffs_feature_flag_id_idx": { + "name": "fffs_feature_flag_id_idx", + "columns": [ + { + "expression": "feature_flag_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "fffs_feature_subgraph_id_idx": { + "name": "fffs_feature_subgraph_id_idx", + "columns": [ + { + "expression": "feature_subgraph_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "feature_flags_to_feature_subgraphs_feature_flag_id_feature_flags_id_fk": { + "name": "feature_flags_to_feature_subgraphs_feature_flag_id_feature_flags_id_fk", + "tableFrom": "feature_flags_to_feature_subgraphs", + "tableTo": "feature_flags", + "columnsFrom": [ + "feature_flag_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "feature_flags_to_feature_subgraphs_feature_subgraph_id_subgraphs_id_fk": { + "name": "feature_flags_to_feature_subgraphs_feature_subgraph_id_subgraphs_id_fk", + "tableFrom": "feature_flags_to_feature_subgraphs", + "tableTo": "subgraphs", + "columnsFrom": [ + "feature_subgraph_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "feature_flags_to_feature_subgraphs_feature_flag_id_feature_subgraph_id_pk": { + "name": "feature_flags_to_feature_subgraphs_feature_flag_id_feature_subgraph_id_pk", + "columns": [ + "feature_flag_id", + "feature_subgraph_id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.feature_flags": { + "name": "feature_flags", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "namespace_id": { + "name": "namespace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "labels": { + "name": "labels", + "type": "text[]", + "primaryKey": false, + "notNull": false + }, + "is_enabled": { + "name": "is_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "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": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "ff_organization_id_idx": { + "name": "ff_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ff_namespace_id_idx": { + "name": "ff_namespace_id_idx", + "columns": [ + { + "expression": "namespace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ff_created_by_idx": { + "name": "ff_created_by_idx", + "columns": [ + { + "expression": "created_by", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "feature_flags_organization_id_organizations_id_fk": { + "name": "feature_flags_organization_id_organizations_id_fk", + "tableFrom": "feature_flags", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "feature_flags_namespace_id_namespaces_id_fk": { + "name": "feature_flags_namespace_id_namespaces_id_fk", + "tableFrom": "feature_flags", + "tableTo": "namespaces", + "columnsFrom": [ + "namespace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "feature_flags_created_by_users_id_fk": { + "name": "feature_flags_created_by_users_id_fk", + "tableFrom": "feature_flags", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.feature_subgraphs_to_base_subgraphs": { + "name": "feature_subgraphs_to_base_subgraphs", + "schema": "", + "columns": { + "feature_subgraph_id": { + "name": "feature_subgraph_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "base_subgraph_id": { + "name": "base_subgraph_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "fsbs_feature_subgraph_id_idx": { + "name": "fsbs_feature_subgraph_id_idx", + "columns": [ + { + "expression": "feature_subgraph_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "fsbs_base_subgraph_id_idx": { + "name": "fsbs_base_subgraph_id_idx", + "columns": [ + { + "expression": "base_subgraph_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "feature_subgraphs_to_base_subgraphs_feature_subgraph_id_subgraphs_id_fk": { + "name": "feature_subgraphs_to_base_subgraphs_feature_subgraph_id_subgraphs_id_fk", + "tableFrom": "feature_subgraphs_to_base_subgraphs", + "tableTo": "subgraphs", + "columnsFrom": [ + "feature_subgraph_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "feature_subgraphs_to_base_subgraphs_base_subgraph_id_subgraphs_id_fk": { + "name": "feature_subgraphs_to_base_subgraphs_base_subgraph_id_subgraphs_id_fk", + "tableFrom": "feature_subgraphs_to_base_subgraphs", + "tableTo": "subgraphs", + "columnsFrom": [ + "base_subgraph_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "feature_subgraphs_to_base_subgraphs_feature_subgraph_id_base_subgraph_id_pk": { + "name": "feature_subgraphs_to_base_subgraphs_feature_subgraph_id_base_subgraph_id_pk", + "columns": [ + "feature_subgraph_id", + "base_subgraph_id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.federated_graph_clients": { + "name": "federated_graph_clients", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "federated_graph_id": { + "name": "federated_graph_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()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by_id": { + "name": "created_by_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_by_id": { + "name": "updated_by_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "fgc_created_by_id_idx": { + "name": "fgc_created_by_id_idx", + "columns": [ + { + "expression": "created_by_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "fgc_updated_by_id_idx": { + "name": "fgc_updated_by_id_idx", + "columns": [ + { + "expression": "updated_by_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "federated_graph_clients_federated_graph_id_federated_graphs_id_fk": { + "name": "federated_graph_clients_federated_graph_id_federated_graphs_id_fk", + "tableFrom": "federated_graph_clients", + "tableTo": "federated_graphs", + "columnsFrom": [ + "federated_graph_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "federated_graph_clients_created_by_id_users_id_fk": { + "name": "federated_graph_clients_created_by_id_users_id_fk", + "tableFrom": "federated_graph_clients", + "tableTo": "users", + "columnsFrom": [ + "created_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "federated_graph_clients_updated_by_id_users_id_fk": { + "name": "federated_graph_clients_updated_by_id_users_id_fk", + "tableFrom": "federated_graph_clients", + "tableTo": "users", + "columnsFrom": [ + "updated_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "federated_graph_client_name": { + "name": "federated_graph_client_name", + "nullsNotDistinct": false, + "columns": [ + "federated_graph_id", + "name" + ] + } + }, + "checkConstraints": {} + }, + "public.federated_graph_persisted_operations": { + "name": "federated_graph_persisted_operations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "federated_graph_id": { + "name": "federated_graph_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "client_id": { + "name": "client_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "operation_id": { + "name": "operation_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "hash": { + "name": "hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_path": { + "name": "file_path", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "operation_names": { + "name": "operation_names", + "type": "text[]", + "primaryKey": false, + "notNull": false + }, + "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": false + }, + "operation_content": { + "name": "operation_content", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by_id": { + "name": "created_by_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_by_id": { + "name": "updated_by_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "fgpo_created_by_id_idx": { + "name": "fgpo_created_by_id_idx", + "columns": [ + { + "expression": "created_by_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "fgpo_updated_by_id_idx": { + "name": "fgpo_updated_by_id_idx", + "columns": [ + { + "expression": "updated_by_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "fgpo_client_id_idx": { + "name": "fgpo_client_id_idx", + "columns": [ + { + "expression": "client_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "federated_graph_persisted_operations_federated_graph_id_federated_graphs_id_fk": { + "name": "federated_graph_persisted_operations_federated_graph_id_federated_graphs_id_fk", + "tableFrom": "federated_graph_persisted_operations", + "tableTo": "federated_graphs", + "columnsFrom": [ + "federated_graph_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "federated_graph_persisted_operations_client_id_federated_graph_clients_id_fk": { + "name": "federated_graph_persisted_operations_client_id_federated_graph_clients_id_fk", + "tableFrom": "federated_graph_persisted_operations", + "tableTo": "federated_graph_clients", + "columnsFrom": [ + "client_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "federated_graph_persisted_operations_created_by_id_users_id_fk": { + "name": "federated_graph_persisted_operations_created_by_id_users_id_fk", + "tableFrom": "federated_graph_persisted_operations", + "tableTo": "users", + "columnsFrom": [ + "created_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "federated_graph_persisted_operations_updated_by_id_users_id_fk": { + "name": "federated_graph_persisted_operations_updated_by_id_users_id_fk", + "tableFrom": "federated_graph_persisted_operations", + "tableTo": "users", + "columnsFrom": [ + "updated_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "federated_graph_persisted_operations_file_path_unique": { + "name": "federated_graph_persisted_operations_file_path_unique", + "nullsNotDistinct": false, + "columns": [ + "file_path" + ] + }, + "federated_graph_operation_id": { + "name": "federated_graph_operation_id", + "nullsNotDistinct": false, + "columns": [ + "federated_graph_id", + "client_id", + "operation_id" + ] + } + }, + "checkConstraints": {} + }, + "public.federated_graphs": { + "name": "federated_graphs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "routing_url": { + "name": "routing_url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "target_id": { + "name": "target_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "composed_schema_version_id": { + "name": "composed_schema_version_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "admission_webhook_url": { + "name": "admission_webhook_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "admission_webhook_secret": { + "name": "admission_webhook_secret", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "supports_federation": { + "name": "supports_federation", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "router_compatibility_version": { + "name": "router_compatibility_version", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'1'" + } + }, + "indexes": { + "fgs_target_id_idx": { + "name": "fgs_target_id_idx", + "columns": [ + { + "expression": "target_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "fgs_composed_schema_version_id_idx": { + "name": "fgs_composed_schema_version_id_idx", + "columns": [ + { + "expression": "composed_schema_version_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "federated_graphs_target_id_targets_id_fk": { + "name": "federated_graphs_target_id_targets_id_fk", + "tableFrom": "federated_graphs", + "tableTo": "targets", + "columnsFrom": [ + "target_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "federated_graphs_composed_schema_version_id_schema_versions_id_fk": { + "name": "federated_graphs_composed_schema_version_id_schema_versions_id_fk", + "tableFrom": "federated_graphs", + "tableTo": "schema_versions", + "columnsFrom": [ + "composed_schema_version_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.federated_graphs_to_feature_flag_schema_versions": { + "name": "federated_graphs_to_feature_flag_schema_versions", + "schema": "", + "columns": { + "federated_graph_id": { + "name": "federated_graph_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "base_composition_schema_version_id": { + "name": "base_composition_schema_version_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "composed_schema_version_id": { + "name": "composed_schema_version_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "feature_flag_id": { + "name": "feature_flag_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "fgffsv_federated_graph_id_idx": { + "name": "fgffsv_federated_graph_id_idx", + "columns": [ + { + "expression": "federated_graph_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "fgffsv_base_composition_schema_version_id_idx": { + "name": "fgffsv_base_composition_schema_version_id_idx", + "columns": [ + { + "expression": "base_composition_schema_version_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "fgffsv_composed_schema_version_id_idx": { + "name": "fgffsv_composed_schema_version_id_idx", + "columns": [ + { + "expression": "composed_schema_version_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "fgffsv_feature_flag_id_idx": { + "name": "fgffsv_feature_flag_id_idx", + "columns": [ + { + "expression": "feature_flag_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "federated_graphs_to_feature_flag_schema_versions_federated_graph_id_federated_graphs_id_fk": { + "name": "federated_graphs_to_feature_flag_schema_versions_federated_graph_id_federated_graphs_id_fk", + "tableFrom": "federated_graphs_to_feature_flag_schema_versions", + "tableTo": "federated_graphs", + "columnsFrom": [ + "federated_graph_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "federated_graphs_to_feature_flag_schema_versions_base_composition_schema_version_id_schema_versions_id_fk": { + "name": "federated_graphs_to_feature_flag_schema_versions_base_composition_schema_version_id_schema_versions_id_fk", + "tableFrom": "federated_graphs_to_feature_flag_schema_versions", + "tableTo": "schema_versions", + "columnsFrom": [ + "base_composition_schema_version_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "federated_graphs_to_feature_flag_schema_versions_composed_schema_version_id_schema_versions_id_fk": { + "name": "federated_graphs_to_feature_flag_schema_versions_composed_schema_version_id_schema_versions_id_fk", + "tableFrom": "federated_graphs_to_feature_flag_schema_versions", + "tableTo": "schema_versions", + "columnsFrom": [ + "composed_schema_version_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "federated_graphs_to_feature_flag_schema_versions_feature_flag_id_feature_flags_id_fk": { + "name": "federated_graphs_to_feature_flag_schema_versions_feature_flag_id_feature_flags_id_fk", + "tableFrom": "federated_graphs_to_feature_flag_schema_versions", + "tableTo": "feature_flags", + "columnsFrom": [ + "feature_flag_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "federated_graphs_to_feature_flag_schema_versions_federated_graph_id_base_composition_schema_version_id_composed_schema_version_id_pk": { + "name": "federated_graphs_to_feature_flag_schema_versions_federated_graph_id_base_composition_schema_version_id_composed_schema_version_id_pk", + "columns": [ + "federated_graph_id", + "base_composition_schema_version_id", + "composed_schema_version_id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.field_grace_period": { + "name": "field_grace_period", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "subgraph_id": { + "name": "subgraph_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "namespace_id": { + "name": "namespace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "is_deprecated": { + "name": "is_deprecated", + "type": "boolean", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "unique_field_grace_period_idx": { + "name": "unique_field_grace_period_idx", + "columns": [ + { + "expression": "subgraph_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "namespace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "path", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "is_deprecated", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "fgp_subgraph_id_idx": { + "name": "fgp_subgraph_id_idx", + "columns": [ + { + "expression": "subgraph_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "fgp_organization_id_idx": { + "name": "fgp_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "fgp_namespace_id_idx": { + "name": "fgp_namespace_id_idx", + "columns": [ + { + "expression": "namespace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "field_grace_period_subgraph_id_subgraphs_id_fk": { + "name": "field_grace_period_subgraph_id_subgraphs_id_fk", + "tableFrom": "field_grace_period", + "tableTo": "subgraphs", + "columnsFrom": [ + "subgraph_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "field_grace_period_organization_id_organizations_id_fk": { + "name": "field_grace_period_organization_id_organizations_id_fk", + "tableFrom": "field_grace_period", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "field_grace_period_namespace_id_namespaces_id_fk": { + "name": "field_grace_period_namespace_id_namespaces_id_fk", + "tableFrom": "field_grace_period", + "tableTo": "namespaces", + "columnsFrom": [ + "namespace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.git_installations": { + "name": "git_installations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "git_installation_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "provider_account_id": { + "name": "provider_account_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "provider_installation_id": { + "name": "provider_installation_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "provider_name": { + "name": "provider_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "oauth_token": { + "name": "oauth_token", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.graph_api_tokens": { + "name": "graph_api_tokens", + "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 + }, + "federated_graph_id": { + "name": "federated_graph_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "graphApiToken_name_idx": { + "name": "graphApiToken_name_idx", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "federated_graph_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "gat_organization_id_idx": { + "name": "gat_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "gat_federated_graph_id_idx": { + "name": "gat_federated_graph_id_idx", + "columns": [ + { + "expression": "federated_graph_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "gat_created_by_idx": { + "name": "gat_created_by_idx", + "columns": [ + { + "expression": "created_by", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "graph_api_tokens_organization_id_organizations_id_fk": { + "name": "graph_api_tokens_organization_id_organizations_id_fk", + "tableFrom": "graph_api_tokens", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "graph_api_tokens_federated_graph_id_federated_graphs_id_fk": { + "name": "graph_api_tokens_federated_graph_id_federated_graphs_id_fk", + "tableFrom": "graph_api_tokens", + "tableTo": "federated_graphs", + "columnsFrom": [ + "federated_graph_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "graph_api_tokens_created_by_users_id_fk": { + "name": "graph_api_tokens_created_by_users_id_fk", + "tableFrom": "graph_api_tokens", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "graph_api_tokens_token_unique": { + "name": "graph_api_tokens_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "checkConstraints": {} + }, + "public.graph_composition_subgraphs": { + "name": "graph_composition_subgraphs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "graph_composition_id": { + "name": "graph_composition_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "subgraph_id": { + "name": "subgraph_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "subgraph_target_id": { + "name": "subgraph_target_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "subgraph_name": { + "name": "subgraph_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "schema_version_id": { + "name": "schema_version_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "change_type": { + "name": "change_type", + "type": "graph_composition_subgraph_change_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'unchanged'" + }, + "is_feature_subgraph": { + "name": "is_feature_subgraph", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "graphcompsub_graph_composition_id_idx": { + "name": "graphcompsub_graph_composition_id_idx", + "columns": [ + { + "expression": "graph_composition_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "graphcompsub_schema_version_id_idx": { + "name": "graphcompsub_schema_version_id_idx", + "columns": [ + { + "expression": "schema_version_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "graph_composition_subgraphs_graph_composition_id_graph_compositions_id_fk": { + "name": "graph_composition_subgraphs_graph_composition_id_graph_compositions_id_fk", + "tableFrom": "graph_composition_subgraphs", + "tableTo": "graph_compositions", + "columnsFrom": [ + "graph_composition_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "graph_composition_subgraphs_schema_version_id_schema_versions_id_fk": { + "name": "graph_composition_subgraphs_schema_version_id_schema_versions_id_fk", + "tableFrom": "graph_composition_subgraphs", + "tableTo": "schema_versions", + "columnsFrom": [ + "schema_version_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.graph_compositions": { + "name": "graph_compositions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "schema_version_id": { + "name": "schema_version_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "is_composable": { + "name": "is_composable", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "composition_errors": { + "name": "composition_errors", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "composition_warnings": { + "name": "composition_warnings", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "router_config_signature": { + "name": "router_config_signature", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "deployment_error": { + "name": "deployment_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "admission_error": { + "name": "admission_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_by_id": { + "name": "created_by_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by_email": { + "name": "created_by_email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_feature_flag_composition": { + "name": "is_feature_flag_composition", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "router_compatibility_version": { + "name": "router_compatibility_version", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'1'" + } + }, + "indexes": { + "graphcomp_schema_version_id_idx": { + "name": "graphcomp_schema_version_id_idx", + "columns": [ + { + "expression": "schema_version_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "graphcomp_created_by_id_idx": { + "name": "graphcomp_created_by_id_idx", + "columns": [ + { + "expression": "created_by_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "graph_compositions_schema_version_id_schema_versions_id_fk": { + "name": "graph_compositions_schema_version_id_schema_versions_id_fk", + "tableFrom": "graph_compositions", + "tableTo": "schema_versions", + "columnsFrom": [ + "schema_version_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "graph_compositions_created_by_id_users_id_fk": { + "name": "graph_compositions_created_by_id_users_id_fk", + "tableFrom": "graph_compositions", + "tableTo": "users", + "columnsFrom": [ + "created_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.graph_request_keys": { + "name": "graph_request_keys", + "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 + }, + "federated_graph_id": { + "name": "federated_graph_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "privateKey": { + "name": "privateKey", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "publicKey": { + "name": "publicKey", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "grk_organization_id_idx": { + "name": "grk_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "grk_federated_graph_id_idx": { + "name": "grk_federated_graph_id_idx", + "columns": [ + { + "expression": "federated_graph_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "graph_request_keys_organization_id_organizations_id_fk": { + "name": "graph_request_keys_organization_id_organizations_id_fk", + "tableFrom": "graph_request_keys", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "graph_request_keys_federated_graph_id_federated_graphs_id_fk": { + "name": "graph_request_keys_federated_graph_id_federated_graphs_id_fk", + "tableFrom": "graph_request_keys", + "tableTo": "federated_graphs", + "columnsFrom": [ + "federated_graph_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "graph_request_keys_federated_graph_id_unique": { + "name": "graph_request_keys_federated_graph_id_unique", + "nullsNotDistinct": false, + "columns": [ + "federated_graph_id" + ] + }, + "graph_request_keys_privateKey_unique": { + "name": "graph_request_keys_privateKey_unique", + "nullsNotDistinct": false, + "columns": [ + "privateKey" + ] + }, + "graph_request_keys_publicKey_unique": { + "name": "graph_request_keys_publicKey_unique", + "nullsNotDistinct": false, + "columns": [ + "publicKey" + ] + } + }, + "checkConstraints": {} + }, + "public.linked_schema_checks": { + "name": "linked_schema_checks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "schema_check_id": { + "name": "schema_check_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "linked_schema_check_id": { + "name": "linked_schema_check_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "lsc_schema_check_id_linked_schema_check_id_unique": { + "name": "lsc_schema_check_id_linked_schema_check_id_unique", + "columns": [ + { + "expression": "schema_check_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "linked_schema_check_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "lsc_schema_check_id_idx": { + "name": "lsc_schema_check_id_idx", + "columns": [ + { + "expression": "schema_check_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "lsc_linked_schema_check_id_idx": { + "name": "lsc_linked_schema_check_id_idx", + "columns": [ + { + "expression": "linked_schema_check_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "linked_schema_checks_schema_check_id_schema_checks_id_fk": { + "name": "linked_schema_checks_schema_check_id_schema_checks_id_fk", + "tableFrom": "linked_schema_checks", + "tableTo": "schema_checks", + "columnsFrom": [ + "schema_check_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "linked_schema_checks_linked_schema_check_id_schema_checks_id_fk": { + "name": "linked_schema_checks_linked_schema_check_id_schema_checks_id_fk", + "tableFrom": "linked_schema_checks", + "tableTo": "schema_checks", + "columnsFrom": [ + "linked_schema_check_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.linked_subgraphs": { + "name": "linked_subgraphs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "source_subgraph_id": { + "name": "source_subgraph_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "target_subgraph_id": { + "name": "target_subgraph_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_by_id": { + "name": "created_by_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "ls_source_subgraph_id_idx": { + "name": "ls_source_subgraph_id_idx", + "columns": [ + { + "expression": "source_subgraph_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ls_target_subgraph_id_idx": { + "name": "ls_target_subgraph_id_idx", + "columns": [ + { + "expression": "target_subgraph_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ls_created_by_id_idx": { + "name": "ls_created_by_id_idx", + "columns": [ + { + "expression": "created_by_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "linked_subgraphs_source_subgraph_id_subgraphs_id_fk": { + "name": "linked_subgraphs_source_subgraph_id_subgraphs_id_fk", + "tableFrom": "linked_subgraphs", + "tableTo": "subgraphs", + "columnsFrom": [ + "source_subgraph_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "linked_subgraphs_target_subgraph_id_subgraphs_id_fk": { + "name": "linked_subgraphs_target_subgraph_id_subgraphs_id_fk", + "tableFrom": "linked_subgraphs", + "tableTo": "subgraphs", + "columnsFrom": [ + "target_subgraph_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "linked_subgraphs_created_by_id_users_id_fk": { + "name": "linked_subgraphs_created_by_id_users_id_fk", + "tableFrom": "linked_subgraphs", + "tableTo": "users", + "columnsFrom": [ + "created_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "linked_subgraphs_source_subgraph_id_unique": { + "name": "linked_subgraphs_source_subgraph_id_unique", + "nullsNotDistinct": false, + "columns": [ + "source_subgraph_id" + ] + } + }, + "checkConstraints": {} + }, + "public.namespace_cache_warmer_config": { + "name": "namespace_cache_warmer_config", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "namespace_id": { + "name": "namespace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "max_operations_count": { + "name": "max_operations_count", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "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": false + } + }, + "indexes": { + "nscwc_namespace_id_idx": { + "name": "nscwc_namespace_id_idx", + "columns": [ + { + "expression": "namespace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "namespace_cache_warmer_config_namespace_id_namespaces_id_fk": { + "name": "namespace_cache_warmer_config_namespace_id_namespaces_id_fk", + "tableFrom": "namespace_cache_warmer_config", + "tableTo": "namespaces", + "columnsFrom": [ + "namespace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "namespace_cache_warmer_config_namespace_id_unique": { + "name": "namespace_cache_warmer_config_namespace_id_unique", + "nullsNotDistinct": false, + "columns": [ + "namespace_id" + ] + } + }, + "checkConstraints": {} + }, + "public.namespace_config": { + "name": "namespace_config", + "schema": "", + "columns": { + "namespace_id": { + "name": "namespace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "enable_linting": { + "name": "enable_linting", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "enable_graph_pruning": { + "name": "enable_graph_pruning", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "enable_cache_warming": { + "name": "enable_cache_warming", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "checks_timeframe_in_days": { + "name": "checks_timeframe_in_days", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "enable_proposals": { + "name": "enable_proposals", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "namespace_config_namespace_id_namespaces_id_fk": { + "name": "namespace_config_namespace_id_namespaces_id_fk", + "tableFrom": "namespace_config", + "tableTo": "namespaces", + "columnsFrom": [ + "namespace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_namespace": { + "name": "unique_namespace", + "nullsNotDistinct": false, + "columns": [ + "namespace_id" + ] + } + }, + "checkConstraints": {} + }, + "public.namespace_graph_pruning_check_config": { + "name": "namespace_graph_pruning_check_config", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "namespace_id": { + "name": "namespace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "graph_pruning_rule": { + "name": "graph_pruning_rule", + "type": "graph_pruning_rules", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "severity_level": { + "name": "severity_level", + "type": "lint_severity", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "grace_period": { + "name": "grace_period", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "scheme_usage_check_period": { + "name": "scheme_usage_check_period", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "nsgpcc_namespace_id_idx": { + "name": "nsgpcc_namespace_id_idx", + "columns": [ + { + "expression": "namespace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "namespace_graph_pruning_check_config_namespace_id_namespaces_id_fk": { + "name": "namespace_graph_pruning_check_config_namespace_id_namespaces_id_fk", + "tableFrom": "namespace_graph_pruning_check_config", + "tableTo": "namespaces", + "columnsFrom": [ + "namespace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.namespace_lint_check_config": { + "name": "namespace_lint_check_config", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "namespace_id": { + "name": "namespace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "lint_rule": { + "name": "lint_rule", + "type": "lint_rules", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "severity_level": { + "name": "severity_level", + "type": "lint_severity", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "nslcc_namespace_id_idx": { + "name": "nslcc_namespace_id_idx", + "columns": [ + { + "expression": "namespace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "namespace_lint_check_config_namespace_id_namespaces_id_fk": { + "name": "namespace_lint_check_config_namespace_id_namespaces_id_fk", + "tableFrom": "namespace_lint_check_config", + "tableTo": "namespaces", + "columnsFrom": [ + "namespace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.namespace_proposal_config": { + "name": "namespace_proposal_config", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "namespace_id": { + "name": "namespace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "check_severity_level": { + "name": "check_severity_level", + "type": "lint_severity", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "publish_severity_level": { + "name": "publish_severity_level", + "type": "lint_severity", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "namespace_proposal_config_namespace_id_namespaces_id_fk": { + "name": "namespace_proposal_config_namespace_id_namespaces_id_fk", + "tableFrom": "namespace_proposal_config", + "tableTo": "namespaces", + "columnsFrom": [ + "namespace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "npc_namespace_id_idx": { + "name": "npc_namespace_id_idx", + "nullsNotDistinct": false, + "columns": [ + "namespace_id" + ] + } + }, + "checkConstraints": {} + }, + "public.namespaces": { + "name": "namespaces", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "ns_organization_id_idx": { + "name": "ns_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ns_created_by_idx": { + "name": "ns_created_by_idx", + "columns": [ + { + "expression": "created_by", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "namespaces_organization_id_organizations_id_fk": { + "name": "namespaces_organization_id_organizations_id_fk", + "tableFrom": "namespaces", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "namespaces_created_by_users_id_fk": { + "name": "namespaces_created_by_users_id_fk", + "tableFrom": "namespaces", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_name": { + "name": "unique_name", + "nullsNotDistinct": false, + "columns": [ + "name", + "organization_id" + ] + } + }, + "checkConstraints": {} + }, + "public.oidc_providers": { + "name": "oidc_providers", + "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 + }, + "alias": { + "name": "alias", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "endpoint": { + "name": "endpoint", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "oidcp_organization_id_idx": { + "name": "oidcp_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "oidc_providers_organization_id_organizations_id_fk": { + "name": "oidc_providers_organization_id_organizations_id_fk", + "tableFrom": "oidc_providers", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "oidc_providers_alias_unique": { + "name": "oidc_providers_alias_unique", + "nullsNotDistinct": false, + "columns": [ + "alias" + ] + } + }, + "checkConstraints": {} + }, + "public.operation_change_overrides": { + "name": "operation_change_overrides", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "hash": { + "name": "hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "namespace_id": { + "name": "namespace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "change_type": { + "name": "change_type", + "type": "schema_change_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "hash_change_idx": { + "name": "hash_change_idx", + "columns": [ + { + "expression": "hash", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "namespace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "change_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "path", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "oco_created_by_idx": { + "name": "oco_created_by_idx", + "columns": [ + { + "expression": "created_by", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "operation_change_overrides_created_by_users_id_fk": { + "name": "operation_change_overrides_created_by_users_id_fk", + "tableFrom": "operation_change_overrides", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.operation_ignore_all_overrides": { + "name": "operation_ignore_all_overrides", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "hash": { + "name": "hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "namespace_id": { + "name": "namespace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "hash_namespace_ignore_idx": { + "name": "hash_namespace_ignore_idx", + "columns": [ + { + "expression": "hash", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "namespace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "oiao_created_by_idx": { + "name": "oiao_created_by_idx", + "columns": [ + { + "expression": "created_by", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "operation_ignore_all_overrides_created_by_users_id_fk": { + "name": "operation_ignore_all_overrides_created_by_users_id_fk", + "tableFrom": "operation_ignore_all_overrides", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.organization_billing": { + "name": "organization_billing", + "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 + }, + "plan": { + "name": "plan", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stripe_customer_id": { + "name": "stripe_customer_id", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "organization_billing_idx": { + "name": "organization_billing_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "organization_billing_stripe_idx": { + "name": "organization_billing_stripe_idx", + "columns": [ + { + "expression": "stripe_customer_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "organization_billing_organization_id_organizations_id_fk": { + "name": "organization_billing_organization_id_organizations_id_fk", + "tableFrom": "organization_billing", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.organization_features": { + "name": "organization_features", + "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 + }, + "feature": { + "name": "feature", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": true + }, + "limit": { + "name": "limit", + "type": "real", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "organization_feature_idx": { + "name": "organization_feature_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "feature", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "orgf_organization_id_idx": { + "name": "orgf_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "organization_features_organization_id_organizations_id_fk": { + "name": "organization_features_organization_id_organizations_id_fk", + "tableFrom": "organization_features", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.organization_group_members": { + "name": "organization_group_members", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_member_id": { + "name": "organization_member_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "group_id": { + "name": "group_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "organization_member_group_idx": { + "name": "organization_member_group_idx", + "columns": [ + { + "expression": "organization_member_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "group_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "organization_group_members_organization_member_id_organization_members_id_fk": { + "name": "organization_group_members_organization_member_id_organization_members_id_fk", + "tableFrom": "organization_group_members", + "tableTo": "organization_members", + "columnsFrom": [ + "organization_member_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "organization_group_members_group_id_organization_groups_id_fk": { + "name": "organization_group_members_group_id_organization_groups_id_fk", + "tableFrom": "organization_group_members", + "tableTo": "organization_groups", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.organization_group_rule_namespaces": { + "name": "organization_group_rule_namespaces", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "rule_id": { + "name": "rule_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "namespace_id": { + "name": "namespace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "organization_group_rule_namespaces_rule_id_organization_group_rules_id_fk": { + "name": "organization_group_rule_namespaces_rule_id_organization_group_rules_id_fk", + "tableFrom": "organization_group_rule_namespaces", + "tableTo": "organization_group_rules", + "columnsFrom": [ + "rule_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "organization_group_rule_namespaces_namespace_id_namespaces_id_fk": { + "name": "organization_group_rule_namespaces_namespace_id_namespaces_id_fk", + "tableFrom": "organization_group_rule_namespaces", + "tableTo": "namespaces", + "columnsFrom": [ + "namespace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.organization_group_rule_targets": { + "name": "organization_group_rule_targets", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "rule_id": { + "name": "rule_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "target_id": { + "name": "target_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "organization_group_rule_targets_rule_id_organization_group_rules_id_fk": { + "name": "organization_group_rule_targets_rule_id_organization_group_rules_id_fk", + "tableFrom": "organization_group_rule_targets", + "tableTo": "organization_group_rules", + "columnsFrom": [ + "rule_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "organization_group_rule_targets_target_id_targets_id_fk": { + "name": "organization_group_rule_targets_target_id_targets_id_fk", + "tableFrom": "organization_group_rule_targets", + "tableTo": "targets", + "columnsFrom": [ + "target_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.organization_group_rules": { + "name": "organization_group_rules", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "group_id": { + "name": "group_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "organization_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "organization_group_rules_group_id_organization_groups_id_fk": { + "name": "organization_group_rules_group_id_organization_groups_id_fk", + "tableFrom": "organization_group_rules", + "tableTo": "organization_groups", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.organization_groups": { + "name": "organization_groups", + "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 + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "builtin": { + "name": "builtin", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "kc_group_id": { + "name": "kc_group_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "organization_groups_organization_id_organizations_id_fk": { + "name": "organization_groups_organization_id_organizations_id_fk", + "tableFrom": "organization_groups", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "organization_groups_kc_group_id_unique": { + "name": "organization_groups_kc_group_id_unique", + "nullsNotDistinct": false, + "columns": [ + "kc_group_id" + ] + } + }, + "checkConstraints": {} + }, + "public.organization_integrations": { + "name": "organization_integrations", + "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 + }, + "events": { + "name": "events", + "type": "text[]", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "integration_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "organization_integration_idx": { + "name": "organization_integration_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "orgint_organization_id_idx": { + "name": "orgint_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "organization_integrations_organization_id_organizations_id_fk": { + "name": "organization_integrations_organization_id_organizations_id_fk", + "tableFrom": "organization_integrations", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.organization_invitation_groups": { + "name": "organization_invitation_groups", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "invitation_id": { + "name": "invitation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "group_id": { + "name": "group_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "org_inv_invitation_idx": { + "name": "org_inv_invitation_idx", + "columns": [ + { + "expression": "invitation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "org_inv_group_id": { + "name": "org_inv_group_id", + "columns": [ + { + "expression": "group_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "organization_invitation_groups_invitation_id_organization_invitations_id_fk": { + "name": "organization_invitation_groups_invitation_id_organization_invitations_id_fk", + "tableFrom": "organization_invitation_groups", + "tableTo": "organization_invitations", + "columnsFrom": [ + "invitation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "organization_invitation_groups_group_id_organization_groups_id_fk": { + "name": "organization_invitation_groups_group_id_organization_groups_id_fk", + "tableFrom": "organization_invitation_groups", + "tableTo": "organization_groups", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.organization_invitations": { + "name": "organization_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 + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "invited_by": { + "name": "invited_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "accepted": { + "name": "accepted", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "last_sent_at": { + "name": "last_sent_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": { + "orginv_organization_id_idx": { + "name": "orginv_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "orginv_user_id_idx": { + "name": "orginv_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "orginv_invited_by_idx": { + "name": "orginv_invited_by_idx", + "columns": [ + { + "expression": "invited_by", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "organization_invitations_organization_id_organizations_id_fk": { + "name": "organization_invitations_organization_id_organizations_id_fk", + "tableFrom": "organization_invitations", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "organization_invitations_user_id_users_id_fk": { + "name": "organization_invitations_user_id_users_id_fk", + "tableFrom": "organization_invitations", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "organization_invitations_invited_by_users_id_fk": { + "name": "organization_invitations_invited_by_users_id_fk", + "tableFrom": "organization_invitations", + "tableTo": "users", + "columnsFrom": [ + "invited_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.organization_member_roles": { + "name": "organization_member_roles", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_member_id": { + "name": "organization_member_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "member_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "organization_member_role_idx": { + "name": "organization_member_role_idx", + "columns": [ + { + "expression": "organization_member_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "role", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "organization_member_roles_organization_member_id_organization_members_id_fk": { + "name": "organization_member_roles_organization_member_id_organization_members_id_fk", + "tableFrom": "organization_member_roles", + "tableTo": "organization_members", + "columnsFrom": [ + "organization_member_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.organization_webhook_configs": { + "name": "organization_webhook_configs", + "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 + }, + "endpoint": { + "name": "endpoint", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "events": { + "name": "events", + "type": "text[]", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "orgwc_organization_id_idx": { + "name": "orgwc_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "organization_webhook_configs_organization_id_organizations_id_fk": { + "name": "organization_webhook_configs_organization_id_organizations_id_fk", + "tableFrom": "organization_webhook_configs", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "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 + }, + "invite_code": { + "name": "invite_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "kc_group_id": { + "name": "kc_group_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "is_deactivated": { + "name": "is_deactivated", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "deactivation_reason": { + "name": "deactivation_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "deactivated_at": { + "name": "deactivated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "queued_for_deletion_at": { + "name": "queued_for_deletion_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "queued_for_deletion_by": { + "name": "queued_for_deletion_by", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "orgs_created_by_idx": { + "name": "orgs_created_by_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "organizations_user_id_users_id_fk": { + "name": "organizations_user_id_users_id_fk", + "tableFrom": "organizations", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "organizations_slug_unique": { + "name": "organizations_slug_unique", + "nullsNotDistinct": false, + "columns": [ + "slug" + ] + }, + "organizations_kc_group_id_unique": { + "name": "organizations_kc_group_id_unique", + "nullsNotDistinct": false, + "columns": [ + "kc_group_id" + ] + } + }, + "checkConstraints": {} + }, + "public.organization_members": { + "name": "organization_members", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "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": { + "organization_member_idx": { + "name": "organization_member_idx", + "columns": [ + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "unique_organization_member_idx": { + "name": "unique_organization_member_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "orgm_organization_id_idx": { + "name": "orgm_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "organization_members_user_id_users_id_fk": { + "name": "organization_members_user_id_users_id_fk", + "tableFrom": "organization_members", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "organization_members_organization_id_organizations_id_fk": { + "name": "organization_members_organization_id_organizations_id_fk", + "tableFrom": "organization_members", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.playground_scripts": { + "name": "playground_scripts", + "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 + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_by_id": { + "name": "created_by_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "type": { + "name": "type", + "type": "playground_script_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + } + }, + "indexes": { + "ps_organization_id_idx": { + "name": "ps_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ps_created_by_id_idx": { + "name": "ps_created_by_id_idx", + "columns": [ + { + "expression": "created_by_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "playground_scripts_organization_id_organizations_id_fk": { + "name": "playground_scripts_organization_id_organizations_id_fk", + "tableFrom": "playground_scripts", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "playground_scripts_created_by_id_users_id_fk": { + "name": "playground_scripts_created_by_id_users_id_fk", + "tableFrom": "playground_scripts", + "tableTo": "users", + "columnsFrom": [ + "created_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.plugin_image_versions": { + "name": "plugin_image_versions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "schema_version_id": { + "name": "schema_version_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "version": { + "name": "version", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "platform": { + "name": "platform", + "type": "text[]", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "plugin_image_versions_schema_version_id_schema_versions_id_fk": { + "name": "plugin_image_versions_schema_version_id_schema_versions_id_fk", + "tableFrom": "plugin_image_versions", + "tableTo": "schema_versions", + "columnsFrom": [ + "schema_version_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.proposal_checks": { + "name": "proposal_checks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "schema_check_id": { + "name": "schema_check_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "proposal_id": { + "name": "proposal_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "pc_check_id_proposal_id_idx": { + "name": "pc_check_id_proposal_id_idx", + "columns": [ + { + "expression": "schema_check_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "proposal_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "proposal_checks_schema_check_id_schema_checks_id_fk": { + "name": "proposal_checks_schema_check_id_schema_checks_id_fk", + "tableFrom": "proposal_checks", + "tableTo": "schema_checks", + "columnsFrom": [ + "schema_check_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "proposal_checks_proposal_id_proposals_id_fk": { + "name": "proposal_checks_proposal_id_proposals_id_fk", + "tableFrom": "proposal_checks", + "tableTo": "proposals", + "columnsFrom": [ + "proposal_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.proposal_subgraphs": { + "name": "proposal_subgraphs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "proposal_id": { + "name": "proposal_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "subgraph_id": { + "name": "subgraph_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "subgraph_name": { + "name": "subgraph_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "schema_sdl": { + "name": "schema_sdl", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_deleted": { + "name": "is_deleted", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_new": { + "name": "is_new", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "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": false + }, + "is_published": { + "name": "is_published", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "current_schema_version_id": { + "name": "current_schema_version_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "labels": { + "name": "labels", + "type": "text[]", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "proposal_subgraphs_proposal_id_proposals_id_fk": { + "name": "proposal_subgraphs_proposal_id_proposals_id_fk", + "tableFrom": "proposal_subgraphs", + "tableTo": "proposals", + "columnsFrom": [ + "proposal_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "proposal_subgraphs_subgraph_id_subgraphs_id_fk": { + "name": "proposal_subgraphs_subgraph_id_subgraphs_id_fk", + "tableFrom": "proposal_subgraphs", + "tableTo": "subgraphs", + "columnsFrom": [ + "subgraph_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "proposal_subgraphs_current_schema_version_id_schema_versions_id_fk": { + "name": "proposal_subgraphs_current_schema_version_id_schema_versions_id_fk", + "tableFrom": "proposal_subgraphs", + "tableTo": "schema_versions", + "columnsFrom": [ + "current_schema_version_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "proposal_subgraph": { + "name": "proposal_subgraph", + "nullsNotDistinct": false, + "columns": [ + "proposal_id", + "subgraph_name" + ] + } + }, + "checkConstraints": {} + }, + "public.proposals": { + "name": "proposals", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "federated_graph_id": { + "name": "federated_graph_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()" + }, + "created_by_id": { + "name": "created_by_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "state": { + "name": "state", + "type": "proposal_state", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "origin": { + "name": "origin", + "type": "proposal_origin", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'INTERNAL'" + } + }, + "indexes": { + "pr_created_by_id_idx": { + "name": "pr_created_by_id_idx", + "columns": [ + { + "expression": "created_by_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "pr_federated_graph_id_idx": { + "name": "pr_federated_graph_id_idx", + "columns": [ + { + "expression": "federated_graph_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "proposals_federated_graph_id_federated_graphs_id_fk": { + "name": "proposals_federated_graph_id_federated_graphs_id_fk", + "tableFrom": "proposals", + "tableTo": "federated_graphs", + "columnsFrom": [ + "federated_graph_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "proposals_created_by_id_users_id_fk": { + "name": "proposals_created_by_id_users_id_fk", + "tableFrom": "proposals", + "tableTo": "users", + "columnsFrom": [ + "created_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "federated_graph_proposal_name": { + "name": "federated_graph_proposal_name", + "nullsNotDistinct": false, + "columns": [ + "federated_graph_id", + "name" + ] + } + }, + "checkConstraints": {} + }, + "public.protobuf_schema_versions": { + "name": "protobuf_schema_versions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "schema_version_id": { + "name": "schema_version_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "proto_schema": { + "name": "proto_schema", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "proto_mappings": { + "name": "proto_mappings", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "proto_lock": { + "name": "proto_lock", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "protobuf_schema_versions_schema_version_id_schema_versions_id_fk": { + "name": "protobuf_schema_versions_schema_version_id_schema_versions_id_fk", + "tableFrom": "protobuf_schema_versions", + "tableTo": "schema_versions", + "columnsFrom": [ + "schema_version_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.schema_check_change_action": { + "name": "schema_check_change_action", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "schema_check_id": { + "name": "schema_check_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "change_type": { + "name": "change_type", + "type": "schema_change_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "change_message": { + "name": "change_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_breaking": { + "name": "is_breaking", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "schema_check_subgraph_id": { + "name": "schema_check_subgraph_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "scca_schema_check_id_idx": { + "name": "scca_schema_check_id_idx", + "columns": [ + { + "expression": "schema_check_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "schema_check_change_action_schema_check_id_schema_checks_id_fk": { + "name": "schema_check_change_action_schema_check_id_schema_checks_id_fk", + "tableFrom": "schema_check_change_action", + "tableTo": "schema_checks", + "columnsFrom": [ + "schema_check_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "schema_check_change_action_schema_check_subgraph_id_schema_check_subgraphs_id_fk": { + "name": "schema_check_change_action_schema_check_subgraph_id_schema_check_subgraphs_id_fk", + "tableFrom": "schema_check_change_action", + "tableTo": "schema_check_subgraphs", + "columnsFrom": [ + "schema_check_subgraph_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.schema_check_change_operation_usage": { + "name": "schema_check_change_operation_usage", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "schema_check_change_action_id": { + "name": "schema_check_change_action_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "hash": { + "name": "hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "first_seen_at": { + "name": "first_seen_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "federated_graph_id": { + "name": "federated_graph_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "is_safe_override": { + "name": "is_safe_override", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + } + }, + "indexes": { + "sccou_schema_check_change_action_id_idx": { + "name": "sccou_schema_check_change_action_id_idx", + "columns": [ + { + "expression": "schema_check_change_action_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sccou_federated_graph_id_idx": { + "name": "sccou_federated_graph_id_idx", + "columns": [ + { + "expression": "federated_graph_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "schema_check_change_operation_usage_schema_check_change_action_id_schema_check_change_action_id_fk": { + "name": "schema_check_change_operation_usage_schema_check_change_action_id_schema_check_change_action_id_fk", + "tableFrom": "schema_check_change_operation_usage", + "tableTo": "schema_check_change_action", + "columnsFrom": [ + "schema_check_change_action_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "schema_check_change_operation_usage_federated_graph_id_federated_graphs_id_fk": { + "name": "schema_check_change_operation_usage_federated_graph_id_federated_graphs_id_fk", + "tableFrom": "schema_check_change_operation_usage", + "tableTo": "federated_graphs", + "columnsFrom": [ + "federated_graph_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.schema_check_composition": { + "name": "schema_check_composition", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "schema_check_id": { + "name": "schema_check_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "target_id": { + "name": "target_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "composition_errors": { + "name": "composition_errors", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "composition_warnings": { + "name": "composition_warnings", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "composed_schema_sdl": { + "name": "composed_schema_sdl", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "client_schema": { + "name": "client_schema", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "scc_schema_check_id_idx": { + "name": "scc_schema_check_id_idx", + "columns": [ + { + "expression": "schema_check_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "scc_target_id_idx": { + "name": "scc_target_id_idx", + "columns": [ + { + "expression": "target_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "schema_check_composition_schema_check_id_schema_checks_id_fk": { + "name": "schema_check_composition_schema_check_id_schema_checks_id_fk", + "tableFrom": "schema_check_composition", + "tableTo": "schema_checks", + "columnsFrom": [ + "schema_check_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "schema_check_composition_target_id_targets_id_fk": { + "name": "schema_check_composition_target_id_targets_id_fk", + "tableFrom": "schema_check_composition", + "tableTo": "targets", + "columnsFrom": [ + "target_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.schema_check_federated_graphs": { + "name": "schema_check_federated_graphs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "check_id": { + "name": "check_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "federated_graph_id": { + "name": "federated_graph_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "traffic_check_days": { + "name": "traffic_check_days", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "scfg_check_id_idx": { + "name": "scfg_check_id_idx", + "columns": [ + { + "expression": "check_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "scfg_federated_graph_id_idx": { + "name": "scfg_federated_graph_id_idx", + "columns": [ + { + "expression": "federated_graph_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "schema_check_federated_graphs_check_id_schema_checks_id_fk": { + "name": "schema_check_federated_graphs_check_id_schema_checks_id_fk", + "tableFrom": "schema_check_federated_graphs", + "tableTo": "schema_checks", + "columnsFrom": [ + "check_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "schema_check_federated_graphs_federated_graph_id_federated_graphs_id_fk": { + "name": "schema_check_federated_graphs_federated_graph_id_federated_graphs_id_fk", + "tableFrom": "schema_check_federated_graphs", + "tableTo": "federated_graphs", + "columnsFrom": [ + "federated_graph_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.schema_check_graph_pruning_action": { + "name": "schema_check_graph_pruning_action", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "schema_check_id": { + "name": "schema_check_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "graph_pruning_rule": { + "name": "graph_pruning_rule", + "type": "graph_pruning_rules", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "field_path": { + "name": "field_path", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_error": { + "name": "is_error", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "location": { + "name": "location", + "type": "json", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "federated_graph_id": { + "name": "federated_graph_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "schema_check_subgraph_id": { + "name": "schema_check_subgraph_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "scgpa_schema_check_id_idx": { + "name": "scgpa_schema_check_id_idx", + "columns": [ + { + "expression": "schema_check_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "scgpa_federated_graph_id_idx": { + "name": "scgpa_federated_graph_id_idx", + "columns": [ + { + "expression": "federated_graph_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "schema_check_graph_pruning_action_schema_check_id_schema_checks_id_fk": { + "name": "schema_check_graph_pruning_action_schema_check_id_schema_checks_id_fk", + "tableFrom": "schema_check_graph_pruning_action", + "tableTo": "schema_checks", + "columnsFrom": [ + "schema_check_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "schema_check_graph_pruning_action_federated_graph_id_federated_graphs_id_fk": { + "name": "schema_check_graph_pruning_action_federated_graph_id_federated_graphs_id_fk", + "tableFrom": "schema_check_graph_pruning_action", + "tableTo": "federated_graphs", + "columnsFrom": [ + "federated_graph_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "schema_check_graph_pruning_action_schema_check_subgraph_id_schema_check_subgraphs_id_fk": { + "name": "schema_check_graph_pruning_action_schema_check_subgraph_id_schema_check_subgraphs_id_fk", + "tableFrom": "schema_check_graph_pruning_action", + "tableTo": "schema_check_subgraphs", + "columnsFrom": [ + "schema_check_subgraph_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.schema_check_lint_action": { + "name": "schema_check_lint_action", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "schema_check_id": { + "name": "schema_check_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "lint_rule_type": { + "name": "lint_rule_type", + "type": "lint_rules", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_error": { + "name": "is_error", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "location": { + "name": "location", + "type": "json", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "schema_check_subgraph_id": { + "name": "schema_check_subgraph_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "sclact_schema_check_id_idx": { + "name": "sclact_schema_check_id_idx", + "columns": [ + { + "expression": "schema_check_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "schema_check_lint_action_schema_check_id_schema_checks_id_fk": { + "name": "schema_check_lint_action_schema_check_id_schema_checks_id_fk", + "tableFrom": "schema_check_lint_action", + "tableTo": "schema_checks", + "columnsFrom": [ + "schema_check_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "schema_check_lint_action_schema_check_subgraph_id_schema_check_subgraphs_id_fk": { + "name": "schema_check_lint_action_schema_check_subgraph_id_schema_check_subgraphs_id_fk", + "tableFrom": "schema_check_lint_action", + "tableTo": "schema_check_subgraphs", + "columnsFrom": [ + "schema_check_subgraph_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.schema_check_proposal_match": { + "name": "schema_check_proposal_match", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "schema_check_id": { + "name": "schema_check_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "proposal_id": { + "name": "proposal_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "proposal_match": { + "name": "proposal_match", + "type": "boolean", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "scpm_schema_check_id_idx": { + "name": "scpm_schema_check_id_idx", + "columns": [ + { + "expression": "schema_check_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "scpm_proposal_id_idx": { + "name": "scpm_proposal_id_idx", + "columns": [ + { + "expression": "proposal_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "schema_check_proposal_match_schema_check_id_schema_checks_id_fk": { + "name": "schema_check_proposal_match_schema_check_id_schema_checks_id_fk", + "tableFrom": "schema_check_proposal_match", + "tableTo": "schema_checks", + "columnsFrom": [ + "schema_check_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "schema_check_proposal_match_proposal_id_proposals_id_fk": { + "name": "schema_check_proposal_match_proposal_id_proposals_id_fk", + "tableFrom": "schema_check_proposal_match", + "tableTo": "proposals", + "columnsFrom": [ + "proposal_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_schema_check_proposal_match": { + "name": "unique_schema_check_proposal_match", + "nullsNotDistinct": false, + "columns": [ + "schema_check_id", + "proposal_id" + ] + } + }, + "checkConstraints": {} + }, + "public.schema_check_subgraphs": { + "name": "schema_check_subgraphs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "schema_check_id": { + "name": "schema_check_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "subgraph_id": { + "name": "subgraph_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "subgraph_name": { + "name": "subgraph_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "proposed_subgraph_schema_sdl": { + "name": "proposed_subgraph_schema_sdl", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_deleted": { + "name": "is_deleted", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_new": { + "name": "is_new", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "namespace_id": { + "name": "namespace_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "labels": { + "name": "labels", + "type": "text[]", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "scs_schema_check_id_idx": { + "name": "scs_schema_check_id_idx", + "columns": [ + { + "expression": "schema_check_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "scs_subgraph_id_idx": { + "name": "scs_subgraph_id_idx", + "columns": [ + { + "expression": "subgraph_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "schema_check_subgraphs_schema_check_id_schema_checks_id_fk": { + "name": "schema_check_subgraphs_schema_check_id_schema_checks_id_fk", + "tableFrom": "schema_check_subgraphs", + "tableTo": "schema_checks", + "columnsFrom": [ + "schema_check_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "schema_check_subgraphs_subgraph_id_subgraphs_id_fk": { + "name": "schema_check_subgraphs_subgraph_id_subgraphs_id_fk", + "tableFrom": "schema_check_subgraphs", + "tableTo": "subgraphs", + "columnsFrom": [ + "subgraph_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "schema_check_subgraphs_namespace_id_namespaces_id_fk": { + "name": "schema_check_subgraphs_namespace_id_namespaces_id_fk", + "tableFrom": "schema_check_subgraphs", + "tableTo": "namespaces", + "columnsFrom": [ + "namespace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.schema_check_subgraphs_federated_graphs": { + "name": "schema_check_subgraphs_federated_graphs", + "schema": "", + "columns": { + "schema_check_federated_graph_id": { + "name": "schema_check_federated_graph_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "schema_check_subgraph_id": { + "name": "schema_check_subgraph_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "scsfg_schema_check_subgraph_id_idx": { + "name": "scsfg_schema_check_subgraph_id_idx", + "columns": [ + { + "expression": "schema_check_subgraph_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "scsfg_schema_check_federated_graph_id_idx": { + "name": "scsfg_schema_check_federated_graph_id_idx", + "columns": [ + { + "expression": "schema_check_federated_graph_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "schema_check_subgraphs_federated_graphs_schema_check_federated_graph_id_schema_check_federated_graphs_id_fk": { + "name": "schema_check_subgraphs_federated_graphs_schema_check_federated_graph_id_schema_check_federated_graphs_id_fk", + "tableFrom": "schema_check_subgraphs_federated_graphs", + "tableTo": "schema_check_federated_graphs", + "columnsFrom": [ + "schema_check_federated_graph_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "schema_check_subgraphs_federated_graphs_schema_check_subgraph_id_schema_check_subgraphs_id_fk": { + "name": "schema_check_subgraphs_federated_graphs_schema_check_subgraph_id_schema_check_subgraphs_id_fk", + "tableFrom": "schema_check_subgraphs_federated_graphs", + "tableTo": "schema_check_subgraphs", + "columnsFrom": [ + "schema_check_subgraph_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.schema_checks": { + "name": "schema_checks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "target_id": { + "name": "target_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "is_composable": { + "name": "is_composable", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "is_deleted": { + "name": "is_deleted", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "has_breaking_changes": { + "name": "has_breaking_changes", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "has_lint_errors": { + "name": "has_lint_errors", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "has_graph_pruning_errors": { + "name": "has_graph_pruning_errors", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "has_client_traffic": { + "name": "has_client_traffic", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "proposal_match": { + "name": "proposal_match", + "type": "proposal_match", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "client_traffic_check_skipped": { + "name": "client_traffic_check_skipped", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "lint_skipped": { + "name": "lint_skipped", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "graph_pruning_skipped": { + "name": "graph_pruning_skipped", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "composition_skipped": { + "name": "composition_skipped", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "breaking_changes_skipped": { + "name": "breaking_changes_skipped", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "proposed_subgraph_schema_sdl": { + "name": "proposed_subgraph_schema_sdl", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "gh_details": { + "name": "gh_details", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "forced_success": { + "name": "forced_success", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "vcs_context": { + "name": "vcs_context", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "sc_target_id_idx": { + "name": "sc_target_id_idx", + "columns": [ + { + "expression": "target_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "schema_checks_target_id_targets_id_fk": { + "name": "schema_checks_target_id_targets_id_fk", + "tableFrom": "schema_checks", + "tableTo": "targets", + "columnsFrom": [ + "target_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.schema_versions": { + "name": "schema_versions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "target_id": { + "name": "target_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "schema_sdl": { + "name": "schema_sdl", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "client_schema": { + "name": "client_schema", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "is_v2_graph": { + "name": "is_v2_graph", + "type": "boolean", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "sv_organization_id_idx": { + "name": "sv_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sv_target_id_idx": { + "name": "sv_target_id_idx", + "columns": [ + { + "expression": "target_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "schema_versions_organization_id_organizations_id_fk": { + "name": "schema_versions_organization_id_organizations_id_fk", + "tableFrom": "schema_versions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.schema_version_change_action": { + "name": "schema_version_change_action", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "schema_version_id": { + "name": "schema_version_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "change_type": { + "name": "change_type", + "type": "schema_change_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "change_message": { + "name": "change_message", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "svca_schema_version_id_idx": { + "name": "svca_schema_version_id_idx", + "columns": [ + { + "expression": "schema_version_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "schema_version_change_action_schema_version_id_schema_versions_id_fk": { + "name": "schema_version_change_action_schema_version_id_schema_versions_id_fk", + "tableFrom": "schema_version_change_action", + "tableTo": "schema_versions", + "columnsFrom": [ + "schema_version_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.sessions": { + "name": "sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "id_token": { + "name": "id_token", + "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()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "sessions_user_id_idx": { + "name": "sessions_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sessions_user_id_users_id_fk": { + "name": "sessions_user_id_users_id_fk", + "tableFrom": "sessions", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "sessions_user_id_unique": { + "name": "sessions_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "checkConstraints": {} + }, + "public.slack_installations": { + "name": "slack_installations", + "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 + }, + "slack_organization_id": { + "name": "slack_organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "slack_organization_name": { + "name": "slack_organization_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "slack_channel_id": { + "name": "slack_channel_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "slack_channel_name": { + "name": "slack_channel_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "slack_user_id": { + "name": "slack_user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "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": false + } + }, + "indexes": { + "slack_installations_idx": { + "name": "slack_installations_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "slack_organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "slack_channel_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "slackinst_organization_id_idx": { + "name": "slackinst_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "slack_installations_organization_id_organizations_id_fk": { + "name": "slack_installations_organization_id_organizations_id_fk", + "tableFrom": "slack_installations", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.slack_integration_configs": { + "name": "slack_integration_configs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "integration_id": { + "name": "integration_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "endpoint": { + "name": "endpoint", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "slackintconf_integration_id_idx": { + "name": "slackintconf_integration_id_idx", + "columns": [ + { + "expression": "integration_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "slack_integration_configs_integration_id_organization_integrations_id_fk": { + "name": "slack_integration_configs_integration_id_organization_integrations_id_fk", + "tableFrom": "slack_integration_configs", + "tableTo": "organization_integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.slack_schema_update_event_configs": { + "name": "slack_schema_update_event_configs", + "schema": "", + "columns": { + "slack_integration_config_id": { + "name": "slack_integration_config_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "federated_graph_id": { + "name": "federated_graph_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "slacksuec_slack_integration_config_id_idx": { + "name": "slacksuec_slack_integration_config_id_idx", + "columns": [ + { + "expression": "slack_integration_config_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "slacksuec_federated_graph_id_idx": { + "name": "slacksuec_federated_graph_id_idx", + "columns": [ + { + "expression": "federated_graph_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "slack_schema_update_event_configs_slack_integration_config_id_slack_integration_configs_id_fk": { + "name": "slack_schema_update_event_configs_slack_integration_config_id_slack_integration_configs_id_fk", + "tableFrom": "slack_schema_update_event_configs", + "tableTo": "slack_integration_configs", + "columnsFrom": [ + "slack_integration_config_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "slack_schema_update_event_configs_federated_graph_id_federated_graphs_id_fk": { + "name": "slack_schema_update_event_configs_federated_graph_id_federated_graphs_id_fk", + "tableFrom": "slack_schema_update_event_configs", + "tableTo": "federated_graphs", + "columnsFrom": [ + "federated_graph_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "slack_schema_update_event_configs_slack_integration_config_id_federated_graph_id_pk": { + "name": "slack_schema_update_event_configs_slack_integration_config_id_federated_graph_id_pk", + "columns": [ + "slack_integration_config_id", + "federated_graph_id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.subgraph_members": { + "name": "subgraph_members", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "subgraph_id": { + "name": "subgraph_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "unique_subgraph_member_idx": { + "name": "unique_subgraph_member_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "subgraph_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sm_user_id_idx": { + "name": "sm_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sm_subgraph_id_idx": { + "name": "sm_subgraph_id_idx", + "columns": [ + { + "expression": "subgraph_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "subgraph_members_user_id_users_id_fk": { + "name": "subgraph_members_user_id_users_id_fk", + "tableFrom": "subgraph_members", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "subgraph_members_subgraph_id_subgraphs_id_fk": { + "name": "subgraph_members_subgraph_id_subgraphs_id_fk", + "tableFrom": "subgraph_members", + "tableTo": "subgraphs", + "columnsFrom": [ + "subgraph_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.subgraphs": { + "name": "subgraphs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "routing_url": { + "name": "routing_url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "subscription_url": { + "name": "subscription_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "subscription_protocol": { + "name": "subscription_protocol", + "type": "subscription_protocol", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'ws'" + }, + "websocket_subprotocol": { + "name": "websocket_subprotocol", + "type": "websocket_subprotocol", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'auto'" + }, + "schema_version_id": { + "name": "schema_version_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "target_id": { + "name": "target_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "is_feature_subgraph": { + "name": "is_feature_subgraph", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_event_driven_graph": { + "name": "is_event_driven_graph", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "type": { + "name": "type", + "type": "subgraph_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'standard'" + } + }, + "indexes": { + "subgraphs_target_id_idx": { + "name": "subgraphs_target_id_idx", + "columns": [ + { + "expression": "target_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "subgraphs_schema_version_id_idx": { + "name": "subgraphs_schema_version_id_idx", + "columns": [ + { + "expression": "schema_version_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "subgraphs_schema_version_id_schema_versions_id_fk": { + "name": "subgraphs_schema_version_id_schema_versions_id_fk", + "tableFrom": "subgraphs", + "tableTo": "schema_versions", + "columnsFrom": [ + "schema_version_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "subgraphs_target_id_targets_id_fk": { + "name": "subgraphs_target_id_targets_id_fk", + "tableFrom": "subgraphs", + "tableTo": "targets", + "columnsFrom": [ + "target_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.federated_subgraphs": { + "name": "federated_subgraphs", + "schema": "", + "columns": { + "federated_graph_id": { + "name": "federated_graph_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "subgraph_id": { + "name": "subgraph_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "fs_federated_graph_id_idx": { + "name": "fs_federated_graph_id_idx", + "columns": [ + { + "expression": "federated_graph_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "fs_subgraph_id_idx": { + "name": "fs_subgraph_id_idx", + "columns": [ + { + "expression": "subgraph_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "federated_subgraphs_federated_graph_id_federated_graphs_id_fk": { + "name": "federated_subgraphs_federated_graph_id_federated_graphs_id_fk", + "tableFrom": "federated_subgraphs", + "tableTo": "federated_graphs", + "columnsFrom": [ + "federated_graph_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "federated_subgraphs_subgraph_id_subgraphs_id_fk": { + "name": "federated_subgraphs_subgraph_id_subgraphs_id_fk", + "tableFrom": "federated_subgraphs", + "tableTo": "subgraphs", + "columnsFrom": [ + "subgraph_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "federated_subgraphs_federated_graph_id_subgraph_id_pk": { + "name": "federated_subgraphs_federated_graph_id_subgraph_id_pk", + "columns": [ + "federated_graph_id", + "subgraph_id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.target_label_matchers": { + "name": "target_label_matchers", + "schema": "", + "columns": { + "target_id": { + "name": "target_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "label_matcher": { + "name": "label_matcher", + "type": "text[]", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "tlm_target_id_idx": { + "name": "tlm_target_id_idx", + "columns": [ + { + "expression": "target_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "target_label_matchers_target_id_targets_id_fk": { + "name": "target_label_matchers_target_id_targets_id_fk", + "tableFrom": "target_label_matchers", + "tableTo": "targets", + "columnsFrom": [ + "target_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.targets": { + "name": "targets", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "target_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "labels": { + "name": "labels", + "type": "text[]", + "primaryKey": false, + "notNull": false + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "readme": { + "name": "readme", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "namespace_id": { + "name": "namespace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "organization_name_idx": { + "name": "organization_name_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "namespace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "targets_organization_id_idx": { + "name": "targets_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "targets_created_by_idx": { + "name": "targets_created_by_idx", + "columns": [ + { + "expression": "created_by", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "targets_namespace_id_idx": { + "name": "targets_namespace_id_idx", + "columns": [ + { + "expression": "namespace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "targets_organization_id_organizations_id_fk": { + "name": "targets_organization_id_organizations_id_fk", + "tableFrom": "targets", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "targets_created_by_users_id_fk": { + "name": "targets_created_by_users_id_fk", + "tableFrom": "targets", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "targets_namespace_id_namespaces_id_fk": { + "name": "targets_namespace_id_namespaces_id_fk", + "tableFrom": "targets", + "tableTo": "namespaces", + "columnsFrom": [ + "namespace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.users": { + "name": "users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "users_email_unique": { + "name": "users_email_unique", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "checkConstraints": {} + }, + "public.webhook_deliveries": { + "name": "webhook_deliveries", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_by_id": { + "name": "created_by_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "webhook_delivery_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "endpoint": { + "name": "endpoint", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "event_name": { + "name": "event_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "request_headers": { + "name": "request_headers", + "type": "json", + "primaryKey": false, + "notNull": true + }, + "response_headers": { + "name": "response_headers", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "response_status_code": { + "name": "response_status_code", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "response_error_code": { + "name": "response_error_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "response_body": { + "name": "response_body", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "retry_count": { + "name": "retry_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "duration": { + "name": "duration", + "type": "real", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "original_delivery_id": { + "name": "original_delivery_id", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "webhd_organization_id_idx": { + "name": "webhd_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "webhd_created_by_id_idx": { + "name": "webhd_created_by_id_idx", + "columns": [ + { + "expression": "created_by_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "webhook_deliveries_created_by_id_users_id_fk": { + "name": "webhook_deliveries_created_by_id_users_id_fk", + "tableFrom": "webhook_deliveries", + "tableTo": "users", + "columnsFrom": [ + "created_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "webhook_deliveries_organization_id_organizations_id_fk": { + "name": "webhook_deliveries_organization_id_organizations_id_fk", + "tableFrom": "webhook_deliveries", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.webhook_graph_schema_update": { + "name": "webhook_graph_schema_update", + "schema": "", + "columns": { + "webhook_id": { + "name": "webhook_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "federated_graph_id": { + "name": "federated_graph_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "wgsu_webhook_id_idx": { + "name": "wgsu_webhook_id_idx", + "columns": [ + { + "expression": "webhook_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "wgsu_federated_graph_id_idx": { + "name": "wgsu_federated_graph_id_idx", + "columns": [ + { + "expression": "federated_graph_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "webhook_graph_schema_update_webhook_id_organization_webhook_configs_id_fk": { + "name": "webhook_graph_schema_update_webhook_id_organization_webhook_configs_id_fk", + "tableFrom": "webhook_graph_schema_update", + "tableTo": "organization_webhook_configs", + "columnsFrom": [ + "webhook_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "webhook_graph_schema_update_federated_graph_id_federated_graphs_id_fk": { + "name": "webhook_graph_schema_update_federated_graph_id_federated_graphs_id_fk", + "tableFrom": "webhook_graph_schema_update", + "tableTo": "federated_graphs", + "columnsFrom": [ + "federated_graph_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "webhook_graph_schema_update_webhook_id_federated_graph_id_pk": { + "name": "webhook_graph_schema_update_webhook_id_federated_graph_id_pk", + "columns": [ + "webhook_id", + "federated_graph_id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.webhook_proposal_state_update": { + "name": "webhook_proposal_state_update", + "schema": "", + "columns": { + "webhook_id": { + "name": "webhook_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "federated_graph_id": { + "name": "federated_graph_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "wpsu_webhook_id_idx": { + "name": "wpsu_webhook_id_idx", + "columns": [ + { + "expression": "webhook_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "wpsu_federated_graph_id_idx": { + "name": "wpsu_federated_graph_id_idx", + "columns": [ + { + "expression": "federated_graph_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "webhook_proposal_state_update_webhook_id_organization_webhook_configs_id_fk": { + "name": "webhook_proposal_state_update_webhook_id_organization_webhook_configs_id_fk", + "tableFrom": "webhook_proposal_state_update", + "tableTo": "organization_webhook_configs", + "columnsFrom": [ + "webhook_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "webhook_proposal_state_update_federated_graph_id_federated_graphs_id_fk": { + "name": "webhook_proposal_state_update_federated_graph_id_federated_graphs_id_fk", + "tableFrom": "webhook_proposal_state_update", + "tableTo": "federated_graphs", + "columnsFrom": [ + "federated_graph_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "webhook_proposal_state_update_webhook_id_federated_graph_id_pk": { + "name": "webhook_proposal_state_update_webhook_id_federated_graph_id_pk", + "columns": [ + "webhook_id", + "federated_graph_id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + } + }, + "enums": { + "public.git_installation_type": { + "name": "git_installation_type", + "schema": "public", + "values": [ + "PERSONAL", + "ORGANIZATION" + ] + }, + "public.graph_composition_subgraph_change_type": { + "name": "graph_composition_subgraph_change_type", + "schema": "public", + "values": [ + "added", + "removed", + "updated", + "unchanged" + ] + }, + "public.graph_pruning_rules": { + "name": "graph_pruning_rules", + "schema": "public", + "values": [ + "UNUSED_FIELDS", + "DEPRECATED_FIELDS", + "REQUIRE_DEPRECATION_BEFORE_DELETION" + ] + }, + "public.integration_type": { + "name": "integration_type", + "schema": "public", + "values": [ + "slack" + ] + }, + "public.lint_rules": { + "name": "lint_rules", + "schema": "public", + "values": [ + "FIELD_NAMES_SHOULD_BE_CAMEL_CASE", + "TYPE_NAMES_SHOULD_BE_PASCAL_CASE", + "SHOULD_NOT_HAVE_TYPE_PREFIX", + "SHOULD_NOT_HAVE_TYPE_SUFFIX", + "SHOULD_NOT_HAVE_INPUT_PREFIX", + "SHOULD_HAVE_INPUT_SUFFIX", + "SHOULD_NOT_HAVE_ENUM_PREFIX", + "SHOULD_NOT_HAVE_ENUM_SUFFIX", + "SHOULD_NOT_HAVE_INTERFACE_PREFIX", + "SHOULD_NOT_HAVE_INTERFACE_SUFFIX", + "ENUM_VALUES_SHOULD_BE_UPPER_CASE", + "ORDER_FIELDS", + "ORDER_ENUM_VALUES", + "ORDER_DEFINITIONS", + "ALL_TYPES_REQUIRE_DESCRIPTION", + "DISALLOW_CASE_INSENSITIVE_ENUM_VALUES", + "NO_TYPENAME_PREFIX_IN_TYPE_FIELDS", + "REQUIRE_DEPRECATION_REASON" + ] + }, + "public.lint_severity": { + "name": "lint_severity", + "schema": "public", + "values": [ + "warn", + "error" + ] + }, + "public.member_role": { + "name": "member_role", + "schema": "public", + "values": [ + "admin", + "developer", + "viewer" + ] + }, + "public.organization_role": { + "name": "organization_role", + "schema": "public", + "values": [ + "organization-admin", + "organization-developer", + "organization-viewer", + "organization-apikey-manager", + "namespace-admin", + "namespace-viewer", + "graph-admin", + "graph-viewer", + "subgraph-admin", + "subgraph-publisher", + "subgraph-checker", + "subgraph-viewer" + ] + }, + "public.playground_script_type": { + "name": "playground_script_type", + "schema": "public", + "values": [ + "pre-flight", + "pre-operation", + "post-operation" + ] + }, + "public.proposal_match": { + "name": "proposal_match", + "schema": "public", + "values": [ + "success", + "warn", + "error" + ] + }, + "public.proposal_origin": { + "name": "proposal_origin", + "schema": "public", + "values": [ + "INTERNAL", + "EXTERNAL" + ] + }, + "public.proposal_state": { + "name": "proposal_state", + "schema": "public", + "values": [ + "DRAFT", + "APPROVED", + "PUBLISHED", + "CLOSED" + ] + }, + "public.schema_change_type": { + "name": "schema_change_type", + "schema": "public", + "values": [ + "FIELD_ARGUMENT_DESCRIPTION_CHANGED", + "FIELD_ARGUMENT_DEFAULT_CHANGED", + "FIELD_ARGUMENT_TYPE_CHANGED", + "DIRECTIVE_REMOVED", + "DIRECTIVE_ADDED", + "DIRECTIVE_DESCRIPTION_CHANGED", + "DIRECTIVE_LOCATION_ADDED", + "DIRECTIVE_LOCATION_REMOVED", + "DIRECTIVE_ARGUMENT_ADDED", + "DIRECTIVE_ARGUMENT_REMOVED", + "DIRECTIVE_ARGUMENT_DESCRIPTION_CHANGED", + "DIRECTIVE_ARGUMENT_DEFAULT_VALUE_CHANGED", + "DIRECTIVE_ARGUMENT_TYPE_CHANGED", + "ENUM_VALUE_REMOVED", + "ENUM_VALUE_ADDED", + "ENUM_VALUE_DESCRIPTION_CHANGED", + "ENUM_VALUE_DEPRECATION_REASON_CHANGED", + "ENUM_VALUE_DEPRECATION_REASON_ADDED", + "ENUM_VALUE_DEPRECATION_REASON_REMOVED", + "FIELD_REMOVED", + "FIELD_ADDED", + "FIELD_DESCRIPTION_CHANGED", + "FIELD_DESCRIPTION_ADDED", + "FIELD_DESCRIPTION_REMOVED", + "FIELD_DEPRECATION_ADDED", + "FIELD_DEPRECATION_REMOVED", + "FIELD_DEPRECATION_REASON_CHANGED", + "FIELD_DEPRECATION_REASON_ADDED", + "FIELD_DEPRECATION_REASON_REMOVED", + "FIELD_TYPE_CHANGED", + "FIELD_ARGUMENT_ADDED", + "FIELD_ARGUMENT_REMOVED", + "INPUT_FIELD_REMOVED", + "INPUT_FIELD_ADDED", + "INPUT_FIELD_DESCRIPTION_ADDED", + "INPUT_FIELD_DESCRIPTION_REMOVED", + "INPUT_FIELD_DESCRIPTION_CHANGED", + "INPUT_FIELD_DEFAULT_VALUE_CHANGED", + "INPUT_FIELD_TYPE_CHANGED", + "OBJECT_TYPE_INTERFACE_ADDED", + "OBJECT_TYPE_INTERFACE_REMOVED", + "SCHEMA_QUERY_TYPE_CHANGED", + "SCHEMA_MUTATION_TYPE_CHANGED", + "SCHEMA_SUBSCRIPTION_TYPE_CHANGED", + "TYPE_REMOVED", + "TYPE_ADDED", + "TYPE_KIND_CHANGED", + "TYPE_DESCRIPTION_CHANGED", + "TYPE_DESCRIPTION_REMOVED", + "TYPE_DESCRIPTION_ADDED", + "UNION_MEMBER_REMOVED", + "UNION_MEMBER_ADDED", + "DIRECTIVE_USAGE_UNION_MEMBER_ADDED", + "DIRECTIVE_USAGE_UNION_MEMBER_REMOVED", + "DIRECTIVE_USAGE_ENUM_ADDED", + "DIRECTIVE_USAGE_ENUM_REMOVED", + "DIRECTIVE_USAGE_ENUM_VALUE_ADDED", + "DIRECTIVE_USAGE_ENUM_VALUE_REMOVED", + "DIRECTIVE_USAGE_INPUT_OBJECT_ADDED", + "DIRECTIVE_USAGE_INPUT_OBJECT_REMOVED", + "DIRECTIVE_USAGE_FIELD_ADDED", + "DIRECTIVE_USAGE_FIELD_REMOVED", + "DIRECTIVE_USAGE_SCALAR_ADDED", + "DIRECTIVE_USAGE_SCALAR_REMOVED", + "DIRECTIVE_USAGE_OBJECT_ADDED", + "DIRECTIVE_USAGE_OBJECT_REMOVED", + "DIRECTIVE_USAGE_INTERFACE_ADDED", + "DIRECTIVE_USAGE_INTERFACE_REMOVED", + "DIRECTIVE_USAGE_ARGUMENT_DEFINITION_ADDED", + "DIRECTIVE_USAGE_ARGUMENT_DEFINITION_REMOVED", + "DIRECTIVE_USAGE_SCHEMA_ADDED", + "DIRECTIVE_USAGE_SCHEMA_REMOVED", + "DIRECTIVE_USAGE_FIELD_DEFINITION_ADDED", + "DIRECTIVE_USAGE_FIELD_DEFINITION_REMOVED", + "DIRECTIVE_USAGE_INPUT_FIELD_DEFINITION_ADDED", + "DIRECTIVE_USAGE_INPUT_FIELD_DEFINITION_REMOVED" + ] + }, + "public.subgraph_type": { + "name": "subgraph_type", + "schema": "public", + "values": [ + "standard", + "grpc_plugin", + "grpc_service" + ] + }, + "public.subscription_protocol": { + "name": "subscription_protocol", + "schema": "public", + "values": [ + "ws", + "sse", + "sse_post" + ] + }, + "public.status": { + "name": "status", + "schema": "public", + "values": [ + "incomplete", + "incomplete_expired", + "trialing", + "active", + "past_due", + "canceled", + "unpaid", + "paused" + ] + }, + "public.target_type": { + "name": "target_type", + "schema": "public", + "values": [ + "federated", + "subgraph" + ] + }, + "public.webhook_delivery_type": { + "name": "webhook_delivery_type", + "schema": "public", + "values": [ + "webhook", + "slack", + "admission" + ] + }, + "public.websocket_subprotocol": { + "name": "websocket_subprotocol", + "schema": "public", + "values": [ + "auto", + "graphql-ws", + "graphql-transport-ws" + ] + } + }, + "schemas": {}, + "sequences": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/controlplane/migrations/meta/_journal.json b/controlplane/migrations/meta/_journal.json index 5db5e27483..73698dbd95 100644 --- a/controlplane/migrations/meta/_journal.json +++ b/controlplane/migrations/meta/_journal.json @@ -932,6 +932,13 @@ "when": 1758819671620, "tag": "0132_slippery_payback", "breakpoints": true + }, + { + "idx": 133, + "version": "7", + "when": 1763679951539, + "tag": "0133_foamy_vargas", + "breakpoints": true } ] } \ No newline at end of file diff --git a/controlplane/src/core/bufservices/user/inviteUser.ts b/controlplane/src/core/bufservices/user/inviteUser.ts index 3cde09bdf1..33c119e992 100644 --- a/controlplane/src/core/bufservices/user/inviteUser.ts +++ b/controlplane/src/core/bufservices/user/inviteUser.ts @@ -3,13 +3,10 @@ import { HandlerContext } from '@connectrpc/connect'; import { EnumStatusCode } from '@wundergraph/cosmo-connect/dist/common/common_pb'; import { InviteUserRequest, InviteUserResponse } from '@wundergraph/cosmo-connect/dist/platform/v1/platform_pb'; import { AuditLogRepository } from '../../repositories/AuditLogRepository.js'; -import { OrganizationInvitationRepository } from '../../repositories/OrganizationInvitationRepository.js'; -import { OrganizationRepository } from '../../repositories/OrganizationRepository.js'; -import { UserRepository } from '../../repositories/UserRepository.js'; import type { RouterOptions } from '../../routes.js'; import { enrichLogger, getLogger, handleError } from '../../util.js'; -import { OrganizationGroupRepository } from '../../repositories/OrganizationGroupRepository.js'; import { UnauthorizedError } from '../../errors/errors.js'; +import { UserInviteService } from '../../services/UserInviteService.js'; export function inviteUser( opts: RouterOptions, @@ -22,191 +19,29 @@ export function inviteUser( const authContext = await opts.authenticator.authenticate(ctx.requestHeader); logger = enrichLogger(ctx, logger, authContext); - const userRepo = new UserRepository(logger, opts.db); - const orgRepo = new OrganizationRepository(logger, opts.db, opts.billingDefaultPlanId); - const orgGroupRepo = new OrganizationGroupRepository(opts.db); - const orgInvitationRepo = new OrganizationInvitationRepository(logger, opts.db, opts.billingDefaultPlanId); const auditLogRepo = new AuditLogRepository(opts.db); - if (authContext.organizationDeactivated || !authContext.rbac.isOrganizationAdminOrDeveloper) { throw new UnauthorizedError(); } - const organization = await orgRepo.byId(authContext.organizationId); - if (!organization) { - return { - response: { - code: EnumStatusCode.ERR_NOT_FOUND, - details: `Organization not found`, - }, - }; - } - - const memberCount = await orgRepo.memberCount(authContext.organizationId); - const usersFeature = await orgRepo.getFeature({ - organizationId: authContext.organizationId, - featureId: 'users', + const service = new UserInviteService({ + db: opts.db, + logger, + keycloakRealm: opts.keycloakRealm, + keycloak: opts.keycloakClient, + mailer: opts.mailerClient, }); - const limit = usersFeature?.limit === -1 ? undefined : usersFeature?.limit; - - if (limit && memberCount >= limit) { - return { - response: { - code: EnumStatusCode.ERR_LIMIT_REACHED, - details: `The user limit for this organization has been reached`, - }, - }; - } - - await opts.keycloakClient.authenticateClient(); - - const keycloakUser = await opts.keycloakClient.client.users.find({ - max: 1, - email: req.email, - realm: opts.keycloakRealm, - exact: true, - }); - - let keycloakUserID; - - if (keycloakUser.length === 0) { - keycloakUserID = await opts.keycloakClient.addKeycloakUser({ - email: req.email, - isPasswordTemp: true, - realm: opts.keycloakRealm, - }); - } else { - keycloakUserID = keycloakUser[0].id; - } - - const user = await userRepo.byId(keycloakUserID!); - - const groups: string[] = []; - for (const groupId of req.groups) { - const group = await orgGroupRepo.byId({ - organizationId: authContext.organizationId, - groupId, - }); - - if (!group) { - return { - response: { - code: EnumStatusCode.ERR_NOT_FOUND, - details: 'Group not found', - }, - }; - } - - groups.push(group.groupId); - } - - if (user) { - const orgMember = await orgRepo.getOrganizationMember({ - organizationID: authContext.organizationId, - userID: user.id, - }); - if (orgMember) { - return { - response: { - code: EnumStatusCode.ERR_ALREADY_EXISTS, - details: `${req.email} is already a member of this organization`, - }, - }; - } - - const orgInvitation = await orgInvitationRepo.getPendingOrganizationInvitation({ - organizationID: authContext.organizationId, - userID: user.id, - }); - if (orgInvitation) { - const userMemberships = await orgRepo.memberships({ userId: user.id }); - // if the user memberships are empty, that means the user has not logged in till now, - // so we send the user a mail form keycloak - if (userMemberships.length === 0) { - await opts.keycloakClient.executeActionsEmail({ - userID: user.id, - redirectURI: `${process.env.WEB_BASE_URL}/login?redirectURL=${process.env.WEB_BASE_URL}/account/invitations`, - realm: opts.keycloakRealm, - }); - } else { - // the user has already logged in, so we send our custom org invitation email - // eslint-disable-next-line no-lonely-if - if (opts.mailerClient) { - await opts.mailerClient.sendInviteEmail({ - inviteLink: `${process.env.WEB_BASE_URL}/account/invitations`, - organizationName: organization.name, - receiverEmail: req.email, - invitedBy: orgInvitation.invitedBy, - }); - } - } - - await auditLogRepo.addAuditLog({ - organizationId: authContext.organizationId, - organizationSlug: organization.slug, - auditAction: 'organization_invitation.created', - action: 'created', - actorId: authContext.userId, - auditableDisplayName: req.email, - auditableType: 'user', - actorDisplayName: authContext.userDisplayName, - apiKeyName: authContext.apiKeyName, - actorType: authContext.auth === 'api_key' ? 'api_key' : 'user', - }); - - return { - response: { - code: EnumStatusCode.OK, - details: 'Invited member successfully.', - }, - }; - } - } - - // We don't need the group when re-inviting a member - if (groups.length === 0) { - return { - response: { - code: EnumStatusCode.ERR_NOT_FOUND, - details: 'No group was provided', - }, - }; - } - - const userMemberships = await orgRepo.memberships({ userId: keycloakUserID! }); - // to verify if the user is a new user or not, we check the memberships of the user - if (userMemberships.length > 0) { - if (opts.mailerClient) { - const inviter = await userRepo.byId(authContext.userId); - await opts.mailerClient.sendInviteEmail({ - inviteLink: `${process.env.WEB_BASE_URL}/account/invitations`, - organizationName: organization.name, - receiverEmail: req.email, - invitedBy: inviter?.email, - }); - } - } else { - await opts.keycloakClient.executeActionsEmail({ - userID: keycloakUserID!, - redirectURI: `${process.env.WEB_BASE_URL}/login?redirectURL=${process.env.WEB_BASE_URL}/account/invitations`, - realm: opts.keycloakRealm, - }); - } - - // TODO: rate limit this - await orgInvitationRepo.inviteUser({ - email: req.email, - userId: keycloakUserID!, + await service.inviteUser({ organizationId: authContext.organizationId, - dbUser: user, inviterUserId: authContext.userId, - groups, + email: req.email, + groups: req.groups, }); await auditLogRepo.addAuditLog({ organizationId: authContext.organizationId, - organizationSlug: organization.slug, + organizationSlug: authContext.organizationSlug, auditAction: 'organization_invitation.created', action: 'created', actorId: authContext.userId, diff --git a/controlplane/src/core/build-server.ts b/controlplane/src/core/build-server.ts index 4ecb4e8173..9bb8db3688 100644 --- a/controlplane/src/core/build-server.ts +++ b/controlplane/src/core/build-server.ts @@ -460,6 +460,7 @@ export default async function build(opts: BuildConfig) { await fastify.register(ScimController, { organizationRepository, + mailer: mailerClient, userRepository: userRepo, apiKeyRepository, authenticator: apiKeyAuth, diff --git a/controlplane/src/core/controllers/auth.ts b/controlplane/src/core/controllers/auth.ts index 448e482410..1dd52acc75 100644 --- a/controlplane/src/core/controllers/auth.ts +++ b/controlplane/src/core/controllers/auth.ts @@ -1,7 +1,7 @@ import { FastifyPluginCallback } from 'fastify'; import fp from 'fastify-plugin'; import { PostgresJsDatabase } from 'drizzle-orm/postgres-js'; -import { eq, sql } from 'drizzle-orm'; +import { and, eq, sql } from 'drizzle-orm'; import { lru } from 'tiny-lru'; import { uid } from 'uid'; import { PlatformEventName } from '@wundergraph/cosmo-connect/dist/notifications/events_pb'; @@ -271,7 +271,7 @@ const plugin: FastifyPluginCallback = function Auth(fasti const existingMemberships = await tx .select({ one: sql`1`.as('one') }) .from(organizationsMembers) - .where(eq(organizationsMembers.userId, userId)) + .where(and(eq(organizationsMembers.userId, userId), eq(organizationsMembers.active, true))) .limit(1) .execute(); diff --git a/controlplane/src/core/controllers/scim.ts b/controlplane/src/core/controllers/scim.ts index 8e55550e47..a15a70e5b3 100644 --- a/controlplane/src/core/controllers/scim.ts +++ b/controlplane/src/core/controllers/scim.ts @@ -1,12 +1,17 @@ import { PostgresJsDatabase } from 'drizzle-orm/postgres-js'; -import { FastifyPluginCallback, FastifyRequest } from 'fastify'; +import { FastifyPluginCallback, FastifyReply, FastifyRequest } from 'fastify'; import fp from 'fastify-plugin'; +import { EnumStatusCode } from '@wundergraph/cosmo-connect/dist/common/common_pb'; import * as schema from '../../db/schema.js'; import { OrganizationRepository } from '../repositories/OrganizationRepository.js'; import { UserRepository } from '../repositories/UserRepository.js'; import ApiKeyAuthenticator, { ApiKeyAuthContext } from '../services/ApiKeyAuthenticator.js'; import Keycloak from '../services/Keycloak.js'; import { ApiKeyRepository } from '../repositories/ApiKeyRepository.js'; +import Mailer from '../services/Mailer.js'; +import { AddAuditLogInput, AuditLogRepository } from '../repositories/AuditLogRepository.js'; +import { UserInviteService } from '../services/UserInviteService.js'; +import { isPublicError } from '../errors/errors.js'; export type ScimControllerOptions = { db: PostgresJsDatabase; @@ -16,8 +21,64 @@ export type ScimControllerOptions = { authenticator: ApiKeyAuthenticator; keycloakClient: Keycloak; keycloakRealm: string; + mailer?: Mailer; }; +type ListUsersRequest = FastifyRequest<{ + Querystring: { + filter?: string; + startIndex?: number; + count?: number; + }; +}>; + +type GetUserRequest = FastifyRequest<{ + Params: { userID: string }; +}>; + +type CreateUserRequest = FastifyRequest<{ + Body: { + schemas: string[]; + userName: string; + name: { givenName: string; familyName: string }; + emails: { primary: boolean; value: string }[]; + password: string; + displayName: string; + groups: string[]; + active: boolean; + locale: string; + externalId: string; + }; +}>; + +type UpdateUserRequest = FastifyRequest<{ + Params: { userID: string }; + Body: { + schemas: string[]; + id: string; + userName: string; + name: { givenName?: string; familyName?: string }; + emails: { primary: boolean; value: string }[]; + password: string; + groups: string[]; + active: boolean; + }; +}>; + +type PatchOperationType = 'add' | 'replace' | 'remove'; + +type PatchOperation = + | { op: PatchOperationType; path: string; value: string } + | { op: PatchOperationType; value: Record }; + +type PatchUserRequest = FastifyRequest<{ + Params: { userID: string }; + Body: { + schemas: string[]; + Operations: PatchOperation[]; + }; +}>; + declare module 'fastify' { interface FastifyRequest { authContext: ApiKeyAuthContext; @@ -34,7 +95,7 @@ const ScimError = ({ detail, status }: { detail: string; status: number }) => { // https://developer.okta.com/docs/reference/scim/scim-20/ const plugin: FastifyPluginCallback = function Scim(fastify, opts, done) { - fastify.addContentTypeParser('application/scim+json', { parseAs: 'string' }, function (req, body, done) { + fastify.addContentTypeParser('application/scim+json', { parseAs: 'string' }, function (_, body, done) { try { const json = JSON.parse(body.toString()); done(null, json); @@ -93,11 +154,12 @@ const plugin: FastifyPluginCallback = function Scim(fasti } }); - fastify.get('/', (req, res) => { + fastify.get('/', (_: FastifyRequest, res: FastifyReply) => { return res.code(200).send('SCIM'); }); - fastify.get<{ Querystring: { filter?: string; startIndex?: number; count?: number } }>('/Users', async (req, res) => { + // list existing users + fastify.get('/Users', async (req: ListUsersRequest, res: FastifyReply) => { const authContext = req.authContext; const filter = req.query?.filter; @@ -197,11 +259,11 @@ const plugin: FastifyPluginCallback = function Scim(fasti }); }); - fastify.get('/Users/:userID', async (req: FastifyRequest<{ Params: { userID: string } }>, res) => { + // fetch user + fastify.get('/Users/:userID', async (req: GetUserRequest, res: FastifyReply) => { const authContext = req.authContext; const userID = req.params.userID; - const user = await opts.organizationRepository.getOrganizationMember({ organizationID: authContext.organizationId, userID, @@ -237,7 +299,7 @@ const plugin: FastifyPluginCallback = function Scim(fasti givenName: keycloakUsers[0].firstName || '', familyName: keycloakUsers[0].lastName || '', }, - active: keycloakUsers[0].enabled, + active: user.active, emails: [ { primary: true, @@ -252,166 +314,47 @@ const plugin: FastifyPluginCallback = function Scim(fasti }); // create a user - fastify.post( - '/Users', - async ( - req: FastifyRequest<{ - Body: { - schemas: string[]; - userName: string; - name: { givenName: string; familyName: string }; - emails: { primary: boolean; value: string }[]; - password: string; - displayName: string; - groups: string[]; - active: boolean; - locale: string; - externalId: string; - }; - }>, - res, - ) => { - const authContext = req.authContext; - - const { userName, name, emails, password, displayName, groups, active, locale, externalId } = req.body; - - const email = emails.find((e) => e.primary)?.value || userName; - - const org = await opts.organizationRepository.byId(authContext.organizationId); - if (!org) { - return res.code(404).send( - ScimError({ - detail: 'Organization not found.', - status: 404, - }), - ); - } - - // Ensure that the organization has been linked to a Keycloak group - if (!org.kcGroupId) { - return res.code(500).send( - ScimError({ - detail: `Organization group "${org.slug}" not found`, - status: 500, - }), - ); - } - - // Make sure that the group exists in Keycloak - const kcGroup = await opts.keycloakClient.client.groups.findOne({ - realm: opts.keycloakRealm, - id: org.kcGroupId, - }); + fastify.post('/Users', async (req: CreateUserRequest, res: FastifyReply) => { + const authContext = req.authContext; - if (!kcGroup) { - return res.code(500).send( - ScimError({ - detail: `Organization group "${org.slug}" not found`, - status: 500, - }), - ); - } + const { userName, name, emails, password, displayName, groups, active, locale, externalId } = req.body; + const email = emails.find((e) => e.primary)?.value || userName; - // Check whether the organization member already exists - const orgMember = await opts.organizationRepository.getOrganizationMemberByEmail({ - organizationID: authContext.organizationId, - userEmail: email, + try { + const service = new UserInviteService({ + db: opts.db, + logger: req.log, + keycloakRealm: opts.keycloakRealm, + keycloak: opts.keycloakClient, + mailer: opts.mailer, }); - if (orgMember) { - return res.code(409).send( - ScimError({ - detail: 'User is already a part of the organization.', - status: 409, - }), - ); - } - - // fetching the org from keycloak - const user = await opts.userRepository.byEmail(email); - const keycloakUsers = await opts.keycloakClient.client.users.find({ - realm: opts.keycloakRealm, + const userId = await service.inviteUser({ + organizationId: authContext.organizationId, + inviterUserId: authContext.userId, email, - exact: true, - }); - - if (user) { - if (keycloakUsers.length === 0) { - // return 500 as the user should exist on keycloak if it exists in the db - return res.code(500).send( - ScimError({ - detail: `User '${user.email}' not found on keycloak`, - status: 500, - }), - ); - } else { - await opts.keycloakClient.client.users.addToGroup({ - id: user.id, - realm: opts.keycloakRealm, - groupId: org.kcGroupId!, - }); - - await opts.organizationRepository.addOrganizationMember({ - userID: user.id, - organizationID: authContext.organizationId, - }); - - return res.code(201).send({ - schemas: ['urn:ietf:params:scim:schemas:core:2.0:User'], - id: user.id, - userName: email, - name, - emails, - displayName, - locale, - externalId, - active, - groups, - meta: { - resourceType: 'User', - }, - }); - } - } - - let keycloakUserID = ''; - try { - if (keycloakUsers.length === 0) { - keycloakUserID = await opts.keycloakClient.addKeycloakUser({ - realm: opts.keycloakRealm, - firstName: name.givenName, - lastName: name.familyName, - email, - password, - isPasswordTemp: false, - }); - } else { - keycloakUserID = keycloakUsers[0].id!; - } - } catch (err: any) { - return res.code(500).send( - ScimError({ - detail: err.responseData.errorMessage || err.message, - status: 500, - }), - ); - } - - await opts.keycloakClient.client.users.addToGroup({ - id: keycloakUserID, - realm: opts.keycloakRealm, - groupId: org.kcGroupId!, + firstName: name.givenName, + lastName: name.familyName, + password, }); - await opts.userRepository.addUser({ id: keycloakUserID, email }); - await opts.organizationRepository.addOrganizationMember({ - userID: keycloakUserID, - organizationID: authContext.organizationId, + const auditLogRepo = new AuditLogRepository(opts.db); + await auditLogRepo.addAuditLog({ + organizationId: authContext.organizationId, + organizationSlug: authContext.organizationSlug, + auditAction: 'scim.organization_invitation_created', + action: 'created', + actorId: authContext.userId, + auditableDisplayName: email, + auditableType: 'user', + actorDisplayName: authContext.userDisplayName, + apiKeyName: authContext.apiKeyName, + actorType: authContext.auth === 'api_key' ? 'api_key' : 'user', }); return res.code(201).send({ schemas: ['urn:ietf:params:scim:schemas:core:2.0:User'], - id: keycloakUserID, + id: userId, userName: email, name, emails, @@ -424,134 +367,204 @@ const plugin: FastifyPluginCallback = function Scim(fasti resourceType: 'User', }, }); - }, - ); - - // update a user - fastify.put( - '/Users/:userID', - async ( - req: FastifyRequest<{ - Params: { userID: string }; - Body: { - schemas: string[]; - id: string; - userName: string; - name: { givenName?: string; familyName?: string }; - emails: { primary: boolean; value: string }[]; - password: string; - groups: string[]; - active: boolean; - }; - }>, - res, - ) => { - const authContext = req.authContext; - - const userID = req.params.userID; - const { name, emails, password, groups, active } = req.body; - - const user = await opts.organizationRepository.getOrganizationMember({ - organizationID: authContext.organizationId, - userID, - }); - - if (!user) { - return res.code(404).send( + } catch (err: unknown) { + if (isPublicError(err)) { + return res.code(400).send( ScimError({ - detail: 'User not found', - status: 404, + detail: err.message, + status: err.code === EnumStatusCode.ERR_ALREADY_EXISTS ? 409 : 500, }), ); - } - - const keycloakUsers = await opts.keycloakClient.client.users.find({ - realm: opts.keycloakRealm, - email: user.email, - }); - if (keycloakUsers.length === 0) { - return res.code(404).send( + } else if (err instanceof Error) { + return res.code(500).send( ScimError({ - detail: 'User not found', - status: 404, + detail: err.message, + status: 500, }), ); } + } - await opts.keycloakClient.updateKeycloakUser({ - id: userID, - enabled: active, - firstName: name.givenName, - lastName: name.familyName, - realm: opts.keycloakRealm, - groups, - password, - }); + return res.code(500).send( + ScimError({ + detail: 'Oh no! Something went wrong while creating the user.', + status: 500, + }), + ); + }); - await opts.userRepository.updateUser({ id: userID, active }); + // update a user + fastify.put('/Users/:userID', async (req: UpdateUserRequest, res: FastifyReply) => { + const authContext = req.authContext; - return res.code(200).send({ - schemas: ['urn:ietf:params:scim:schemas:core:2.0:User'], - id: userID, - userName: user.email, - name, - emails, + const userID = req.params.userID; + const { name, emails, groups, active } = req.body; + + const user = await opts.organizationRepository.getOrganizationMember({ + organizationID: authContext.organizationId, + userID, + }); + + if (!user) { + return res.code(404).send( + ScimError({ + detail: 'User not found', + status: 404, + }), + ); + } + + const keycloakUsers = await opts.keycloakClient.client.users.find({ + realm: opts.keycloakRealm, + email: user.email, + }); + if (keycloakUsers.length === 0) { + return res.code(404).send( + ScimError({ + detail: 'User not found', + status: 404, + }), + ); + } + + // Update user details in Keycloak + const auditLogRepo = new AuditLogRepository(opts.db); + await opts.keycloakClient.updateKeycloakUser({ + id: userID, + firstName: name.givenName, + lastName: name.familyName, + realm: opts.keycloakRealm, + groups, + }); + + await auditLogRepo.addAuditLog({ + organizationId: authContext.organizationId, + organizationSlug: authContext.organizationSlug, + auditAction: 'scim.update_organization_member', + action: 'updated', + actorId: authContext.userId, + auditableDisplayName: user.email, + auditableType: 'user', + actorDisplayName: authContext.userDisplayName, + apiKeyName: authContext.apiKeyName, + actorType: authContext.auth === 'api_key' ? 'api_key' : 'user', + }); + + // If the active status has changed, update the organization member's active status to reflect it + if (user.active !== active) { + await opts.organizationRepository.setOrganizationMemberActive({ + id: user.orgMemberID, + organizationId: authContext.organizationId, active, - groups, - meta: { - resourceType: 'User', - }, }); - }, - ); - // remove the user from the org - fastify.patch( - '/Users/:userID', - async ( - req: FastifyRequest<{ - Params: { userID: string }; - Body: { schemas: string[]; Operations: { op: string; value: { active: boolean } }[] }; - }>, - res, - ) => { - const authContext = req.authContext; - - const userID = req.params.userID; - - const orgMember = await opts.organizationRepository.getOrganizationMember({ - organizationID: authContext.organizationId, - userID, + await auditLogRepo.addAuditLog({ + organizationId: authContext.organizationId, + organizationSlug: authContext.organizationSlug, + auditAction: active ? 'scim.activate_organization_member' : 'scim.deactivate_organization_member', + action: 'updated', + actorId: authContext.userId, + auditableDisplayName: user.email, + auditableType: 'user', + actorDisplayName: authContext.userDisplayName, + apiKeyName: authContext.apiKeyName, + actorType: authContext.auth === 'api_key' ? 'api_key' : 'user', }); - if (!orgMember) { - return res.code(404).send( - ScimError({ - detail: 'User not found', - status: 404, - }), - ); - } + } - const operations = req.body.Operations; + return res.code(200).send({ + schemas: ['urn:ietf:params:scim:schemas:core:2.0:User'], + id: userID, + userName: user.email, + name, + emails, + active, + groups, + meta: { + resourceType: 'User', + }, + }); + }); - for (const operation of operations) { - const value = operation.value; - if ('active' in value) { - const active = value.active; + // remove the user from the org + fastify.patch('/Users/:userID', async (req: PatchUserRequest, res: FastifyReply) => { + const authContext = req.authContext; - await opts.keycloakClient.updateKeycloakUser({ - id: userID, - enabled: active, - realm: opts.keycloakRealm, + const userID = req.params.userID; + const orgMember = await opts.organizationRepository.getOrganizationMember({ + organizationID: authContext.organizationId, + userID, + }); + if (!orgMember) { + return res.code(404).send( + ScimError({ + detail: 'User not found', + status: 404, + }), + ); + } + + const auditLogs: AddAuditLogInput[] = []; + const partialAudit: Omit = { + organizationId: authContext.organizationId, + organizationSlug: authContext.organizationSlug, + actorId: authContext.userId, + actorDisplayName: authContext.userDisplayName, + auditableDisplayName: orgMember.email, + auditableType: 'user', + apiKeyName: authContext.apiKeyName, + actorType: authContext.auth === 'api_key' ? 'api_key' : 'user', + }; + + const operations = req.body.Operations; + if (!operations || operations.length === 0) { + return res.code(204).send(); + } + + for (const operation of operations) { + if (operation.op?.toLowerCase() !== 'replace') { + // We only care about the `replace` operation + continue; + } + + if ('path' in operation) { + if (operation.path.toLowerCase() === 'active') { + const active = operation.value?.toLowerCase() === 'true'; + await opts.organizationRepository.setOrganizationMemberActive({ + id: orgMember.orgMemberID, + organizationId: authContext.organizationId, + active, }); - await opts.userRepository.updateUser({ id: userID, active }); + auditLogs.push({ + ...partialAudit, + auditAction: active ? 'scim.activate_organization_member' : 'scim.deactivate_organization_member', + action: 'updated', + }); } + } else if ('active' in operation.value && typeof operation.value.active === 'boolean') { + const active = operation.value.active; + await opts.organizationRepository.setOrganizationMemberActive({ + id: orgMember.orgMemberID, + organizationId: authContext.organizationId, + active, + }); + + auditLogs.push({ + ...partialAudit, + auditAction: active ? 'scim.activate_organization_member' : 'scim.deactivate_organization_member', + action: 'updated', + }); } + } - return res.code(204).send(); - }, - ); + if (auditLogs.length > 0) { + const auditLogRepo = new AuditLogRepository(opts.db); + await auditLogRepo.addAuditLog(...auditLogs); + } + + return res.code(204).send(); + }); done(); }; diff --git a/controlplane/src/core/errors/errors.ts b/controlplane/src/core/errors/errors.ts index 3bf208e017..c7dca64575 100644 --- a/controlplane/src/core/errors/errors.ts +++ b/controlplane/src/core/errors/errors.ts @@ -30,7 +30,7 @@ export function isAuthenticationError(e: Error): e is AuthenticationError { return e instanceof AuthenticationError; } -export function isPublicError(e: Error): e is PublicError { +export function isPublicError(e: unknown): e is PublicError { return e instanceof PublicError; } diff --git a/controlplane/src/core/repositories/OrganizationInvitationRepository.ts b/controlplane/src/core/repositories/OrganizationInvitationRepository.ts index 41ccbffeca..ca2d9eb2b2 100644 --- a/controlplane/src/core/repositories/OrganizationInvitationRepository.ts +++ b/controlplane/src/core/repositories/OrganizationInvitationRepository.ts @@ -120,6 +120,7 @@ export class OrganizationInvitationRepository { userID: users.id, email: users.email, invitedBy: users1.email, + lastSentAt: schema.organizationInvitations.lastSentAt, }) .from(organizationInvitations) .innerJoin(users, eq(users.id, organizationInvitations.userId)) @@ -143,6 +144,7 @@ export class OrganizationInvitationRepository { email: orgMember[0].email, invitedBy: orgMember[0].invitedBy || undefined, groups: await this.getPendingInvitationGroups(orgMember[0].invitationId), + lastSentAt: orgMember[0].lastSentAt || undefined, } as OrganizationInvitationDTO; } @@ -189,7 +191,7 @@ export class OrganizationInvitationRepository { .returning() .execute(); - if (inserted.length === 0) { + if (inserted.length === 0 || input.groups.length === 0) { return; } @@ -257,4 +259,18 @@ export class OrganizationInvitationRepository { ) .execute(); } + + public async updateLastSentToNow({ organizationId, userId }: { organizationId: string; userId: string }) { + await this.db + .update(organizationInvitations) + .set({ lastSentAt: new Date() }) + .where( + and( + eq(organizationInvitations.organizationId, organizationId), + eq(organizationInvitations.userId, userId), + eq(organizationInvitations.accepted, false), + ), + ) + .execute(); + } } diff --git a/controlplane/src/core/repositories/OrganizationRepository.ts b/controlplane/src/core/repositories/OrganizationRepository.ts index 0327f194c3..15a696a564 100644 --- a/controlplane/src/core/repositories/OrganizationRepository.ts +++ b/controlplane/src/core/repositories/OrganizationRepository.ts @@ -250,7 +250,7 @@ export class OrganizationRepository { .innerJoin(organizations, eq(organizations.id, input.organizationId)) .innerJoin(users, eq(users.id, organizationsMembers.userId)) .limit(1) - .where(eq(users.id, input.userId)) + .where(and(eq(users.id, input.userId), eq(organizationsMembers.active, true))) .execute(); return userOrganizations.length > 0; @@ -279,13 +279,14 @@ export class OrganizationRepository { queuedForDeletionAt: organizations.queuedForDeletionAt, queuedForDeletionBy: organizations.queuedForDeletionBy, kcGroupId: organizations.kcGroupId, + active: organizationsMembers.active, }) .from(organizationsMembers) .innerJoin(organizations, eq(organizations.id, organizationsMembers.organizationId)) .innerJoin(users, eq(users.id, organizationsMembers.userId)) .leftJoin(organizationBilling, eq(organizations.id, organizationBilling.organizationId)) .leftJoin(billingSubscriptions, eq(organizations.id, billingSubscriptions.organizationId)) - .where(eq(users.id, input.userId)) + .where(and(eq(users.id, input.userId), eq(organizationsMembers.active, true))) .execute(); return Promise.all( @@ -365,7 +366,7 @@ export class OrganizationRepository { userID: users.id, email: users.email, memberID: organizationsMembers.id, - active: users.active, + active: organizationsMembers.active, createdAt: organizationsMembers.createdAt, }) .from(organizationsMembers) @@ -403,7 +404,7 @@ export class OrganizationRepository { userID: users.id, email: users.email, memberID: organizationsMembers.id, - active: users.active, + active: organizationsMembers.active, createdAt: organizationsMembers.createdAt, }) .from(organizationsMembers) @@ -459,7 +460,7 @@ export class OrganizationRepository { userID: users.id, email: users.email, memberID: organizationsMembers.id, - active: users.active, + active: organizationsMembers.active, createdAt: organizationsMembers.createdAt, }) .from(organizationsMembers) @@ -496,12 +497,20 @@ export class OrganizationRepository { .values({ userId: input.userID, organizationId: input.organizationID, + active: true, }) .returning() .execute(); return insertedMember[0]; } + public setOrganizationMemberActive(input: { id: string; organizationId: string; active: boolean }) { + return this.db + .update(organizationsMembers) + .set({ active: input.active }) + .where(and(eq(organizationsMembers.organizationId, input.organizationId), eq(organizationsMembers.id, input.id))); + } + public async removeOrganizationMember(input: { userID: string; organizationID: string }) { await this.db .delete(organizationsMembers) diff --git a/controlplane/src/core/repositories/UserRepository.ts b/controlplane/src/core/repositories/UserRepository.ts index 1c8bbae8ea..1b4305e59c 100644 --- a/controlplane/src/core/repositories/UserRepository.ts +++ b/controlplane/src/core/repositories/UserRepository.ts @@ -175,13 +175,4 @@ export class UserRepository { throw e; } } - - // only to update the active attribute - public async updateUser(input: { id: string; active: boolean }) { - await this.db - .update(users) - .set({ active: input.active, updatedAt: new Date() }) - .where(eq(users.id, input.id)) - .execute(); - } } diff --git a/controlplane/src/core/services/Keycloak.ts b/controlplane/src/core/services/Keycloak.ts index eeabe3368a..f6ee813ab0 100644 --- a/controlplane/src/core/services/Keycloak.ts +++ b/controlplane/src/core/services/Keycloak.ts @@ -92,6 +92,17 @@ export default class Keycloak { return createUserResp.id; } + public async findUserByEmail({ email, realm }: { email: string; realm?: string }) { + const foundUsers = await this.client.users.find({ + max: 1, + email, + realm: realm || this.realm, + exact: true, + }); + + return foundUsers.length === 1 ? foundUsers[0] : undefined; + } + public async updateKeycloakUser({ realm, id, diff --git a/controlplane/src/core/services/UserInviteService.ts b/controlplane/src/core/services/UserInviteService.ts new file mode 100644 index 0000000000..f961aca498 --- /dev/null +++ b/controlplane/src/core/services/UserInviteService.ts @@ -0,0 +1,252 @@ +import { PostgresJsDatabase } from 'drizzle-orm/postgres-js'; +import { FastifyBaseLogger } from 'fastify'; +import { EnumStatusCode } from '@wundergraph/cosmo-connect/dist/common/common_pb'; +import { sql } from 'drizzle-orm'; +import { OrganizationRepository } from '../repositories/OrganizationRepository.js'; +import * as schema from '../../db/schema.js'; +import { PublicError } from '../errors/errors.js'; +import { OrganizationGroupRepository } from '../repositories/OrganizationGroupRepository.js'; +import { OrganizationInvitationRepository } from '../repositories/OrganizationInvitationRepository.js'; +import { UserRepository } from '../repositories/UserRepository.js'; +import { OrganizationInvitationDTO, UserDTO } from '../../types/index.js'; +import Keycloak from './Keycloak.js'; +import Mailer from './Mailer.js'; + +export class UserInviteService { + private readonly db: PostgresJsDatabase; + private readonly logger: FastifyBaseLogger; + private readonly keycloakRealm: string | undefined; + private readonly keycloak: Keycloak; + private readonly mailer: Mailer | undefined; + + constructor(input: { + db: PostgresJsDatabase; + logger: FastifyBaseLogger; + keycloakRealm: string | undefined; + keycloak: Keycloak; + mailer: Mailer | undefined; + }) { + this.db = input.db; + this.logger = input.logger; + this.keycloakRealm = input.keycloakRealm; + this.keycloak = input.keycloak; + this.mailer = input.mailer; + } + + inviteUser(input: { + organizationId: string; + inviterUserId: string; + email: string; + firstName?: string; + lastName?: string; + password?: string; + groups?: string[]; + }) { + return this.db.transaction(async (tx) => { + const orgRepo = new OrganizationRepository(this.logger, tx); + const userRepo = new UserRepository(this.logger, tx); + const orgInvitationRepo = new OrganizationInvitationRepository(this.logger, tx); + + // Acquire a lock so we don't create multiple invitations for the same user + const lockKey = `invite:${input.organizationId}:${input.email}`; + const advisoryLockRows = await tx.execute( + sql`select pg_try_advisory_xact_lock(hashtext(${lockKey})) as acquired`, + ); + + if (!advisoryLockRows?.[0]?.acquired) { + // Another request already acquired the lock for this invitation + throw new PublicError(EnumStatusCode.ERR, 'Slow down'); + } + + // Retrieve the organization by the provided organization ID + const organization = await orgRepo.byId(input.organizationId); + if (!organization?.kcGroupId) { + // An organization doesn't exist with the provided organization ID + throw new PublicError(EnumStatusCode.ERR_NOT_FOUND, 'Organization not found'); + } + + // Determine whether the organization can invite new members + const memberCount = await orgRepo.memberCount(input.organizationId); + const usersFeature = await orgRepo.getFeature({ + organizationId: input.organizationId, + featureId: 'users', + }); + + const limit = usersFeature?.limit === -1 ? undefined : usersFeature?.limit; + if (limit && memberCount >= limit) { + // The organization has reached the member limit + throw new PublicError( + EnumStatusCode.ERR_LIMIT_REACHED, + `The user limit for this organization has been reached`, + ); + } + + // Check whether the organization member already exists + const orgMember = await orgRepo.getOrganizationMemberByEmail({ + organizationID: input.organizationId, + userEmail: input.email, + }); + + if (orgMember) { + throw new PublicError(EnumStatusCode.ERR_ALREADY_EXISTS, 'User is already a part of the organization.'); + } + + // Retrieve the user from Keycloak + await this.keycloak.authenticateClient(); + const keycloakUser = await this.keycloak.findUserByEmail({ + email: input.email, + realm: this.keycloakRealm, + }); + + let keycloakUserId: string; + let user: UserDTO | null = null; + if (keycloakUser?.id) { + // The user already exists in Keycloak + keycloakUserId = keycloakUser.id!; + user = await userRepo.byId(keycloakUserId); + if (!user) { + // Make sure the user exists in the database + await userRepo.addUser({ id: keycloakUserId, email: input.email }); + } + } else { + // The user doesn't exist in Keycloak + keycloakUserId = await this.keycloak.addKeycloakUser({ + realm: this.keycloakRealm, + email: input.email, + firstName: input.firstName, + lastName: input.lastName, + isPasswordTemp: true, + }); + + await userRepo.addUser({ id: keycloakUserId, email: input.email }); + } + + // Ensure that the user exists in the database + if (!user) { + user = await userRepo.byId(keycloakUserId); + } + + if (!user) { + throw new PublicError(EnumStatusCode.ERR_NOT_FOUND, 'User not found'); + } + + // Check whether an invitation already exists for the user + const pendingInv = await orgInvitationRepo.getPendingOrganizationInvitation({ + organizationID: organization.id, + userID: keycloakUserId, + }); + + if (pendingInv) { + // Resend invitation + await this.#sendInvitation({ + orgRepo, + orgInvitationRepo, + pendingInvitation: pendingInv, + organizationId: organization.id, + organizationName: organization.name, + invitedBy: pendingInv.invitedBy, + userId: keycloakUserId, + receiverEmail: input.email, + }); + + return keycloakUserId; + } + + // Validate that the provided groups (if any) are valid for the organization + const groups: string[] = []; + if (input.groups) { + const orgGroupRepo = new OrganizationGroupRepository(tx); + for (const groupId of input.groups) { + const group = await orgGroupRepo.byId({ + organizationId: input.organizationId, + groupId, + }); + + if (!group) { + throw new PublicError(EnumStatusCode.ERR_NOT_FOUND, 'Group not found'); + } + + groups.push(group.groupId); + } + } + + if (input.groups && groups.length === 0) { + // No valid groups were provided + throw new PublicError(EnumStatusCode.ERR, 'No group was provided'); + } + + // Create invitation + await orgInvitationRepo.inviteUser({ + email: input.email, + userId: keycloakUserId, + organizationId: organization.id, + dbUser: user, + inviterUserId: input.inviterUserId, + groups, + }); + + await this.#sendInvitation({ + orgRepo, + orgInvitationRepo, + organizationId: organization.id, + organizationName: organization.name, + invitedBy: input.inviterUserId, + userId: keycloakUserId, + receiverEmail: input.email, + }); + + // Done + return keycloakUserId; + }); + } + + async #sendInvitation({ + orgRepo, + orgInvitationRepo, + pendingInvitation, + organizationId, + organizationName, + invitedBy, + userId, + receiverEmail, + }: { + orgRepo: OrganizationRepository; + orgInvitationRepo: OrganizationInvitationRepository; + pendingInvitation?: OrganizationInvitationDTO; + organizationId: string; + organizationName: string; + invitedBy: string | undefined; + userId: string; + receiverEmail: string; + }) { + const memberships = await orgRepo.memberships({ userId }); + if (memberships.length === 0) { + // If the user memberships are empty, that means the user has not logged in until now, + // so we send the user a mail form Keycloak + await this.keycloak.executeActionsEmail({ + realm: this.keycloakRealm, + userID: userId, + redirectURI: `${process.env.WEB_BASE_URL}/login?redirectURL=${process.env.WEB_BASE_URL}/account/invitations`, + }); + } else { + // The user has already logged in, so we send our custom org invitation email + if (!this.mailer) { + return; + } + + if (pendingInvitation?.lastSentAt && pendingInvitation.lastSentAt.getTime() + 1000 * 60 * 30 > Date.now()) { + // We are not sending the invitation more than once every 30 minutes + return; + } + + await this.mailer.sendInviteEmail({ + inviteLink: `${process.env.WEB_BASE_URL}/account/invitations`, + organizationName, + receiverEmail, + invitedBy, + }); + } + + await orgInvitationRepo.updateLastSentToNow({ organizationId, userId }); + } +} diff --git a/controlplane/src/db/models.ts b/controlplane/src/db/models.ts index 0a4d770038..1330b5717e 100644 --- a/controlplane/src/db/models.ts +++ b/controlplane/src/db/models.ts @@ -170,4 +170,8 @@ export type AuditLogFullAction = | 'proposal.closed' | 'proposal.enabled' | 'proposal.disabled' - | 'namespace_proposal_config.updated'; + | 'namespace_proposal_config.updated' + | 'scim.organization_invitation_created' + | 'scim.update_organization_member' + | 'scim.activate_organization_member' + | 'scim.deactivate_organization_member'; diff --git a/controlplane/src/db/schema.ts b/controlplane/src/db/schema.ts index b03b416a51..8cb70a4c97 100644 --- a/controlplane/src/db/schema.ts +++ b/controlplane/src/db/schema.ts @@ -1396,6 +1396,7 @@ export const organizationsMembers = pgTable( .references(() => organizations.id, { onDelete: 'cascade', }), + active: boolean('active').notNull().default(true), createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(), }, (t) => { @@ -1601,6 +1602,7 @@ export const organizationInvitations = pgTable( .references(() => users.id, { onDelete: 'cascade' }), invitedBy: uuid('invited_by').references(() => users.id, { onDelete: 'cascade' }), accepted: boolean('accepted').default(false), + lastSentAt: timestamp('last_sent_at', { withTimezone: true }), createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(), }, (t) => { diff --git a/controlplane/src/types/index.ts b/controlplane/src/types/index.ts index 92809d51fd..d832c66480 100644 --- a/controlplane/src/types/index.ts +++ b/controlplane/src/types/index.ts @@ -315,6 +315,7 @@ export interface OrganizationInvitationDTO { email: string; invitedBy?: string; groups: { groupId: string; kcGroupId: string | null }[]; + lastSentAt?: Date; } export interface APIKeyDTO { diff --git a/controlplane/test/scim.test.ts b/controlplane/test/scim.test.ts index 42f9b845e3..e9e93a7efc 100644 --- a/controlplane/test/scim.test.ts +++ b/controlplane/test/scim.test.ts @@ -1,15 +1,15 @@ import { uid } from 'uid'; -import { afterAll, beforeAll, describe, expect, test } from 'vitest'; +import { afterAll, beforeAll, describe, expect, vi, test } from 'vitest'; import { EnumStatusCode } from '@wundergraph/cosmo-connect/dist/common/common_pb'; import { PromiseClient } from '@connectrpc/connect'; import { PlatformService } from '@wundergraph/cosmo-connect/dist/platform/v1/platform_connect'; import Keycloak from '../src/core/services/Keycloak.js'; -import { afterAllSetup, beforeAllSetup, UserTestData } from '../src/core/test-util.js'; +import { afterAllSetup, beforeAllSetup, TestAuthenticator, UserTestData } from '../src/core/test-util.js'; import { AuthContext } from '../src/types/index.js'; import { SetupKeycloak, SetupTest } from './test-util.js'; // https://developer.okta.com/docs/reference/scim/scim-20/ -describe('Scim server v2.0', (ctx) => { +describe('Scim server v2.0', () => { let dbname = ''; let baseAddress = ''; let realmName = ''; @@ -18,6 +18,7 @@ describe('Scim server v2.0', (ctx) => { let keycloakClient: Keycloak; let server: any; let client: PromiseClient; + let authenticator: TestAuthenticator; beforeAll(async () => { dbname = await beforeAllSetup(); @@ -35,6 +36,7 @@ describe('Scim server v2.0', (ctx) => { realmName = setupDetails.realm; server = setupDetails.server; client = setupDetails.client; + authenticator = setupDetails.authenticator; await SetupKeycloak({ keycloakClient, realmName, @@ -47,7 +49,7 @@ describe('Scim server v2.0', (ctx) => { await afterAllSetup(dbname); }); - test('Should test scim server base route', async (testContext) => { + test('Should test scim server base route', async () => { const res = await fetch(`${baseAddress}/scim/v2/`, { method: 'GET', headers: { @@ -58,7 +60,7 @@ describe('Scim server v2.0', (ctx) => { expect(res.status).toBe(200); }); - test('Should return 401 if the authorization fails', async (testContext) => { + test('Should return 401 if the authorization fails', async () => { const res = await fetch(`${baseAddress}/scim/v2/Users`, { method: 'GET', headers: { @@ -69,7 +71,7 @@ describe('Scim server v2.0', (ctx) => { expect(res.status).toBe(401); }); - test('Should test scim server /Users route', async (testContext) => { + test('Should test scim server /Users route', async () => { const res = await fetch(`${baseAddress}/scim/v2/Users`, { method: 'GET', headers: { @@ -83,7 +85,7 @@ describe('Scim server v2.0', (ctx) => { expect(response.totalResults).toBe(4); }); - test('Should test scim server /Users route with filter', async (testContext) => { + test('Should test scim server /Users route with filter', async () => { const res = await fetch(`${baseAddress}/scim/v2/Users?filter=userName eq "${userTestData.email}"`, { method: 'GET', headers: { @@ -97,7 +99,7 @@ describe('Scim server v2.0', (ctx) => { expect(response.totalResults).toBe(1); }); - test('Should test scim server /Users/:userID route', async (testContext) => { + test('Should test scim server /Users/:userID route', async () => { const res = await fetch(`${baseAddress}/scim/v2/Users/${userTestData.userId}`, { method: 'GET', headers: { @@ -111,8 +113,11 @@ describe('Scim server v2.0', (ctx) => { expect(response.userName).toBe(userTestData.email); }); - test('Should test create user and then get user', async (testContext) => { + test('that when a user does not exists an invitation is sent', async () => { const email = uid(8) + '@wg.com'; + const spy = vi.spyOn(keycloakClient, 'executeActionsEmail'); + spy.mockImplementation(vi.fn()); + const createUserResp = await fetch(`${baseAddress}/scim/v2/Users`, { method: 'POST', headers: { @@ -146,21 +151,80 @@ describe('Scim server v2.0', (ctx) => { expect(createUserResp.status).toBe(201); - const res = await fetch(`${baseAddress}/scim/v2/Users/${createUserBody.id}`, { - method: 'GET', + const pendingOrgMembers = await client.getPendingOrganizationMembers({}); + expect(pendingOrgMembers.response?.code).toBe(EnumStatusCode.OK); + expect(pendingOrgMembers.totalCount).toBe(1); + + const emails = pendingOrgMembers.pendingInvitations.map((inv) => inv.email); + const exists = emails.includes(email); + + expect(exists).toBe(true); + expect(spy).toHaveBeenCalledOnce(); + + spy.mockReset(); + }); + + test('that adding an existing user from another organization, invitest the user', async () => { + const email = otherOrgUserTestData!.email; + + // Remove the user from the organization and reject any pending invitation + authenticator.changeUserWithSuppliedContext(otherOrgUserTestData!); + await client.acceptOrDeclineInvitation({ organizationId: userTestData!.organizationId, accept: false }); + + authenticator.changeUserWithSuppliedContext(userTestData!); + await client.removeOrganizationMember({ email }); + + // Create the user invitation + const createUserResp = await fetch(`${baseAddress}/scim/v2/Users`, { + method: 'POST', headers: { Authorization: `Bearer ${userTestData.apiKey}`, 'Content-Type': 'application/scim+json', }, + body: JSON.stringify({ + schemas: ['urn:ietf:params:scim:schemas:core:2.0:User'], + userName: email, + name: { + givenName: 'Test', + familyName: 'User', + }, + emails: [ + { + primary: true, + value: email, + type: 'work', + }, + ], + displayName: 'Test User', + locale: 'en-US', + externalId: '00ujl29u0le5T6Aj10h7', + groups: [], + password: 'wunder@123', + active: true, + }), }); - const response = await res.json(); - expect(res.status).toBe(200); - expect(response.userName).toBe(email); + expect(createUserResp.status).toBe(201); + + const pendingOrgMembers = await client.getPendingOrganizationMembers({}); + expect(pendingOrgMembers.response?.code).toBe(EnumStatusCode.OK); + + const emails = pendingOrgMembers.pendingInvitations.map((inv) => inv.email); + const exists = emails.includes(email); + expect(exists).toBe(true); }); - test('Should test adding an existing user(who is not a part of the organization) and then check if the user is a part of the organization', async (testContext) => { + test('that adding an existing user from another organization multiple times does not create multiple invitations', async () => { const email = otherOrgUserTestData!.email; + + // Remove the user from the organization and reject any pending invitation + authenticator.changeUserWithSuppliedContext(otherOrgUserTestData!); + await client.acceptOrDeclineInvitation({ organizationId: userTestData!.organizationId, accept: false }); + + authenticator.changeUserWithSuppliedContext(userTestData!); + await client.removeOrganizationMember({ email }); + + // Create the user invitation const createUserResp = await fetch(`${baseAddress}/scim/v2/Users`, { method: 'POST', headers: { @@ -192,17 +256,56 @@ describe('Scim server v2.0', (ctx) => { expect(createUserResp.status).toBe(201); - const orgMembersResponse = await client.getOrganizationMembers({}); - const orgMembers = orgMembersResponse.members; - const emails = orgMembers.map((member) => member.email); - const exists = emails.includes(email); + const createUserResp2 = await fetch(`${baseAddress}/scim/v2/Users`, { + method: 'POST', + headers: { + Authorization: `Bearer ${userTestData.apiKey}`, + 'Content-Type': 'application/scim+json', + }, + body: JSON.stringify({ + schemas: ['urn:ietf:params:scim:schemas:core:2.0:User'], + userName: email, + name: { + givenName: 'Test', + familyName: 'User', + }, + emails: [ + { + primary: true, + value: email, + type: 'work', + }, + ], + displayName: 'Test User', + locale: 'en-US', + externalId: '00ujl29u0le5T6Aj10h7', + groups: [], + password: 'wunder@123', + active: true, + }), + }); + + expect(createUserResp2.status).toBe(201); + + const pendingOrgMembers = await client.getPendingOrganizationMembers({}); + expect(pendingOrgMembers.response?.code).toBe(EnumStatusCode.OK); - expect(orgMembersResponse.response?.code).toBe(EnumStatusCode.OK); + const emails = pendingOrgMembers.pendingInvitations.map((inv) => inv.email); + const exists = emails.includes(email); expect(exists).toBe(true); }); - test('Should test update user', async (testContext) => { - const email = uid(8) + '@wg.com'; + test('that an user can be updated after accepting the organization invitation', async () => { + const email = otherOrgUserTestData!.email; + + // Remove the user from the organization and reject any pending invitation + authenticator.changeUserWithSuppliedContext(otherOrgUserTestData!); + await client.acceptOrDeclineInvitation({ organizationId: userTestData!.organizationId, accept: false }); + + authenticator.changeUserWithSuppliedContext(userTestData!); + await client.removeOrganizationMember({ email }); + + // Create the user invitation const createUserResp = await fetch(`${baseAddress}/scim/v2/Users`, { method: 'POST', headers: { @@ -236,6 +339,17 @@ describe('Scim server v2.0', (ctx) => { expect(createUserResp.status).toBe(201); + // Accept the invitation + authenticator.changeUserWithSuppliedContext(otherOrgUserTestData!); + const acceptInvitationResponse = await client.acceptOrDeclineInvitation({ + organizationId: userTestData!.organizationId, + accept: true, + }); + + expect(acceptInvitationResponse.response?.code).toBe(EnumStatusCode.OK); + + // Update the user + authenticator.changeUserWithSuppliedContext(userTestData!); const updateUserResp = await fetch(`${baseAddress}/scim/v2/Users/${createUserBody.id}`, { method: 'PUT', headers: { @@ -287,8 +401,17 @@ describe('Scim server v2.0', (ctx) => { expect(response.active).toBe(false); }); - test('Should test /Users/:userID patch route', async (testContext) => { - const email = uid(8) + '@wg.com'; + test('that an user can be patched after accepting the organization invitation', async () => { + const email = otherOrgUserTestData!.email; + + // Remove the user from the organization and reject any pending invitation + authenticator.changeUserWithSuppliedContext(otherOrgUserTestData!); + await client.acceptOrDeclineInvitation({ organizationId: userTestData!.organizationId, accept: false }); + + authenticator.changeUserWithSuppliedContext(userTestData!); + await client.removeOrganizationMember({ email }); + + // Create the user invitation const createUserResp = await fetch(`${baseAddress}/scim/v2/Users`, { method: 'POST', headers: { @@ -322,6 +445,17 @@ describe('Scim server v2.0', (ctx) => { expect(createUserResp.status).toBe(201); + // Accept the invitation + authenticator.changeUserWithSuppliedContext(otherOrgUserTestData!); + const acceptInvitationResponse = await client.acceptOrDeclineInvitation({ + organizationId: userTestData!.organizationId, + accept: true, + }); + + expect(acceptInvitationResponse.response?.code).toBe(EnumStatusCode.OK); + + // Update the user + authenticator.changeUserWithSuppliedContext(userTestData!); const updateUserResp = await fetch(`${baseAddress}/scim/v2/Users/${createUserBody.id}`, { method: 'PATCH', headers: { diff --git a/studio/src/components/audit-log-table.tsx b/studio/src/components/audit-log-table.tsx index 5724fb3383..14369388ec 100644 --- a/studio/src/components/audit-log-table.tsx +++ b/studio/src/components/audit-log-table.tsx @@ -77,7 +77,9 @@ export const AuditLogTable = ({ logs }: { logs?: AuditLog[] }) => { let preParagraph = null; let postParagraph = null; - if (auditAction === "organization_invitation.created" || action === "queued_deletion") { + if (auditAction === "organization_invitation.created" || + auditAction === "scim.organization_invitation_created" || + action === "queued_deletion") { postParagraph = "for"; } else if (auditAction === "member_role.updated") { preParagraph = "role for"; @@ -102,7 +104,6 @@ export const AuditLogTable = ({ logs }: { logs?: AuditLog[] }) => { } let label = null; - if (targetDisplayName) { label = ( <>