diff --git a/drizzle/migrations/0039_perpetual_sway.sql b/drizzle/migrations/0039_perpetual_sway.sql new file mode 100644 index 00000000..8df5847c --- /dev/null +++ b/drizzle/migrations/0039_perpetual_sway.sql @@ -0,0 +1,23 @@ +CREATE TABLE IF NOT EXISTS "ticket_requirements" ( + "ticket_id" uuid NOT NULL, + "required_ticket_id" uuid NOT NULL, + "requirement_type" text NOT NULL, + "description" text, + "created_at" timestamp (6) DEFAULT now() NOT NULL, + "updated_at" timestamp (6), + "deleted_at" timestamp (6) +); +--> statement-breakpoint +DO $$ BEGIN + ALTER TABLE "ticket_requirements" ADD CONSTRAINT "ticket_requirements_ticket_id_tickets_id_fk" FOREIGN KEY ("ticket_id") REFERENCES "public"."tickets"("id") ON DELETE no action ON UPDATE no action; +EXCEPTION + WHEN duplicate_object THEN null; +END $$; +--> statement-breakpoint +DO $$ BEGIN + ALTER TABLE "ticket_requirements" ADD CONSTRAINT "ticket_requirements_required_ticket_id_tickets_id_fk" FOREIGN KEY ("required_ticket_id") REFERENCES "public"."tickets"("id") ON DELETE no action ON UPDATE no action; +EXCEPTION + WHEN duplicate_object THEN null; +END $$; +--> statement-breakpoint +CREATE UNIQUE INDEX IF NOT EXISTS "unique_ticket_requirement" ON "ticket_requirements" USING btree ("ticket_id","required_ticket_id"); \ No newline at end of file diff --git a/drizzle/migrations/meta/0039_snapshot.json b/drizzle/migrations/meta/0039_snapshot.json new file mode 100644 index 00000000..9d10c06c --- /dev/null +++ b/drizzle/migrations/meta/0039_snapshot.json @@ -0,0 +1,4288 @@ +{ + "id": "26502aeb-f606-4027-8b09-1b7d8d066e3a", + "prevId": "d76fe445-7d51-496f-9d8d-769feb8c5c4f", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.allowed_currencies": { + "name": "allowed_currencies", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "currency": { + "name": "currency", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "payment_methods": { + "name": "payment_methods", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "allowed_currencies_currency_unique": { + "name": "allowed_currencies_currency_unique", + "nullsNotDistinct": false, + "columns": ["currency"] + } + } + }, + "public.communities": { + "name": "communities", + "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": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "logo_image_sanity_ref": { + "name": "logo_image_sanity_ref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "banner_image_sanity_ref": { + "name": "banner_image_sanity_ref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "payment_success_redirect_url": { + "name": "payment_success_redirect_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "payment_cancel_redirect_url": { + "name": "payment_cancel_redirect_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'inactive'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "communities_slug_unique": { + "name": "communities_slug_unique", + "nullsNotDistinct": false, + "columns": ["slug"] + } + } + }, + "public.companies": { + "name": "companies", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "domain": { + "name": "domain", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "logo": { + "name": "logo", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "website": { + "name": "website", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'draft'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.confirmation_token": { + "name": "confirmation_token", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "source_id": { + "name": "source_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "uuid", + "primaryKey": false, + "notNull": true, + "default": "gen_random_uuid()" + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'pending'" + }, + "valid_until": { + "name": "valid_until", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "confirmation_date": { + "name": "confirmation_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "confirmation_token_user_id_users_id_fk": { + "name": "confirmation_token_user_id_users_id_fk", + "tableFrom": "confirmation_token", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "confirmation_token_token_unique": { + "name": "confirmation_token_token_unique", + "nullsNotDistinct": false, + "columns": ["token"] + } + } + }, + "public.events": { + "name": "events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'inactive'" + }, + "visibility": { + "name": "visibility", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'unlisted'" + }, + "start_date_time": { + "name": "start_date_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "end_date_time": { + "name": "end_date_time", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "timezone": { + "name": "timezone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "geo_latitude": { + "name": "geo_latitude", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "geo_longitude": { + "name": "geo_longitude", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "geo_address_json": { + "name": "geo_address_json", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "address_descriptive_name": { + "name": "address_descriptive_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "address": { + "name": "address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "meeting_url": { + "name": "meeting_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "sanity_event_id": { + "name": "sanity_event_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "banner_image_sanity_ref": { + "name": "banner_image_sanity_ref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "public_share_url": { + "name": "public_share_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "logo_image": { + "name": "logo_image", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "preview_image": { + "name": "preview_image", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "banner_image": { + "name": "banner_image", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "mobile_banner_image": { + "name": "mobile_banner_image", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "events_logo_image_images_id_fk": { + "name": "events_logo_image_images_id_fk", + "tableFrom": "events", + "tableTo": "images", + "columnsFrom": ["logo_image"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "events_preview_image_images_id_fk": { + "name": "events_preview_image_images_id_fk", + "tableFrom": "events", + "tableTo": "images", + "columnsFrom": ["preview_image"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "events_banner_image_images_id_fk": { + "name": "events_banner_image_images_id_fk", + "tableFrom": "events", + "tableTo": "images", + "columnsFrom": ["banner_image"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "events_mobile_banner_image_images_id_fk": { + "name": "events_mobile_banner_image_images_id_fk", + "tableFrom": "events", + "tableTo": "images", + "columnsFrom": ["mobile_banner_image"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "events_name_unique": { + "name": "events_name_unique", + "nullsNotDistinct": false, + "columns": ["name"] + } + } + }, + "public.events_communities": { + "name": "events_communities", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": false, + "notNull": true, + "default": "gen_random_uuid()" + }, + "event_id": { + "name": "event_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "community_id": { + "name": "community_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "payment_success_redirect_url": { + "name": "payment_success_redirect_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "payment_cancel_redirect_url": { + "name": "payment_cancel_redirect_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "events_communities_event_id_events_id_fk": { + "name": "events_communities_event_id_events_id_fk", + "tableFrom": "events_communities", + "tableTo": "events", + "columnsFrom": ["event_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "events_communities_community_id_communities_id_fk": { + "name": "events_communities_community_id_communities_id_fk", + "tableFrom": "events_communities", + "tableTo": "communities", + "columnsFrom": ["community_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "events_communities_event_id_community_id_pk": { + "name": "events_communities_event_id_community_id_pk", + "columns": ["event_id", "community_id"] + } + }, + "uniqueConstraints": { + "events_communities_id_unique": { + "name": "events_communities_id_unique", + "nullsNotDistinct": false, + "columns": ["id"] + } + } + }, + "public.events_tags": { + "name": "events_tags", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": false, + "notNull": true, + "default": "gen_random_uuid()" + }, + "event_id": { + "name": "event_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "tag_id": { + "name": "tag_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "events_tags_event_id_events_id_fk": { + "name": "events_tags_event_id_events_id_fk", + "tableFrom": "events_tags", + "tableTo": "events", + "columnsFrom": ["event_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "events_tags_tag_id_tags_id_fk": { + "name": "events_tags_tag_id_tags_id_fk", + "tableFrom": "events_tags", + "tableTo": "tags", + "columnsFrom": ["tag_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "events_tags_event_id_tag_id_pk": { + "name": "events_tags_event_id_tag_id_pk", + "columns": ["event_id", "tag_id"] + } + }, + "uniqueConstraints": { + "events_tags_id_unique": { + "name": "events_tags_id_unique", + "nullsNotDistinct": false, + "columns": ["id"] + } + } + }, + "public.events_users": { + "name": "events_users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "event_id": { + "name": "event_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'member'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "events_users_event_id_events_id_fk": { + "name": "events_users_event_id_events_id_fk", + "tableFrom": "events_users", + "tableTo": "events", + "columnsFrom": ["event_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "events_users_user_id_users_id_fk": { + "name": "events_users_user_id_users_id_fk", + "tableFrom": "events_users", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.galleries": { + "name": "galleries", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": false, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "event_id": { + "name": "event_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "galleries_event_id_events_id_fk": { + "name": "galleries_event_id_events_id_fk", + "tableFrom": "galleries", + "tableTo": "events", + "columnsFrom": ["event_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "galleries_id_unique": { + "name": "galleries_id_unique", + "nullsNotDistinct": false, + "columns": ["id"] + }, + "galleries_slug_unique": { + "name": "galleries_slug_unique", + "nullsNotDistinct": false, + "columns": ["slug"] + } + } + }, + "public.images": { + "name": "images", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": false, + "notNull": true, + "default": "gen_random_uuid()" + }, + "image_url": { + "name": "image_url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "hosting": { + "name": "hosting", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "gallery_id": { + "name": "gallery_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "tags": { + "name": "tags", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "ARRAY[]::text[]" + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "images_tags_index": { + "name": "images_tags_index", + "columns": [ + { + "expression": "tags", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "images_gallery_id_galleries_id_fk": { + "name": "images_gallery_id_galleries_id_fk", + "tableFrom": "images", + "tableTo": "galleries", + "columnsFrom": ["gallery_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "images_id_unique": { + "name": "images_id_unique", + "nullsNotDistinct": false, + "columns": ["id"] + } + } + }, + "public.payments_logs": { + "name": "payments_logs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "external_id": { + "name": "external_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "external_product_reference": { + "name": "external_product_reference", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "platform": { + "name": "platform", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "transaction_amount": { + "name": "transaction_amount", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "external_creation_date": { + "name": "external_creation_date", + "type": "timestamp (6) with time zone", + "primaryKey": false, + "notNull": false + }, + "currency_id": { + "name": "currency_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "original_response_blob": { + "name": "original_response_blob", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_logs_external_id_platform_unique": { + "name": "payments_logs_external_id_platform_unique", + "nullsNotDistinct": false, + "columns": ["external_id", "platform"] + } + } + }, + "public.prices": { + "name": "prices", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "price": { + "name": "price", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "currency_id": { + "name": "currency_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "prices_currency_id_allowed_currencies_id_fk": { + "name": "prices_currency_id_allowed_currencies_id_fk", + "tableFrom": "prices", + "tableTo": "allowed_currencies", + "columnsFrom": ["currency_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.purchase_orders": { + "name": "purchase_orders", + "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 + }, + "public_id": { + "name": "public_id", + "type": "uuid", + "primaryKey": false, + "notNull": true, + "default": "gen_random_uuid()" + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "idempotency_uuid_key": { + "name": "idempotency_uuid_key", + "type": "uuid", + "primaryKey": false, + "notNull": true, + "default": "gen_random_uuid()" + }, + "payment_platform": { + "name": "payment_platform", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "total_price": { + "name": "total_price", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'open'" + }, + "currency_id": { + "name": "currency_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "payment_platform_payment_link": { + "name": "payment_platform_payment_link", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "payment_platform_expiration_date": { + "name": "payment_platform_expiration_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "payment_platform_reference_id": { + "name": "payment_platform_reference_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "payment_platform_status": { + "name": "payment_platform_status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "payment_platform_metadata": { + "name": "payment_platform_metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "purchase_order_payment_status": { + "name": "purchase_order_payment_status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'unpaid'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "purchase_orders_user_id_users_id_fk": { + "name": "purchase_orders_user_id_users_id_fk", + "tableFrom": "purchase_orders", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "purchase_orders_currency_id_allowed_currencies_id_fk": { + "name": "purchase_orders_currency_id_allowed_currencies_id_fk", + "tableFrom": "purchase_orders", + "tableTo": "allowed_currencies", + "columnsFrom": ["currency_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "purchase_orders_public_id_unique": { + "name": "purchase_orders_public_id_unique", + "nullsNotDistinct": false, + "columns": ["public_id"] + }, + "purchase_orders_idempotency_uuid_key_unique": { + "name": "purchase_orders_idempotency_uuid_key_unique", + "nullsNotDistinct": false, + "columns": ["idempotency_uuid_key"] + } + } + }, + "public.salaries": { + "name": "salaries", + "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 + }, + "amount": { + "name": "amount", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "company_id": { + "name": "company_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "currency_code": { + "name": "currency_code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "work_seniority_and_role_id": { + "name": "work_seniority_and_role_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "work_email_id": { + "name": "work_email_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "years_of_experience": { + "name": "years_of_experience", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "gender": { + "name": "gender", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "gender_other_text": { + "name": "gender_other_text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "country_code": { + "name": "country_code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type_of_employment": { + "name": "type_of_employment", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "work_metodology": { + "name": "work_metodology", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "salaries_user_id_users_id_fk": { + "name": "salaries_user_id_users_id_fk", + "tableFrom": "salaries", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "salaries_company_id_companies_id_fk": { + "name": "salaries_company_id_companies_id_fk", + "tableFrom": "salaries", + "tableTo": "companies", + "columnsFrom": ["company_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "salaries_work_seniority_and_role_id_work_seniority_and_role_id_fk": { + "name": "salaries_work_seniority_and_role_id_work_seniority_and_role_id_fk", + "tableFrom": "salaries", + "tableTo": "work_seniority_and_role", + "columnsFrom": ["work_seniority_and_role_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "salaries_work_email_id_work_email_id_fk": { + "name": "salaries_work_email_id_work_email_id_fk", + "tableFrom": "salaries", + "tableTo": "work_email", + "columnsFrom": ["work_email_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.schedule": { + "name": "schedule", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "event_id": { + "name": "event_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "start_at": { + "name": "start_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true + }, + "end_at": { + "name": "end_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "schedule_event_id_events_id_fk": { + "name": "schedule_event_id_events_id_fk", + "tableFrom": "schedule", + "tableTo": "events", + "columnsFrom": ["event_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "schedule_id_unique": { + "name": "schedule_id_unique", + "nullsNotDistinct": false, + "columns": ["id"] + } + } + }, + "public.sessions": { + "name": "sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "schedule_id": { + "name": "schedule_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "start_at": { + "name": "start_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true + }, + "end_at": { + "name": "end_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "sessions_schedule_id_schedule_id_fk": { + "name": "sessions_schedule_id_schedule_id_fk", + "tableFrom": "sessions", + "tableTo": "schedule", + "columnsFrom": ["schedule_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "sessions_id_unique": { + "name": "sessions_id_unique", + "nullsNotDistinct": false, + "columns": ["id"] + } + } + }, + "public.session_to_speakers": { + "name": "session_to_speakers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "session_id": { + "name": "session_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "speaker_id": { + "name": "speaker_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "session_to_speakers_session_id_sessions_id_fk": { + "name": "session_to_speakers_session_id_sessions_id_fk", + "tableFrom": "session_to_speakers", + "tableTo": "sessions", + "columnsFrom": ["session_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "session_to_speakers_speaker_id_speakers_id_fk": { + "name": "session_to_speakers_speaker_id_speakers_id_fk", + "tableFrom": "session_to_speakers", + "tableTo": "speakers", + "columnsFrom": ["speaker_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "session_to_speakers_id_unique": { + "name": "session_to_speakers_id_unique", + "nullsNotDistinct": false, + "columns": ["id"] + } + } + }, + "public.speakers": { + "name": "speakers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "rol": { + "name": "rol", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "avatar": { + "name": "avatar", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "event_id": { + "name": "event_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "company": { + "name": "company", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "social_links": { + "name": "social_links", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "ARRAY[]::text[]" + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "speakers_event_id_events_id_fk": { + "name": "speakers_event_id_events_id_fk", + "tableFrom": "speakers", + "tableTo": "events", + "columnsFrom": ["event_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "speakers_id_unique": { + "name": "speakers_id_unique", + "nullsNotDistinct": false, + "columns": ["id"] + } + } + }, + "public.tags": { + "name": "tags", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "tags_name_unique": { + "name": "tags_name_unique", + "nullsNotDistinct": false, + "columns": ["name"] + } + } + }, + "public.tags_communities": { + "name": "tags_communities", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": false, + "notNull": true, + "default": "gen_random_uuid()" + }, + "tag_id": { + "name": "tag_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "community_id": { + "name": "community_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "tags_communities_tag_id_tags_id_fk": { + "name": "tags_communities_tag_id_tags_id_fk", + "tableFrom": "tags_communities", + "tableTo": "tags", + "columnsFrom": ["tag_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "tags_communities_community_id_communities_id_fk": { + "name": "tags_communities_community_id_communities_id_fk", + "tableFrom": "tags_communities", + "tableTo": "communities", + "columnsFrom": ["community_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "tags_communities_tag_id_community_id_pk": { + "name": "tags_communities_tag_id_community_id_pk", + "columns": ["tag_id", "community_id"] + } + }, + "uniqueConstraints": { + "tags_communities_id_unique": { + "name": "tags_communities_id_unique", + "nullsNotDistinct": false, + "columns": ["id"] + } + } + }, + "public.teams": { + "name": "teams", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "event_id": { + "name": "event_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "limit": { + "name": "limit", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 5 + }, + "team_status": { + "name": "team_status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'waiting_resolution'" + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "teams_event_id_events_id_fk": { + "name": "teams_event_id_events_id_fk", + "tableFrom": "teams", + "tableTo": "events", + "columnsFrom": ["event_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.tickets_prices": { + "name": "tickets_prices", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "ticket_id": { + "name": "ticket_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "price_id": { + "name": "price_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "tickets_prices_ticket_id_tickets_id_fk": { + "name": "tickets_prices_ticket_id_tickets_id_fk", + "tableFrom": "tickets_prices", + "tableTo": "tickets", + "columnsFrom": ["ticket_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "tickets_prices_price_id_prices_id_fk": { + "name": "tickets_prices_price_id_prices_id_fk", + "tableFrom": "tickets_prices", + "tableTo": "prices", + "columnsFrom": ["price_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.tickets": { + "name": "tickets", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'inactive'" + }, + "tags": { + "name": "tags", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "ARRAY[]::text[]" + }, + "external_link": { + "name": "external_link", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "max_tickets_per_user": { + "name": "max_tickets_per_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "image_link": { + "name": "image_link", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "visibility": { + "name": "visibility", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'unlisted'" + }, + "start_date_time": { + "name": "start_date_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "end_date_time": { + "name": "end_date_time", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "requires_approval": { + "name": "requires_approval", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "quantity": { + "name": "quantity", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_unlimited": { + "name": "is_unlimited", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_free": { + "name": "is_free", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "event_id": { + "name": "event_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "stripe_product_id": { + "name": "stripe_product_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "mercado_pago_product_id": { + "name": "mercado_pago_product_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "coupon_id": { + "name": "coupon_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "tickets_event_id_index": { + "name": "tickets_event_id_index", + "columns": [ + { + "expression": "event_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "tickets_event_id_events_id_fk": { + "name": "tickets_event_id_events_id_fk", + "tableFrom": "tickets", + "tableTo": "events", + "columnsFrom": ["event_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "tickets_coupon_id_coupons_id_fk": { + "name": "tickets_coupon_id_coupons_id_fk", + "tableFrom": "tickets", + "tableTo": "coupons", + "columnsFrom": ["coupon_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "tickets_name_unique": { + "name": "tickets_name_unique", + "nullsNotDistinct": false, + "columns": ["name"] + } + } + }, + "public.users": { + "name": "users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "externalId": { + "name": "externalId", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lastName": { + "name": "lastName", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "bio": { + "name": "bio", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "''" + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "gender": { + "name": "gender", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "pronouns": { + "name": "pronouns", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'inactive'" + }, + "gender_other_text": { + "name": "gender_other_text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "isSuperAdmin": { + "name": "isSuperAdmin", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "emailVerified": { + "name": "emailVerified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "imageUrl": { + "name": "imageUrl", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "username": { + "name": "username", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "publicMetadata": { + "name": "publicMetadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "users_email_index": { + "name": "users_email_index", + "columns": [ + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "users_name_index": { + "name": "users_name_index", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "gin", + "with": {} + }, + "users_last_name_index": { + "name": "users_last_name_index", + "columns": [ + { + "expression": "lastName", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "gin", + "with": {} + }, + "users_username_index": { + "name": "users_username_index", + "columns": [ + { + "expression": "username", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "gin", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "users_email_unique": { + "name": "users_email_unique", + "nullsNotDistinct": false, + "columns": ["email"] + }, + "users_username_unique": { + "name": "users_username_unique", + "nullsNotDistinct": false, + "columns": ["username"] + } + } + }, + "public.users_communities": { + "name": "users_communities", + "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": false + }, + "community_id": { + "name": "community_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'member'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "users_communities_user_id_users_id_fk": { + "name": "users_communities_user_id_users_id_fk", + "tableFrom": "users_communities", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "users_communities_community_id_communities_id_fk": { + "name": "users_communities_community_id_communities_id_fk", + "tableFrom": "users_communities", + "tableTo": "communities", + "columnsFrom": ["community_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.user_data": { + "name": "user_data", + "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": false + }, + "country_of_residence": { + "name": "country_of_residence", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "city": { + "name": "city", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "works_in_organization": { + "name": "works_in_organization", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "organization_name": { + "name": "organization_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "role_in_organization": { + "name": "role_in_organization", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "rut": { + "name": "rut", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "food_allergies": { + "name": "food_allergies", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "emergency_phone_number": { + "name": "emergency_phone_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "user_id_index": { + "name": "user_id_index", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "user_data_user_id_users_id_fk": { + "name": "user_data_user_id_users_id_fk", + "tableFrom": "user_data", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.users_tags": { + "name": "users_tags", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": false, + "notNull": true, + "default": "gen_random_uuid()" + }, + "tag_id": { + "name": "tag_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "users_tags_tag_id_tags_id_fk": { + "name": "users_tags_tag_id_tags_id_fk", + "tableFrom": "users_tags", + "tableTo": "tags", + "columnsFrom": ["tag_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "users_tags_user_id_users_id_fk": { + "name": "users_tags_user_id_users_id_fk", + "tableFrom": "users_tags", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "users_tags_tag_id_user_id_pk": { + "name": "users_tags_tag_id_user_id_pk", + "columns": ["tag_id", "user_id"] + } + }, + "uniqueConstraints": { + "users_tags_id_unique": { + "name": "users_tags_id_unique", + "nullsNotDistinct": false, + "columns": ["id"] + } + } + }, + "public.user_teams": { + "name": "user_teams", + "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 + }, + "team_id": { + "name": "team_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'leader'" + }, + "discipline": { + "name": "discipline", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_participation_status": { + "name": "user_participation_status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'waiting_resolution'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "user_teams_user_id_users_id_fk": { + "name": "user_teams_user_id_users_id_fk", + "tableFrom": "user_teams", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "user_teams_team_id_teams_id_fk": { + "name": "user_teams_team_id_teams_id_fk", + "tableFrom": "user_teams", + "tableTo": "teams", + "columnsFrom": ["team_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.user_tickets": { + "name": "user_tickets", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "public_id": { + "name": "public_id", + "type": "uuid", + "primaryKey": false, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "ticket_template_id": { + "name": "ticket_template_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "purchase_order_id": { + "name": "purchase_order_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "approval_status": { + "name": "approval_status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "redemption_status": { + "name": "redemption_status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "user_tickets_public_id_index": { + "name": "user_tickets_public_id_index", + "columns": [ + { + "expression": "public_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_tickets_ticket_template_id_index": { + "name": "user_tickets_ticket_template_id_index", + "columns": [ + { + "expression": "ticket_template_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_tickets_user_id_index": { + "name": "user_tickets_user_id_index", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_tickets_approval_status_index": { + "name": "user_tickets_approval_status_index", + "columns": [ + { + "expression": "approval_status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_tickets_purchase_order_id_index": { + "name": "user_tickets_purchase_order_id_index", + "columns": [ + { + "expression": "purchase_order_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "user_tickets_user_id_users_id_fk": { + "name": "user_tickets_user_id_users_id_fk", + "tableFrom": "user_tickets", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "user_tickets_ticket_template_id_tickets_id_fk": { + "name": "user_tickets_ticket_template_id_tickets_id_fk", + "tableFrom": "user_tickets", + "tableTo": "tickets", + "columnsFrom": ["ticket_template_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "user_tickets_purchase_order_id_purchase_orders_id_fk": { + "name": "user_tickets_purchase_order_id_purchase_orders_id_fk", + "tableFrom": "user_tickets", + "tableTo": "purchase_orders", + "columnsFrom": ["purchase_order_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.user_tickets_email_logs": { + "name": "user_tickets_email_logs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_ticket_id": { + "name": "user_ticket_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "email_type": { + "name": "email_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "sent_at": { + "name": "sent_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "user_tickets_email_logs_email_type_index": { + "name": "user_tickets_email_logs_email_type_index", + "columns": [ + { + "expression": "email_type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "user_tickets_email_logs_user_ticket_id_user_tickets_id_fk": { + "name": "user_tickets_email_logs_user_ticket_id_user_tickets_id_fk", + "tableFrom": "user_tickets_email_logs", + "tableTo": "user_tickets", + "columnsFrom": ["user_ticket_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "user_tickets_email_logs_user_id_users_id_fk": { + "name": "user_tickets_email_logs_user_id_users_id_fk", + "tableFrom": "user_tickets_email_logs", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_tickets_email_logs_id_unique": { + "name": "user_tickets_email_logs_id_unique", + "nullsNotDistinct": false, + "columns": ["id"] + } + } + }, + "public.user_ticket_transfers": { + "name": "user_ticket_transfers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_ticket_id": { + "name": "user_ticket_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "sender_user_id": { + "name": "sender_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "recipient_user_id": { + "name": "recipient_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "transfer_message": { + "name": "transfer_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "expiration_date": { + "name": "expiration_date", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_return": { + "name": "is_return", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "user_ticket_transfers_user_ticket_id_index": { + "name": "user_ticket_transfers_user_ticket_id_index", + "columns": [ + { + "expression": "user_ticket_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_ticket_transfers_sender_user_id_index": { + "name": "user_ticket_transfers_sender_user_id_index", + "columns": [ + { + "expression": "sender_user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_ticket_transfers_recipient_user_id_index": { + "name": "user_ticket_transfers_recipient_user_id_index", + "columns": [ + { + "expression": "recipient_user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "user_ticket_transfers_user_ticket_id_user_tickets_id_fk": { + "name": "user_ticket_transfers_user_ticket_id_user_tickets_id_fk", + "tableFrom": "user_ticket_transfers", + "tableTo": "user_tickets", + "columnsFrom": ["user_ticket_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_ticket_transfers_sender_user_id_users_id_fk": { + "name": "user_ticket_transfers_sender_user_id_users_id_fk", + "tableFrom": "user_ticket_transfers", + "tableTo": "users", + "columnsFrom": ["sender_user_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "user_ticket_transfers_recipient_user_id_users_id_fk": { + "name": "user_ticket_transfers_recipient_user_id_users_id_fk", + "tableFrom": "user_ticket_transfers", + "tableTo": "users", + "columnsFrom": ["recipient_user_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.work_email": { + "name": "work_email", + "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 + }, + "work_email": { + "name": "work_email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "confirmation_token_id": { + "name": "confirmation_token_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'pending'" + }, + "confirmation_date": { + "name": "confirmation_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "company_id": { + "name": "company_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "work_email_user_id_users_id_fk": { + "name": "work_email_user_id_users_id_fk", + "tableFrom": "work_email", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "work_email_confirmation_token_id_confirmation_token_id_fk": { + "name": "work_email_confirmation_token_id_confirmation_token_id_fk", + "tableFrom": "work_email", + "tableTo": "confirmation_token", + "columnsFrom": ["confirmation_token_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "work_email_company_id_companies_id_fk": { + "name": "work_email_company_id_companies_id_fk", + "tableFrom": "work_email", + "tableTo": "companies", + "columnsFrom": ["company_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.work_role": { + "name": "work_role", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.work_seniority": { + "name": "work_seniority", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.work_seniority_and_role": { + "name": "work_seniority_and_role", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "work_role_id": { + "name": "work_role_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "work_seniority_id": { + "name": "work_seniority_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "work_seniority_and_role_work_role_id_work_role_id_fk": { + "name": "work_seniority_and_role_work_role_id_work_role_id_fk", + "tableFrom": "work_seniority_and_role", + "tableTo": "work_role", + "columnsFrom": ["work_role_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "work_seniority_and_role_work_seniority_id_work_seniority_id_fk": { + "name": "work_seniority_and_role_work_seniority_id_work_seniority_id_fk", + "tableFrom": "work_seniority_and_role", + "tableTo": "work_seniority", + "columnsFrom": ["work_seniority_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.addon_constraints": { + "name": "addon_constraints", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": false, + "notNull": true, + "default": "gen_random_uuid()" + }, + "addon_id": { + "name": "addon_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "related_addon_id": { + "name": "related_addon_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "constraint_type": { + "name": "constraint_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "idx_addon_constraints_unique": { + "name": "idx_addon_constraints_unique", + "columns": [ + { + "expression": "addon_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "related_addon_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "constraint_type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_addon_constraints_addon_id": { + "name": "idx_addon_constraints_addon_id", + "columns": [ + { + "expression": "addon_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_addon_constraints_related_addon_id": { + "name": "idx_addon_constraints_related_addon_id", + "columns": [ + { + "expression": "related_addon_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_addon_relationships_constraint_type": { + "name": "idx_addon_relationships_constraint_type", + "columns": [ + { + "expression": "constraint_type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "addon_constraints_addon_id_addons_id_fk": { + "name": "addon_constraints_addon_id_addons_id_fk", + "tableFrom": "addon_constraints", + "tableTo": "addons", + "columnsFrom": ["addon_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "addon_constraints_related_addon_id_addons_id_fk": { + "name": "addon_constraints_related_addon_id_addons_id_fk", + "tableFrom": "addon_constraints", + "tableTo": "addons", + "columnsFrom": ["related_addon_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "addon_constraints_id_unique": { + "name": "addon_constraints_id_unique", + "nullsNotDistinct": false, + "columns": ["id"] + } + } + }, + "public.addons": { + "name": "addons", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": false, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "total_stock": { + "name": "total_stock", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "max_per_ticket": { + "name": "max_per_ticket", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "tags": { + "name": "tags", + "type": "text[]", + "primaryKey": false, + "notNull": false, + "default": "ARRAY[]::text[]" + }, + "is_free": { + "name": "is_free", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_unlimited": { + "name": "is_unlimited", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "stripe_product_id": { + "name": "stripe_product_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "event_id": { + "name": "event_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "idx_addons_name": { + "name": "idx_addons_name", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "addons_event_id_events_id_fk": { + "name": "addons_event_id_events_id_fk", + "tableFrom": "addons", + "tableTo": "events", + "columnsFrom": ["event_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "addons_id_unique": { + "name": "addons_id_unique", + "nullsNotDistinct": false, + "columns": ["id"] + } + } + }, + "public.ticket_addons": { + "name": "ticket_addons", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": false, + "notNull": true, + "default": "gen_random_uuid()" + }, + "ticket_id": { + "name": "ticket_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "addon_id": { + "name": "addon_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "order_display": { + "name": "order_display", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "idx_ticket_addons_ticket_id": { + "name": "idx_ticket_addons_ticket_id", + "columns": [ + { + "expression": "ticket_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_ticket_addons_addon_id": { + "name": "idx_ticket_addons_addon_id", + "columns": [ + { + "expression": "addon_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_ticket_addons_unique": { + "name": "idx_ticket_addons_unique", + "columns": [ + { + "expression": "ticket_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "addon_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_ticket_addons_order_display": { + "name": "idx_ticket_addons_order_display", + "columns": [ + { + "expression": "ticket_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "order_display", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "ticket_addons_ticket_id_tickets_id_fk": { + "name": "ticket_addons_ticket_id_tickets_id_fk", + "tableFrom": "ticket_addons", + "tableTo": "tickets", + "columnsFrom": ["ticket_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "ticket_addons_addon_id_addons_id_fk": { + "name": "ticket_addons_addon_id_addons_id_fk", + "tableFrom": "ticket_addons", + "tableTo": "addons", + "columnsFrom": ["addon_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "ticket_addons_id_unique": { + "name": "ticket_addons_id_unique", + "nullsNotDistinct": false, + "columns": ["id"] + } + } + }, + "public.addons_prices": { + "name": "addons_prices", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "addon_id": { + "name": "addon_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "price_id": { + "name": "price_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "addons_prices_addon_id_addons_id_fk": { + "name": "addons_prices_addon_id_addons_id_fk", + "tableFrom": "addons_prices", + "tableTo": "addons", + "columnsFrom": ["addon_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "addons_prices_price_id_prices_id_fk": { + "name": "addons_prices_price_id_prices_id_fk", + "tableFrom": "addons_prices", + "tableTo": "prices", + "columnsFrom": ["price_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.user_ticket_addons": { + "name": "user_ticket_addons", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_ticket_id": { + "name": "user_ticket_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "addon_id": { + "name": "addon_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "unit_price_in_cents": { + "name": "unit_price_in_cents", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "approval_status": { + "name": "approval_status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "redemption_status": { + "name": "redemption_status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "purchase_order_id": { + "name": "purchase_order_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "idx_user_ticket_addons_user_ticket_id": { + "name": "idx_user_ticket_addons_user_ticket_id", + "columns": [ + { + "expression": "user_ticket_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_user_ticket_addons_addon_id": { + "name": "idx_user_ticket_addons_addon_id", + "columns": [ + { + "expression": "addon_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "user_ticket_addons_user_ticket_id_user_tickets_id_fk": { + "name": "user_ticket_addons_user_ticket_id_user_tickets_id_fk", + "tableFrom": "user_ticket_addons", + "tableTo": "user_tickets", + "columnsFrom": ["user_ticket_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "user_ticket_addons_addon_id_addons_id_fk": { + "name": "user_ticket_addons_addon_id_addons_id_fk", + "tableFrom": "user_ticket_addons", + "tableTo": "addons", + "columnsFrom": ["addon_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "user_ticket_addons_purchase_order_id_purchase_orders_id_fk": { + "name": "user_ticket_addons_purchase_order_id_purchase_orders_id_fk", + "tableFrom": "user_ticket_addons", + "tableTo": "purchase_orders", + "columnsFrom": ["purchase_order_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.coupons": { + "name": "coupons", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "coupon": { + "name": "coupon", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "event_id": { + "name": "event_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "coupons_event_id_index": { + "name": "coupons_event_id_index", + "columns": [ + { + "expression": "event_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "coupons_code_index": { + "name": "coupons_code_index", + "columns": [ + { + "expression": "lower(\"coupon\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "coupons_event_code_unique_index": { + "name": "coupons_event_code_unique_index", + "columns": [ + { + "expression": "event_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "coupon", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "coupons_event_id_events_id_fk": { + "name": "coupons_event_id_events_id_fk", + "tableFrom": "coupons", + "tableTo": "events", + "columnsFrom": ["event_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.ticket_requirements": { + "name": "ticket_requirements", + "schema": "", + "columns": { + "ticket_id": { + "name": "ticket_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "required_ticket_id": { + "name": "required_ticket_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "requirement_type": { + "name": "requirement_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp (6)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "unique_ticket_requirement": { + "name": "unique_ticket_requirement", + "columns": [ + { + "expression": "ticket_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "required_ticket_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "ticket_requirements_ticket_id_tickets_id_fk": { + "name": "ticket_requirements_ticket_id_tickets_id_fk", + "tableFrom": "ticket_requirements", + "tableTo": "tickets", + "columnsFrom": ["ticket_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "ticket_requirements_required_ticket_id_tickets_id_fk": { + "name": "ticket_requirements_required_ticket_id_tickets_id_fk", + "tableFrom": "ticket_requirements", + "tableTo": "tickets", + "columnsFrom": ["required_ticket_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} diff --git a/drizzle/migrations/meta/_journal.json b/drizzle/migrations/meta/_journal.json index 4d4fee86..a0afcfae 100644 --- a/drizzle/migrations/meta/_journal.json +++ b/drizzle/migrations/meta/_journal.json @@ -274,6 +274,13 @@ "when": 1731287550750, "tag": "0038_far_slyde", "breakpoints": true + }, + { + "idx": 39, + "version": "7", + "when": 1733147422688, + "tag": "0039_perpetual_sway", + "breakpoints": true } ] } diff --git a/src/datasources/db/schema.ts b/src/datasources/db/schema.ts index 420c0869..d243bf74 100644 --- a/src/datasources/db/schema.ts +++ b/src/datasources/db/schema.ts @@ -75,3 +75,5 @@ export * from "~/datasources/db/ticketsAddonsPrices"; export * from "~/datasources/db/userTicketsAddons"; export * from "~/datasources/db/coupons"; + +export * from "~/datasources/db/ticketRequirements"; diff --git a/src/datasources/db/ticketRequirements.ts b/src/datasources/db/ticketRequirements.ts new file mode 100644 index 00000000..f2b65998 --- /dev/null +++ b/src/datasources/db/ticketRequirements.ts @@ -0,0 +1,57 @@ +import { relations } from "drizzle-orm"; +import { pgTable, uuid, text, uniqueIndex } from "drizzle-orm/pg-core"; +import { createInsertSchema, createSelectSchema } from "drizzle-zod"; + +import { ticketsSchema } from "./schema"; +import { createdAndUpdatedAtFields } from "./shared"; + +export const requirementTypeEnum = [ + "ticket_ownership", // User must own a specific ticket + "ticket_category", // User must own a ticket of a specific category +] as const; + +export const ticketRequirementsSchema = pgTable( + "ticket_requirements", + { + ticketId: uuid("ticket_id") + .references(() => ticketsSchema.id) + .notNull(), + // The ticket that is required to access this ticket + requiredTicketId: uuid("required_ticket_id") + .references(() => ticketsSchema.id) + .notNull(), + requirementType: text("requirement_type", { + enum: requirementTypeEnum, + }).notNull(), + description: text("description"), + ...createdAndUpdatedAtFields, + }, + (table) => ({ + uniqueTicketRequirement: uniqueIndex("unique_ticket_requirement").on( + table.ticketId, + table.requiredTicketId, + ), + }), +); + +export const ticketRequirementsRelations = relations( + ticketRequirementsSchema, + ({ one }) => ({ + ticket: one(ticketsSchema, { + fields: [ticketRequirementsSchema.ticketId], + references: [ticketsSchema.id], + }), + requiredTicket: one(ticketsSchema, { + fields: [ticketRequirementsSchema.requiredTicketId], + references: [ticketsSchema.id], + }), + }), +); + +export const selectTicketRequirementsSchema = createSelectSchema( + ticketRequirementsSchema, +); + +export const insertTicketRequirementsSchema = createInsertSchema( + ticketRequirementsSchema, +); diff --git a/src/generated/schema.gql b/src/generated/schema.gql index 6b2c7d15..dc389787 100644 --- a/src/generated/schema.gql +++ b/src/generated/schema.gql @@ -330,6 +330,7 @@ input EventsSearchInput { } input EventsTicketTemplateSearchInput { + coupon: String tags: [String!] } @@ -1179,6 +1180,7 @@ type Ticket { """ quantity: Int quantityLeft: Int + requiredTicketIds: [String!]! requiresApproval: Boolean! startDateTime: DateTime! status: TicketTemplateStatus! diff --git a/src/generated/types.ts b/src/generated/types.ts index 480169bc..d568c7ef 100644 --- a/src/generated/types.ts +++ b/src/generated/types.ts @@ -332,6 +332,7 @@ export type EventsSearchInput = { }; export type EventsTicketTemplateSearchInput = { + coupon?: InputMaybe; tags?: InputMaybe>; }; @@ -1205,6 +1206,7 @@ export type Ticket = { /** The number of tickets available for this ticket type */ quantity?: Maybe; quantityLeft?: Maybe; + requiredTicketIds: Array; requiresApproval: Scalars["Boolean"]["output"]; startDateTime: Scalars["DateTime"]["output"]; status: TicketTemplateStatus; diff --git a/src/schema/ticket/helpers.ts b/src/schema/ticket/helpers.ts index 4dda14b6..af1d90b1 100644 --- a/src/schema/ticket/helpers.ts +++ b/src/schema/ticket/helpers.ts @@ -1,7 +1,7 @@ import { eq } from "drizzle-orm"; import Stripe from "stripe"; -import { TRANSACTION_HANDLER } from "~/datasources/db"; +import { TRANSACTION_HANDLER, ORM_TYPE } from "~/datasources/db"; import { ticketsSchema, addonsSchema } from "~/datasources/db/schema"; import { createOrUpdateStripeProductAndPrice, @@ -165,3 +165,55 @@ const productInfoToStripeItem = ( unit_amount: product.price.amount, }; }; + +export async function validateUserHasRequiredTickets({ + DB, + userId, + ticketId, + logger, +}: { + DB: ORM_TYPE; + userId: string; + ticketId: string; + logger: Logger; +}): Promise { + // Get all requirements for this ticket + const requirements = await DB.query.ticketRequirementsSchema.findMany({ + where: (tr, { eq }) => eq(tr.ticketId, ticketId), + }); + + // If there are no requirements, the user can buy the ticket + if (requirements.length === 0) { + return; + } + + // Get all user tickets that are approved or not requiring approval + const userTickets = await DB.query.userTicketsSchema.findMany({ + where: (ut, { and, eq, inArray }) => + and( + eq(ut.userId, userId), + inArray(ut.approvalStatus, [ + "approved", + "not_required", + "gift_accepted", + "transfer_accepted", + ]), + ), + }); + + // Create a set of ticket IDs the user owns + const userTicketIds = new Set(userTickets.map((ut) => ut.ticketTemplateId)); + + // Check if user has all required tickets + const missingTickets = requirements.filter( + (req) => !userTicketIds.has(req.requiredTicketId), + ); + + if (missingTickets.length > 0) { + throw applicationError( + "User does not have all required tickets to purchase this ticket", + ServiceErrors.FAILED_PRECONDITION, + logger, + ); + } +} diff --git a/src/schema/ticket/types.ts b/src/schema/ticket/types.ts index 16772524..97791f42 100644 --- a/src/schema/ticket/types.ts +++ b/src/schema/ticket/types.ts @@ -176,5 +176,19 @@ export const TicketLoadable = builder.loadableObject(TicketRef, { return root.id; }, }), + requiredTicketIds: t.field({ + type: ["String"], + resolve: async (root, _args, ctx) => { + const requirements = + await ctx.DB.query.ticketRequirementsSchema.findMany({ + where: (tr, { eq }) => eq(tr.ticketId, root.id), + columns: { + requiredTicketId: true, + }, + }); + + return requirements.map((r) => r.requiredTicketId); + }, + }), }), }); diff --git a/src/schema/ticketAddons/helpers/createUpdateAddonMutationHelpers.ts b/src/schema/ticketAddons/helpers/createUpdateAddonMutationHelpers.ts index 92514f7f..94913a63 100644 --- a/src/schema/ticketAddons/helpers/createUpdateAddonMutationHelpers.ts +++ b/src/schema/ticketAddons/helpers/createUpdateAddonMutationHelpers.ts @@ -333,7 +333,7 @@ const constraintHelpers = { }): Promise => { const updateSql = sql` UPDATE ${addonConstraintsSchema} - SET + SET ${sql.raw( addonConstraintsSchema.relatedAddonId.name, )} = tmp.related_addon_id::uuid, @@ -350,7 +350,7 @@ const constraintHelpers = { sql.raw(","), )} ) AS tmp (id, related_addon_id, constraint_type) - WHERE + WHERE ${addonConstraintsSchema}.${sql.raw( addonConstraintsSchema.id.name, )} = tmp.id diff --git a/src/schema/userTickets/mutations/claimUserTicket/index.ts b/src/schema/userTickets/mutations/claimUserTicket/index.ts index c1d02d20..2949dcd3 100644 --- a/src/schema/userTickets/mutations/claimUserTicket/index.ts +++ b/src/schema/userTickets/mutations/claimUserTicket/index.ts @@ -25,6 +25,7 @@ import { getPurchaseRedirectURLsFromPurchaseOrder, } from "~/schema/purchaseOrder/helpers"; import { isValidUUID } from "~/schema/shared/helpers"; +import { validateUserHasRequiredTickets } from "~/schema/ticket/helpers"; import { cleanEmail } from "~/schema/user/userHelpers"; import { getOrCreateTransferRecipients } from "~/schema/userTicketsTransfers/helpers"; import { Context } from "~/types"; @@ -153,6 +154,18 @@ async function processTicketClaim({ const normalizedInput = normalizeTicketClaimInput(purchaseOrder, logger); + // Validate ticket requirements for each ticket being claimed + await Promise.all( + Object.keys(normalizedInput).map(async (ticketId) => { + await validateUserHasRequiredTickets({ + DB, + userId: USER.id, + ticketId, + logger, + }); + }), + ); + const [ticketsAndAddonsInfo, purchaseOrderRecord, transferRecipients] = await Promise.all([ fetchTicketsAndAddonsInfo(DB, normalizedInput, logger), diff --git a/src/schema/userTickets/tests/claimUserTicket/claimUserTicket.test.ts b/src/schema/userTickets/tests/claimUserTicket/claimUserTicket.test.ts index 65392af5..9ea96237 100644 --- a/src/schema/userTickets/tests/claimUserTicket/claimUserTicket.test.ts +++ b/src/schema/userTickets/tests/claimUserTicket/claimUserTicket.test.ts @@ -1,4 +1,13 @@ -import { assert, describe, it, vi, expect, beforeEach } from "vitest"; +import { eq } from "drizzle-orm"; +import { + assert, + describe, + it, + vi, + expect, + beforeEach, + expectTypeOf, +} from "vitest"; import { SelectAllowedCurrencySchema } from "~/datasources/db/allowedCurrencies"; import { SelectCommunitySchema } from "~/datasources/db/communities"; @@ -10,6 +19,7 @@ import { SelectTicketSchema, } from "~/datasources/db/tickets"; import { InsertUserSchema, USER } from "~/datasources/db/users"; +import { userTicketsSchema } from "~/datasources/db/userTickets"; import { handlePaymentLinkGeneration } from "~/schema/purchaseOrder/actions"; import { executeGraphqlOperationAsUser, @@ -26,7 +36,9 @@ import { insertAddonConstraint, insertTicketAddon, SAMPLE_TEST_UUID, + insertTicketRequirement, } from "~/tests/fixtures"; +import { getTestDB } from "~/tests/fixtures/databaseHelper"; import { ClaimUserTicket, @@ -1254,4 +1266,129 @@ describe("Claim a user ticket", () => { }); }); }); + + describe("Create Purchase Order", () => { + it("should fail to create a purchase order if user does not meet ticket requirements", async () => { + const { user, event } = await createTestSetup(); + + const ticketTemplateToBeRequired = await insertTicketTemplate({ + eventId: event.id, + quantity: 100, + isFree: false, + }); + + const ticketTemplateToPurchase = await insertTicketTemplate({ + eventId: event.id, + quantity: 100, + isFree: false, + }); + + await insertTicketRequirement({ + ticketId: ticketTemplateToPurchase.id, + requiredTicketId: ticketTemplateToBeRequired.id, + requirementType: "ticket_ownership", + }); + + const response = await executeClaimTicket(user, { + input: { + purchaseOrder: [ + { + ticketId: ticketTemplateToPurchase.id, + quantity: 2, + itemsDetails: [], + }, + ], + }, + }); + + expect(response.data?.claimUserTicket?.__typename).toBe( + "RedeemUserTicketError", + ); + + if ( + response.data?.claimUserTicket?.__typename === "RedeemUserTicketError" + ) { + expect(response.data?.claimUserTicket.errorMessage).toBe( + "User does not have all required tickets to purchase this ticket", + ); + } + }); + + it("should create a purchase order if user meets ticket requirements", async () => { + const { user, event } = await createTestSetup(); + const DB = await getTestDB(); + + const ticketTemplateToBeRequired = await insertTicketTemplate({ + eventId: event.id, + quantity: 100, + isFree: false, + }); + + const ticketTemplateToPurchase = await insertTicketTemplate({ + eventId: event.id, + quantity: 100, + isFree: false, + }); + + await insertTicketRequirement({ + ticketId: ticketTemplateToPurchase.id, + requiredTicketId: ticketTemplateToBeRequired.id, + requirementType: "ticket_ownership", + }); + + // Claim the required ticket first + const responseRequiredTicket = await executeClaimTicket(user, { + input: { + purchaseOrder: [ + { + ticketId: ticketTemplateToBeRequired.id, + quantity: 1, + itemsDetails: [], + }, + ], + }, + }); + + const userTickets = responseRequiredTicket.data?.claimUserTicket; + + if (!userTickets) { + throw new Error("Failed to claim required ticket"); + } + + if (userTickets.__typename === "RedeemUserTicketError") { + throw new Error("Failed to claim required ticket"); + } + + const id = userTickets.tickets.at(0)?.id; + + if (!id) { + throw new Error("Failed to retrieved id of required ticket"); + } + + await DB.update(userTicketsSchema) + .set({ + approvalStatus: "approved", + }) + .where(eq(userTicketsSchema.id, id)); + + // Now claim the ticket that has the requirement + const response = await executeClaimTicket(user, { + input: { + purchaseOrder: [ + { + ticketId: ticketTemplateToPurchase.id, + quantity: 2, + itemsDetails: [], + }, + ], + }, + }); + + expect(response.data?.claimUserTicket?.__typename).toBe("PurchaseOrder"); + + if (response.data?.claimUserTicket?.__typename === "PurchaseOrder") { + expect(response.data?.claimUserTicket.tickets).toHaveLength(2); + } + }); + }); }); diff --git a/src/tests/fixtures/index.ts b/src/tests/fixtures/index.ts index c815b3a3..11ba6ff5 100644 --- a/src/tests/fixtures/index.ts +++ b/src/tests/fixtures/index.ts @@ -107,6 +107,9 @@ import { insertAddonPriceSchema, selectAddonPriceSchema, addonsPricesSchema, + insertTicketRequirementsSchema, + selectTicketRequirementsSchema, + ticketRequirementsSchema, } from "~/datasources/db/schema"; import { GenderOptionsEnum } from "~/datasources/db/shared"; import { @@ -922,3 +925,23 @@ export const toISODate = ( }; export const SAMPLE_TEST_UUID = "00000000-0000-0000-0000-000000000000"; + +export const insertTicketRequirement = async ( + partialInput?: Partial>, +) => { + const possibleInput = { + ticketId: partialInput?.ticketId ?? faker.string.uuid(), + requiredTicketId: partialInput?.requiredTicketId ?? faker.string.uuid(), + requirementType: partialInput?.requirementType ?? "ticket_ownership", + description: partialInput?.description ?? faker.lorem.sentence(), + + ...CRUDDates(partialInput), + } satisfies z.infer; + + return insertOne( + insertTicketRequirementsSchema, + selectTicketRequirementsSchema, + ticketRequirementsSchema, + possibleInput, + ); +}; diff --git a/workers/transactional_email_service/helpers.ts b/workers/transactional_email_service/helpers.ts index 0b03f203..e17e95f7 100644 --- a/workers/transactional_email_service/helpers.ts +++ b/workers/transactional_email_service/helpers.ts @@ -18,7 +18,7 @@ export const defaultInfo = { from: { name: "CommunityOS", email: "contacto@communityos.io", - } + }, }, nuevopuntocinco: { from: { @@ -31,6 +31,6 @@ export const defaultInfo = { from: { name: "JSConf Chile", email: "contacto@jsconf.cl", - } - } -} \ No newline at end of file + }, + }, +}; diff --git a/workers/transactional_email_service/types.ts b/workers/transactional_email_service/types.ts index 883fa9a3..0343b948 100644 --- a/workers/transactional_email_service/types.ts +++ b/workers/transactional_email_service/types.ts @@ -23,12 +23,12 @@ export interface UserTicketTransferInfo { name: string | null; email: string; username: string | null; - } + }; senderUser: { name: string | null; email: string; username: string | null; - }, + }; transferMessage?: string | null; expirationDate?: Date; userTicket: { @@ -53,5 +53,5 @@ export interface UserTicketTransferInfo { }>; }; }; - } -} \ No newline at end of file + }; +}