diff --git a/cloud/db/migrations/0012_classy_morg.sql b/cloud/db/migrations/0012_classy_morg.sql new file mode 100644 index 0000000000..17700f18a2 --- /dev/null +++ b/cloud/db/migrations/0012_classy_morg.sql @@ -0,0 +1,41 @@ +ALTER TABLE "api_keys" ALTER COLUMN "created_at" SET DATA TYPE timestamp with time zone;--> statement-breakpoint +ALTER TABLE "api_keys" ALTER COLUMN "created_at" SET DEFAULT now();--> statement-breakpoint +ALTER TABLE "api_keys" ALTER COLUMN "last_used_at" SET DATA TYPE timestamp with time zone;--> statement-breakpoint +ALTER TABLE "environments" ALTER COLUMN "created_at" SET DATA TYPE timestamp with time zone;--> statement-breakpoint +ALTER TABLE "environments" ALTER COLUMN "created_at" SET DEFAULT now();--> statement-breakpoint +ALTER TABLE "environments" ALTER COLUMN "updated_at" SET DATA TYPE timestamp with time zone;--> statement-breakpoint +ALTER TABLE "environments" ALTER COLUMN "updated_at" SET DEFAULT now();--> statement-breakpoint +ALTER TABLE "sessions" ALTER COLUMN "expires_at" SET DATA TYPE timestamp with time zone;--> statement-breakpoint +ALTER TABLE "sessions" ALTER COLUMN "created_at" SET DATA TYPE timestamp with time zone;--> statement-breakpoint +ALTER TABLE "sessions" ALTER COLUMN "created_at" SET DEFAULT now();--> statement-breakpoint +ALTER TABLE "sessions" ALTER COLUMN "updated_at" SET DATA TYPE timestamp with time zone;--> statement-breakpoint +ALTER TABLE "sessions" ALTER COLUMN "updated_at" SET DEFAULT now();--> statement-breakpoint +ALTER TABLE "users" ALTER COLUMN "deleted_at" SET DATA TYPE timestamp with time zone;--> statement-breakpoint +ALTER TABLE "users" ALTER COLUMN "created_at" SET DATA TYPE timestamp with time zone;--> statement-breakpoint +ALTER TABLE "users" ALTER COLUMN "created_at" SET DEFAULT now();--> statement-breakpoint +ALTER TABLE "users" ALTER COLUMN "updated_at" SET DATA TYPE timestamp with time zone;--> statement-breakpoint +ALTER TABLE "users" ALTER COLUMN "updated_at" SET DEFAULT now();--> statement-breakpoint +ALTER TABLE "organizations" ALTER COLUMN "created_at" SET DATA TYPE timestamp with time zone;--> statement-breakpoint +ALTER TABLE "organizations" ALTER COLUMN "created_at" SET DEFAULT now();--> statement-breakpoint +ALTER TABLE "organizations" ALTER COLUMN "updated_at" SET DATA TYPE timestamp with time zone;--> statement-breakpoint +ALTER TABLE "organizations" ALTER COLUMN "updated_at" SET DEFAULT now();--> statement-breakpoint +ALTER TABLE "organization_memberships" ALTER COLUMN "created_at" SET DATA TYPE timestamp with time zone;--> statement-breakpoint +ALTER TABLE "organization_memberships" ALTER COLUMN "created_at" SET DEFAULT now();--> statement-breakpoint +ALTER TABLE "organization_memberships" ALTER COLUMN "updated_at" SET DATA TYPE timestamp with time zone;--> statement-breakpoint +ALTER TABLE "organization_memberships" ALTER COLUMN "updated_at" SET DEFAULT now();--> statement-breakpoint +ALTER TABLE "organization_membership_audit" ALTER COLUMN "created_at" SET DATA TYPE timestamp with time zone;--> statement-breakpoint +ALTER TABLE "organization_membership_audit" ALTER COLUMN "created_at" SET DEFAULT now();--> statement-breakpoint +ALTER TABLE "projects" ALTER COLUMN "created_at" SET DATA TYPE timestamp with time zone;--> statement-breakpoint +ALTER TABLE "projects" ALTER COLUMN "created_at" SET DEFAULT now();--> statement-breakpoint +ALTER TABLE "projects" ALTER COLUMN "updated_at" SET DATA TYPE timestamp with time zone;--> statement-breakpoint +ALTER TABLE "projects" ALTER COLUMN "updated_at" SET DEFAULT now();--> statement-breakpoint +ALTER TABLE "project_memberships" ALTER COLUMN "created_at" SET DATA TYPE timestamp with time zone;--> statement-breakpoint +ALTER TABLE "project_memberships" ALTER COLUMN "created_at" SET DEFAULT now();--> statement-breakpoint +ALTER TABLE "project_memberships" ALTER COLUMN "updated_at" SET DATA TYPE timestamp with time zone;--> statement-breakpoint +ALTER TABLE "project_memberships" ALTER COLUMN "updated_at" SET DEFAULT now();--> statement-breakpoint +ALTER TABLE "project_membership_audit" ALTER COLUMN "created_at" SET DATA TYPE timestamp with time zone;--> statement-breakpoint +ALTER TABLE "project_membership_audit" ALTER COLUMN "created_at" SET DEFAULT now();--> statement-breakpoint +ALTER TABLE IF EXISTS "traces" ALTER COLUMN "created_at" SET DATA TYPE timestamp with time zone;--> statement-breakpoint +ALTER TABLE IF EXISTS "traces" ALTER COLUMN "created_at" SET DEFAULT now();--> statement-breakpoint +ALTER TABLE IF EXISTS "spans" ALTER COLUMN "created_at" SET DATA TYPE timestamp with time zone;--> statement-breakpoint +ALTER TABLE IF EXISTS "spans" ALTER COLUMN "created_at" SET DEFAULT now(); diff --git a/cloud/db/migrations/meta/0012_snapshot.json b/cloud/db/migrations/meta/0012_snapshot.json new file mode 100644 index 0000000000..6d93a0413b --- /dev/null +++ b/cloud/db/migrations/meta/0012_snapshot.json @@ -0,0 +1,1176 @@ +{ + "id": "194652e1-4c66-45a0-b443-3507b4514b8f", + "prevId": "cfb64d01-faca-44d0-9a05-12e34af65fb0", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.api_keys": { + "name": "api_keys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "key_hash": { + "name": "key_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "key_prefix": { + "name": "key_prefix", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "environment_id": { + "name": "environment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "ownerId": { + "name": "ownerId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "last_used_at": { + "name": "last_used_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "api_keys_environment_id_environments_id_fk": { + "name": "api_keys_environment_id_environments_id_fk", + "tableFrom": "api_keys", + "tableTo": "environments", + "columnsFrom": ["environment_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "api_keys_ownerId_users_id_fk": { + "name": "api_keys_ownerId_users_id_fk", + "tableFrom": "api_keys", + "tableTo": "users", + "columnsFrom": ["ownerId"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "api_keys_environment_id_name_unique": { + "name": "api_keys_environment_id_name_unique", + "nullsNotDistinct": false, + "columns": ["environment_id", "name"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.environments": { + "name": "environments", + "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 + }, + "project_id": { + "name": "project_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "environments_project_id_projects_id_fk": { + "name": "environments_project_id_projects_id_fk", + "tableFrom": "environments", + "tableTo": "projects", + "columnsFrom": ["project_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "environments_project_id_slug_unique": { + "name": "environments_project_id_slug_unique", + "nullsNotDistinct": false, + "columns": ["project_id", "slug"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "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 + }, + "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": false, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "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": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.users": { + "name": "users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "users_email_unique": { + "name": "users_email_unique", + "nullsNotDistinct": false, + "columns": ["email"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "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 + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "organizations_slug_unique": { + "name": "organizations_slug_unique", + "nullsNotDistinct": false, + "columns": ["slug"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.organization_memberships": { + "name": "organization_memberships", + "schema": "", + "columns": { + "member_id": { + "name": "member_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "organization_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "organization_memberships_member_id_users_id_fk": { + "name": "organization_memberships_member_id_users_id_fk", + "tableFrom": "organization_memberships", + "tableTo": "users", + "columnsFrom": ["member_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "organization_memberships_organization_id_organizations_id_fk": { + "name": "organization_memberships_organization_id_organizations_id_fk", + "tableFrom": "organization_memberships", + "tableTo": "organizations", + "columnsFrom": ["organization_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "organization_memberships_member_id_organization_id_pk": { + "name": "organization_memberships_member_id_organization_id_pk", + "columns": ["member_id", "organization_id"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.organization_membership_audit": { + "name": "organization_membership_audit", + "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 + }, + "actor_id": { + "name": "actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "target_id": { + "name": "target_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "action": { + "name": "action", + "type": "audit_action", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "previous_role": { + "name": "previous_role", + "type": "organization_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "new_role": { + "name": "new_role", + "type": "organization_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "organization_membership_audit_organization_id_organizations_id_fk": { + "name": "organization_membership_audit_organization_id_organizations_id_fk", + "tableFrom": "organization_membership_audit", + "tableTo": "organizations", + "columnsFrom": ["organization_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "organization_membership_audit_actor_id_users_id_fk": { + "name": "organization_membership_audit_actor_id_users_id_fk", + "tableFrom": "organization_membership_audit", + "tableTo": "users", + "columnsFrom": ["actor_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "organization_membership_audit_target_id_users_id_fk": { + "name": "organization_membership_audit_target_id_users_id_fk", + "tableFrom": "organization_membership_audit", + "tableTo": "users", + "columnsFrom": ["target_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.projects": { + "name": "projects", + "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 + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_by_user_id": { + "name": "created_by_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "projects_organization_id_organizations_id_fk": { + "name": "projects_organization_id_organizations_id_fk", + "tableFrom": "projects", + "tableTo": "organizations", + "columnsFrom": ["organization_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "projects_created_by_user_id_users_id_fk": { + "name": "projects_created_by_user_id_users_id_fk", + "tableFrom": "projects", + "tableTo": "users", + "columnsFrom": ["created_by_user_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "projects_organization_id_slug_unique": { + "name": "projects_organization_id_slug_unique", + "nullsNotDistinct": false, + "columns": ["organization_id", "slug"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.project_memberships": { + "name": "project_memberships", + "schema": "", + "columns": { + "member_id": { + "name": "member_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "project_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "project_memberships_project_id_projects_id_fk": { + "name": "project_memberships_project_id_projects_id_fk", + "tableFrom": "project_memberships", + "tableTo": "projects", + "columnsFrom": ["project_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "project_memberships_member_id_organization_id_organization_memberships_member_id_organization_id_fk": { + "name": "project_memberships_member_id_organization_id_organization_memberships_member_id_organization_id_fk", + "tableFrom": "project_memberships", + "tableTo": "organization_memberships", + "columnsFrom": ["member_id", "organization_id"], + "columnsTo": ["member_id", "organization_id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "project_memberships_member_id_project_id_pk": { + "name": "project_memberships_member_id_project_id_pk", + "columns": ["member_id", "project_id"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.project_membership_audit": { + "name": "project_membership_audit", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "project_id": { + "name": "project_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "actor_id": { + "name": "actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "target_id": { + "name": "target_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "action": { + "name": "action", + "type": "audit_action", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "previous_role": { + "name": "previous_role", + "type": "project_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "new_role": { + "name": "new_role", + "type": "project_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "project_membership_audit_project_id_projects_id_fk": { + "name": "project_membership_audit_project_id_projects_id_fk", + "tableFrom": "project_membership_audit", + "tableTo": "projects", + "columnsFrom": ["project_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "project_membership_audit_actor_id_users_id_fk": { + "name": "project_membership_audit_actor_id_users_id_fk", + "tableFrom": "project_membership_audit", + "tableTo": "users", + "columnsFrom": ["actor_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "project_membership_audit_target_id_users_id_fk": { + "name": "project_membership_audit_target_id_users_id_fk", + "tableFrom": "project_membership_audit", + "tableTo": "users", + "columnsFrom": ["target_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.traces": { + "name": "traces", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "trace_id": { + "name": "trace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "environment_id": { + "name": "environment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "service_name": { + "name": "service_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "service_version": { + "name": "service_version", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "resource_attributes": { + "name": "resource_attributes", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "traces_env_created_at_idx": { + "name": "traces_env_created_at_idx", + "columns": [ + { + "expression": "environment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "traces_env_service_name_idx": { + "name": "traces_env_service_name_idx", + "columns": [ + { + "expression": "environment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "service_name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "traces_environment_id_environments_id_fk": { + "name": "traces_environment_id_environments_id_fk", + "tableFrom": "traces", + "tableTo": "environments", + "columnsFrom": ["environment_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "traces_project_id_projects_id_fk": { + "name": "traces_project_id_projects_id_fk", + "tableFrom": "traces", + "tableTo": "projects", + "columnsFrom": ["project_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "traces_organization_id_organizations_id_fk": { + "name": "traces_organization_id_organizations_id_fk", + "tableFrom": "traces", + "tableTo": "organizations", + "columnsFrom": ["organization_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "traces_trace_id_environment_id_unique": { + "name": "traces_trace_id_environment_id_unique", + "nullsNotDistinct": false, + "columns": ["trace_id", "environment_id"] + }, + "traces_id_trace_id_environment_id_unique": { + "name": "traces_id_trace_id_environment_id_unique", + "nullsNotDistinct": false, + "columns": ["id", "trace_id", "environment_id"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.spans": { + "name": "spans", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "trace_db_id": { + "name": "trace_db_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "trace_id": { + "name": "trace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "span_id": { + "name": "span_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "parent_span_id": { + "name": "parent_span_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "environment_id": { + "name": "environment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_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 + }, + "kind": { + "name": "kind", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "start_time_unix_nano": { + "name": "start_time_unix_nano", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "end_time_unix_nano": { + "name": "end_time_unix_nano", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "attributes": { + "name": "attributes", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "events": { + "name": "events", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "links": { + "name": "links", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "dropped_attributes_count": { + "name": "dropped_attributes_count", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "dropped_events_count": { + "name": "dropped_events_count", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "dropped_links_count": { + "name": "dropped_links_count", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "spans_env_created_at_idx": { + "name": "spans_env_created_at_idx", + "columns": [ + { + "expression": "environment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "spans_trace_db_id_idx": { + "name": "spans_trace_db_id_idx", + "columns": [ + { + "expression": "trace_db_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "spans_start_time_idx": { + "name": "spans_start_time_idx", + "columns": [ + { + "expression": "start_time_unix_nano", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "spans_env_start_time_idx": { + "name": "spans_env_start_time_idx", + "columns": [ + { + "expression": "environment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "start_time_unix_nano", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "spans_environment_id_environments_id_fk": { + "name": "spans_environment_id_environments_id_fk", + "tableFrom": "spans", + "tableTo": "environments", + "columnsFrom": ["environment_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "spans_project_id_projects_id_fk": { + "name": "spans_project_id_projects_id_fk", + "tableFrom": "spans", + "tableTo": "projects", + "columnsFrom": ["project_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "spans_organization_id_organizations_id_fk": { + "name": "spans_organization_id_organizations_id_fk", + "tableFrom": "spans", + "tableTo": "organizations", + "columnsFrom": ["organization_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "spans_trace_consistency_fk": { + "name": "spans_trace_consistency_fk", + "tableFrom": "spans", + "tableTo": "traces", + "columnsFrom": ["trace_db_id", "trace_id", "environment_id"], + "columnsTo": ["id", "trace_id", "environment_id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "spans_span_id_trace_id_environment_id_unique": { + "name": "spans_span_id_trace_id_environment_id_unique", + "nullsNotDistinct": false, + "columns": ["span_id", "trace_id", "environment_id"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.organization_role": { + "name": "organization_role", + "schema": "public", + "values": ["OWNER", "ADMIN", "MEMBER"] + }, + "public.audit_action": { + "name": "audit_action", + "schema": "public", + "values": ["GRANT", "REVOKE", "CHANGE"] + }, + "public.project_role": { + "name": "project_role", + "schema": "public", + "values": ["ADMIN", "DEVELOPER", "VIEWER", "ANNOTATOR"] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} diff --git a/cloud/db/migrations/meta/_journal.json b/cloud/db/migrations/meta/_journal.json index 86ce2523f4..3153f85a48 100644 --- a/cloud/db/migrations/meta/_journal.json +++ b/cloud/db/migrations/meta/_journal.json @@ -85,6 +85,13 @@ "when": 1766463987042, "tag": "0011_glossy_phantom_reporter", "breakpoints": true + }, + { + "idx": 12, + "version": "7", + "when": 1766736117726, + "tag": "0012_classy_morg", + "breakpoints": true } ] } diff --git a/cloud/db/schema/api-keys.ts b/cloud/db/schema/api-keys.ts index c693357096..c2140ac434 100644 --- a/cloud/db/schema/api-keys.ts +++ b/cloud/db/schema/api-keys.ts @@ -19,9 +19,9 @@ export const apiKeys = pgTable( ownerId: uuid("ownerId") .references(() => users.id) .notNull(), - createdAt: timestamp("created_at").defaultNow(), + createdAt: timestamp("created_at", { withTimezone: true }).defaultNow(), // Track last usage for auditing - lastUsedAt: timestamp("last_used_at"), + lastUsedAt: timestamp("last_used_at", { withTimezone: true }), }, (table) => ({ environmentNameUnique: unique().on(table.environmentId, table.name), diff --git a/cloud/db/schema/environments.ts b/cloud/db/schema/environments.ts index 0332302f2c..cd99de0b43 100644 --- a/cloud/db/schema/environments.ts +++ b/cloud/db/schema/environments.ts @@ -11,8 +11,8 @@ export const environments = pgTable( projectId: uuid("project_id") .references(() => projects.id, { onDelete: "cascade" }) .notNull(), - createdAt: timestamp("created_at").defaultNow(), - updatedAt: timestamp("updated_at").defaultNow(), + createdAt: timestamp("created_at", { withTimezone: true }).defaultNow(), + updatedAt: timestamp("updated_at", { withTimezone: true }).defaultNow(), }, (table) => ({ uniqueProjectSlug: unique().on(table.projectId, table.slug), diff --git a/cloud/db/schema/organization-membership-audit.ts b/cloud/db/schema/organization-membership-audit.ts index 8f32b72449..5433357b3c 100644 --- a/cloud/db/schema/organization-membership-audit.ts +++ b/cloud/db/schema/organization-membership-audit.ts @@ -26,7 +26,9 @@ export const organizationMembershipAudit = pgTable( action: auditActionEnum("action").notNull(), previousRole: organizationRoleEnum("previous_role"), newRole: organizationRoleEnum("new_role"), - createdAt: timestamp("created_at").defaultNow().notNull(), + createdAt: timestamp("created_at", { withTimezone: true }) + .defaultNow() + .notNull(), }, ); diff --git a/cloud/db/schema/organization-memberships.ts b/cloud/db/schema/organization-memberships.ts index b009658db3..7a1ee4be11 100644 --- a/cloud/db/schema/organization-memberships.ts +++ b/cloud/db/schema/organization-memberships.ts @@ -26,8 +26,8 @@ export const organizationMemberships = pgTable( .references(() => organizations.id, { onDelete: "cascade" }) .notNull(), role: organizationRoleEnum("role").notNull(), - createdAt: timestamp("created_at").defaultNow(), - updatedAt: timestamp("updated_at").defaultNow(), + createdAt: timestamp("created_at", { withTimezone: true }).defaultNow(), + updatedAt: timestamp("updated_at", { withTimezone: true }).defaultNow(), }, (table) => ({ pk: primaryKey({ columns: [table.memberId, table.organizationId] }), diff --git a/cloud/db/schema/organizations.ts b/cloud/db/schema/organizations.ts index 56a458348f..791a0a6c07 100644 --- a/cloud/db/schema/organizations.ts +++ b/cloud/db/schema/organizations.ts @@ -6,8 +6,8 @@ export const organizations = pgTable("organizations", { id: uuid("id").primaryKey().defaultRandom(), name: text("name").notNull(), slug: text("slug").notNull().unique(), - createdAt: timestamp("created_at").defaultNow(), - updatedAt: timestamp("updated_at").defaultNow(), + createdAt: timestamp("created_at", { withTimezone: true }).defaultNow(), + updatedAt: timestamp("updated_at", { withTimezone: true }).defaultNow(), }); export const organizationsRelations = relations(organizations, ({ many }) => ({ diff --git a/cloud/db/schema/project-membership-audit.ts b/cloud/db/schema/project-membership-audit.ts index b56e9a146f..b27d4a4042 100644 --- a/cloud/db/schema/project-membership-audit.ts +++ b/cloud/db/schema/project-membership-audit.ts @@ -19,7 +19,9 @@ export const projectMembershipAudit = pgTable("project_membership_audit", { action: auditActionEnum("action").notNull(), previousRole: projectRoleEnum("previous_role"), newRole: projectRoleEnum("new_role"), - createdAt: timestamp("created_at").defaultNow().notNull(), + createdAt: timestamp("created_at", { withTimezone: true }) + .defaultNow() + .notNull(), }); export const projectMembershipAuditRelations = relations( diff --git a/cloud/db/schema/project-memberships.ts b/cloud/db/schema/project-memberships.ts index cc9f7f284c..a99cc20775 100644 --- a/cloud/db/schema/project-memberships.ts +++ b/cloud/db/schema/project-memberships.ts @@ -30,8 +30,8 @@ export const projectMemberships = pgTable( .references(() => projects.id, { onDelete: "cascade" }) .notNull(), role: projectRoleEnum("role").notNull(), - createdAt: timestamp("created_at").defaultNow(), - updatedAt: timestamp("updated_at").defaultNow(), + createdAt: timestamp("created_at", { withTimezone: true }).defaultNow(), + updatedAt: timestamp("updated_at", { withTimezone: true }).defaultNow(), }, (table) => ({ pk: primaryKey({ columns: [table.memberId, table.projectId] }), diff --git a/cloud/db/schema/projects.ts b/cloud/db/schema/projects.ts index 8789affd43..8340b527a8 100644 --- a/cloud/db/schema/projects.ts +++ b/cloud/db/schema/projects.ts @@ -16,8 +16,8 @@ export const projects = pgTable( createdByUserId: uuid("created_by_user_id") .references(() => users.id) .notNull(), - createdAt: timestamp("created_at").defaultNow(), - updatedAt: timestamp("updated_at").defaultNow(), + createdAt: timestamp("created_at", { withTimezone: true }).defaultNow(), + updatedAt: timestamp("updated_at", { withTimezone: true }).defaultNow(), }, (table) => ({ uniqueOrgSlug: unique().on(table.organizationId, table.slug), diff --git a/cloud/db/schema/sessions.ts b/cloud/db/schema/sessions.ts index dae34c16a0..6b3f687d8e 100644 --- a/cloud/db/schema/sessions.ts +++ b/cloud/db/schema/sessions.ts @@ -7,9 +7,9 @@ export const sessions = pgTable("sessions", { userId: uuid("user_id") .notNull() .references(() => users.id, { onDelete: "cascade" }), - expiresAt: timestamp("expires_at").notNull(), // Unix timestamp - createdAt: timestamp("created_at").defaultNow(), - updatedAt: timestamp("updated_at").defaultNow(), + expiresAt: timestamp("expires_at", { withTimezone: true }).notNull(), + createdAt: timestamp("created_at", { withTimezone: true }).defaultNow(), + updatedAt: timestamp("updated_at", { withTimezone: true }).defaultNow(), }); export const sessionsRelations = relations(sessions, ({ one }) => ({ diff --git a/cloud/db/schema/spans.ts b/cloud/db/schema/spans.ts index 36b1a03e19..062bfe1d1a 100644 --- a/cloud/db/schema/spans.ts +++ b/cloud/db/schema/spans.ts @@ -44,7 +44,7 @@ export const spans = pgTable( droppedAttributesCount: integer("dropped_attributes_count"), droppedEventsCount: integer("dropped_events_count"), droppedLinksCount: integer("dropped_links_count"), - createdAt: timestamp("created_at").defaultNow(), + createdAt: timestamp("created_at", { withTimezone: true }).defaultNow(), }, (table) => ({ spanTraceEnvUnique: unique().on( diff --git a/cloud/db/schema/traces.ts b/cloud/db/schema/traces.ts index e1b3017aa5..f7cc0919da 100644 --- a/cloud/db/schema/traces.ts +++ b/cloud/db/schema/traces.ts @@ -29,7 +29,7 @@ export const traces = pgTable( serviceName: text("service_name"), serviceVersion: text("service_version"), resourceAttributes: jsonb("resource_attributes"), - createdAt: timestamp("created_at").defaultNow(), + createdAt: timestamp("created_at", { withTimezone: true }).defaultNow(), }, (table) => ({ traceEnvUnique: unique().on(table.traceId, table.environmentId), diff --git a/cloud/db/schema/users.ts b/cloud/db/schema/users.ts index a4642a74d2..b776c8f3e2 100644 --- a/cloud/db/schema/users.ts +++ b/cloud/db/schema/users.ts @@ -4,9 +4,9 @@ export const users = pgTable("users", { id: uuid("id").primaryKey().defaultRandom(), email: text("email").notNull().unique(), name: text("name"), - deletedAt: timestamp("deleted_at"), // null = active, non-null = soft-deleted - createdAt: timestamp("created_at").defaultNow(), - updatedAt: timestamp("updated_at").defaultNow(), + deletedAt: timestamp("deleted_at", { withTimezone: true }), // null = active, non-null = soft-deleted + createdAt: timestamp("created_at", { withTimezone: true }).defaultNow(), + updatedAt: timestamp("updated_at", { withTimezone: true }).defaultNow(), }); // Internal types