1451 lines
72 KiB
SQL
1451 lines
72 KiB
SQL
CREATE TABLE "ad_clicks" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"ad_id" integer NOT NULL,
|
|
"session_id" text,
|
|
"user_id" integer,
|
|
"created_at" timestamp with time zone DEFAULT now()
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "ad_impressions" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"ad_id" integer NOT NULL,
|
|
"session_id" text,
|
|
"user_id" integer,
|
|
"created_at" timestamp with time zone DEFAULT now()
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "ads" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"type" text NOT NULL,
|
|
"variant" text,
|
|
"image_path" text,
|
|
"link_url" text,
|
|
"title" text,
|
|
"visibility" text DEFAULT 'everyone' NOT NULL,
|
|
"is_active" boolean DEFAULT true,
|
|
"position" integer DEFAULT 0,
|
|
"impression_count" integer DEFAULT 0,
|
|
"click_count" integer DEFAULT 0,
|
|
"created_at" timestamp with time zone DEFAULT now(),
|
|
"updated_at" timestamp with time zone
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "app_settings" (
|
|
"key" text PRIMARY KEY NOT NULL,
|
|
"value" text NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now()
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "auth_tokens" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"user_id" integer NOT NULL,
|
|
"token" text NOT NULL,
|
|
"type" text NOT NULL,
|
|
"expires_at" timestamp with time zone NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now(),
|
|
CONSTRAINT "auth_tokens_token_unique" UNIQUE("token")
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "chat_thread_read_status" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"user_id" integer NOT NULL,
|
|
"media_id" integer NOT NULL,
|
|
"last_seen_at" timestamp with time zone NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "close_friends" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"user_id" integer NOT NULL,
|
|
"close_friend_id" integer NOT NULL,
|
|
"added_at" timestamp with time zone DEFAULT now()
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "comment_moderation" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"comment_id" integer NOT NULL,
|
|
"status" text DEFAULT 'pending' NOT NULL,
|
|
"moderated_by" integer,
|
|
"moderated_at" timestamp with time zone,
|
|
"reason" text
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "comments" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"media_id" integer NOT NULL,
|
|
"session_id" text NOT NULL,
|
|
"user_id" integer,
|
|
"content" text NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now(),
|
|
"safety_status" text DEFAULT 'pending',
|
|
"safety_checked_at" timestamp with time zone,
|
|
"safety_categories" jsonb,
|
|
"safety_reasoning" text,
|
|
"is_hidden" boolean DEFAULT false,
|
|
"hidden_at" timestamp with time zone,
|
|
"hidden_reason" text,
|
|
"moderation_notes" text
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "compilations" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"filename" text NOT NULL,
|
|
"path" text,
|
|
"duration_seconds" integer,
|
|
"video_ids" jsonb,
|
|
"settings" jsonb,
|
|
"created_at" timestamp with time zone DEFAULT now()
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "content_reports" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"media_id" integer NOT NULL,
|
|
"session_id" text,
|
|
"user_id" integer,
|
|
"report_type" text NOT NULL,
|
|
"description" text,
|
|
"status" text DEFAULT 'pending' NOT NULL,
|
|
"resolved_by" integer,
|
|
"resolved_at" timestamp with time zone,
|
|
"resolution_notes" text,
|
|
"created_at" timestamp with time zone DEFAULT now()
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "creators" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"name" text NOT NULL,
|
|
"slug" text NOT NULL,
|
|
"gender" integer,
|
|
"primary_face_id" integer,
|
|
"face_count" integer DEFAULT 0,
|
|
"video_count" integer DEFAULT 0,
|
|
"tag_id" integer,
|
|
"is_public" boolean DEFAULT false,
|
|
"centroid_embedding" jsonb,
|
|
"centroid_updated_at" timestamp with time zone,
|
|
"centroid_face_count" integer DEFAULT 0,
|
|
"embedding_variance" real,
|
|
"avg_intra_cluster_similarity" real,
|
|
"avg_age" real,
|
|
"age_std_dev" real,
|
|
"created_at" timestamp with time zone DEFAULT now(),
|
|
"updated_at" timestamp with time zone DEFAULT now(),
|
|
CONSTRAINT "creators_name_unique" UNIQUE("name"),
|
|
CONSTRAINT "creators_slug_unique" UNIQUE("slug")
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "digest_clip_tags" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"clip_id" integer NOT NULL,
|
|
"tag_id" integer NOT NULL,
|
|
"source" text DEFAULT 'auto' NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now()
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "digest_compilations" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"digest_id" integer NOT NULL,
|
|
"video_id" integer NOT NULL,
|
|
"folder_id" integer,
|
|
"filename" text NOT NULL,
|
|
"name" text,
|
|
"path" text NOT NULL,
|
|
"duration_seconds" integer,
|
|
"orientation" text,
|
|
"status" text DEFAULT 'pending' NOT NULL,
|
|
"error" text,
|
|
"has_captions" integer DEFAULT 0 NOT NULL,
|
|
"caption_style" jsonb,
|
|
"closing_ad_path" text,
|
|
"closing_ad_duration" integer,
|
|
"tags" jsonb,
|
|
"created_at" timestamp with time zone DEFAULT now(),
|
|
"completed_at" timestamp with time zone
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "digest_generated_clips" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"selected_clip_id" integer NOT NULL,
|
|
"digest_id" integer NOT NULL,
|
|
"folder_id" integer,
|
|
"clip_path" text,
|
|
"gif_path" text,
|
|
"status" text DEFAULT 'pending' NOT NULL,
|
|
"error" text,
|
|
"created_at" timestamp with time zone DEFAULT now(),
|
|
"completed_at" timestamp with time zone,
|
|
"published_to_public_media_id" integer,
|
|
"published_at" timestamp with time zone
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "digest_generated_scenes" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"digest_id" integer NOT NULL,
|
|
"video_id" integer NOT NULL,
|
|
"folder_id" integer,
|
|
"scene_number" integer NOT NULL,
|
|
"scene_path" text,
|
|
"start_time" real NOT NULL,
|
|
"end_time" real NOT NULL,
|
|
"duration" real NOT NULL,
|
|
"tags" jsonb,
|
|
"dominant_position" text,
|
|
"created_at" timestamp with time zone DEFAULT now(),
|
|
"published_to_public_media_id" integer,
|
|
"published_at" timestamp with time zone
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "digest_output_folders" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"digest_id" integer NOT NULL,
|
|
"video_id" integer NOT NULL,
|
|
"folder_path" text NOT NULL,
|
|
"folder_name" text NOT NULL,
|
|
"folder_type" text DEFAULT 'clips' NOT NULL,
|
|
"clip_count" integer DEFAULT 0,
|
|
"compilation_count" integer DEFAULT 0,
|
|
"total_size" integer,
|
|
"created_at" timestamp with time zone DEFAULT now()
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "digest_selected_clips" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"digest_id" integer NOT NULL,
|
|
"video_id" integer NOT NULL,
|
|
"clip_type" text NOT NULL,
|
|
"start_time" integer NOT NULL,
|
|
"end_time" integer NOT NULL,
|
|
"duration" integer NOT NULL,
|
|
"reason" text,
|
|
"interest_score" integer,
|
|
"position" text,
|
|
"transcript_hint" text,
|
|
"tags" jsonb,
|
|
"source" text DEFAULT 'machine' NOT NULL,
|
|
"is_included" integer DEFAULT 1 NOT NULL,
|
|
"is_hook" integer DEFAULT 0 NOT NULL,
|
|
"sequence_order" integer DEFAULT 0 NOT NULL,
|
|
"hook_source_clip_id" integer,
|
|
"created_at" timestamp with time zone DEFAULT now()
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "digest_suggested_tags" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"digest_id" integer NOT NULL,
|
|
"video_id" integer NOT NULL,
|
|
"suggested_category" text NOT NULL,
|
|
"suggested_value" text NOT NULL,
|
|
"confidence" integer,
|
|
"status" text DEFAULT 'pending' NOT NULL,
|
|
"mapped_tag_id" integer,
|
|
"reviewed_by" integer,
|
|
"reviewed_at" timestamp with time zone,
|
|
"created_at" timestamp with time zone DEFAULT now()
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "digest_video_tags" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"digest_id" integer NOT NULL,
|
|
"video_id" integer NOT NULL,
|
|
"category" text NOT NULL,
|
|
"value" text NOT NULL,
|
|
"confidence" integer,
|
|
"source" text DEFAULT 'digest',
|
|
"evidence" jsonb,
|
|
"created_at" timestamp with time zone DEFAULT now()
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "email_change_tokens" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"user_id" integer NOT NULL,
|
|
"new_email" text NOT NULL,
|
|
"token" text NOT NULL,
|
|
"expires_at" timestamp with time zone NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now(),
|
|
CONSTRAINT "email_change_tokens_token_unique" UNIQUE("token")
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "email_verification_tokens" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"user_id" integer NOT NULL,
|
|
"token" text NOT NULL,
|
|
"expires_at" timestamp with time zone NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now(),
|
|
CONSTRAINT "email_verification_tokens_token_unique" UNIQUE("token")
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "featured_playlists" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"playlist_id" integer NOT NULL,
|
|
"position" integer DEFAULT 0 NOT NULL,
|
|
"featured_by" integer,
|
|
"featured_at" timestamp with time zone,
|
|
CONSTRAINT "featured_playlists_playlist_id_unique" UNIQUE("playlist_id")
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "friendships" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"user_id" integer NOT NULL,
|
|
"friend_id" integer NOT NULL,
|
|
"status" text DEFAULT 'pending' NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now(),
|
|
"accepted_at" timestamp with time zone
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "geo_blocking_rules" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"country" text NOT NULL,
|
|
"country_name" text,
|
|
"region" text,
|
|
"city" text,
|
|
"created_at" timestamp with time zone DEFAULT now(),
|
|
"created_by" integer,
|
|
"note" text
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "highlight_cooldowns" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"user_id" integer NOT NULL,
|
|
"last_generated_at" timestamp with time zone NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "invoices" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"user_id" integer NOT NULL,
|
|
"plan_id" integer,
|
|
"invoice_number" text NOT NULL,
|
|
"amount_cad" integer NOT NULL,
|
|
"status" text DEFAULT 'pending' NOT NULL,
|
|
"due_date" timestamp with time zone NOT NULL,
|
|
"paid_at" timestamp with time zone,
|
|
"payment_id" integer,
|
|
"description" text,
|
|
"notes" text,
|
|
"created_at" timestamp with time zone DEFAULT now(),
|
|
"updated_at" timestamp with time zone,
|
|
CONSTRAINT "invoices_invoice_number_unique" UNIQUE("invoice_number")
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "jobs" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"type" text NOT NULL,
|
|
"status" text DEFAULT 'pending',
|
|
"progress" integer DEFAULT 0,
|
|
"log" text,
|
|
"params" jsonb,
|
|
"started_at" timestamp with time zone,
|
|
"completed_at" timestamp with time zone,
|
|
"created_at" timestamp with time zone DEFAULT now(),
|
|
"resource_category" text DEFAULT 'cpu',
|
|
"vram_required" integer DEFAULT 0,
|
|
"queue_position" integer,
|
|
"waiting_reason" text,
|
|
"priority" integer DEFAULT 5,
|
|
"pipeline_id" integer,
|
|
"pipeline_step_id" integer
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "moderation_word_lists" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"level" text NOT NULL,
|
|
"word" text NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now(),
|
|
"created_by" integer
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "notification_preferences" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"user_id" integer NOT NULL,
|
|
"email_friend_request" boolean DEFAULT true,
|
|
"email_friend_request_accepted" boolean DEFAULT true,
|
|
"email_poke" boolean DEFAULT true,
|
|
"email_video_recommendation" boolean DEFAULT true,
|
|
"email_watch_party_invite" boolean DEFAULT true,
|
|
"email_achievement" boolean DEFAULT false,
|
|
"email_digest_complete" boolean DEFAULT true,
|
|
"email_digest_failed" boolean DEFAULT true,
|
|
"email_upload_approved" boolean DEFAULT true,
|
|
"email_upload_rejected" boolean DEFAULT true,
|
|
"inapp_friend_request" boolean DEFAULT true,
|
|
"inapp_friend_request_accepted" boolean DEFAULT true,
|
|
"inapp_poke" boolean DEFAULT true,
|
|
"inapp_video_recommendation" boolean DEFAULT true,
|
|
"inapp_watch_party_invite" boolean DEFAULT true,
|
|
"inapp_achievement" boolean DEFAULT true,
|
|
"inapp_digest_complete" boolean DEFAULT true,
|
|
"inapp_digest_failed" boolean DEFAULT true,
|
|
"inapp_upload_approved" boolean DEFAULT true,
|
|
"inapp_upload_rejected" boolean DEFAULT true,
|
|
"inapp_comment_reply" boolean DEFAULT true,
|
|
"inapp_system" boolean DEFAULT true,
|
|
"quiet_hours_enabled" boolean DEFAULT false,
|
|
"quiet_hours_start" text,
|
|
"quiet_hours_end" text,
|
|
"updated_at" timestamp with time zone DEFAULT now(),
|
|
CONSTRAINT "notification_preferences_user_id_unique" UNIQUE("user_id")
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "notifications" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"user_id" integer NOT NULL,
|
|
"type" text NOT NULL,
|
|
"title" text NOT NULL,
|
|
"message" text,
|
|
"reference_type" text,
|
|
"reference_id" integer,
|
|
"actor_id" integer,
|
|
"metadata" jsonb,
|
|
"is_read" boolean DEFAULT false,
|
|
"action_url" text,
|
|
"group_key" text,
|
|
"created_at" timestamp with time zone DEFAULT now(),
|
|
"read_at" timestamp with time zone
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "password_reset_tokens" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"user_id" integer NOT NULL,
|
|
"token" text NOT NULL,
|
|
"expires_at" timestamp with time zone NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now(),
|
|
"used_at" timestamp with time zone,
|
|
CONSTRAINT "password_reset_tokens_token_unique" UNIQUE("token")
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "payment_audit_log" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"payment_id" integer,
|
|
"invoice_id" integer,
|
|
"user_id" integer,
|
|
"action" text NOT NULL,
|
|
"previous_state" jsonb,
|
|
"new_state" jsonb,
|
|
"performed_by" integer,
|
|
"notes" text,
|
|
"ip_address" text,
|
|
"created_at" timestamp with time zone DEFAULT now()
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "payments" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"invoice_id" integer,
|
|
"user_id" integer,
|
|
"sender_email" text NOT NULL,
|
|
"sender_name" text,
|
|
"amount_cad" integer NOT NULL,
|
|
"reference_number" text,
|
|
"custom_message" text,
|
|
"status" text DEFAULT 'unmatched' NOT NULL,
|
|
"match_confidence" real,
|
|
"match_method" text,
|
|
"raw_email_json" jsonb,
|
|
"received_at" timestamp with time zone NOT NULL,
|
|
"processed_at" timestamp with time zone,
|
|
"processed_by" integer,
|
|
"created_at" timestamp with time zone DEFAULT now(),
|
|
"updated_at" timestamp with time zone,
|
|
CONSTRAINT "payments_reference_number_unique" UNIQUE("reference_number")
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "performer_discrepancies" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"video_id" integer,
|
|
"digest_id" integer,
|
|
"parsed_performer_name" text NOT NULL,
|
|
"parsed_method" text,
|
|
"parsed_confidence" real,
|
|
"detected_performer_id" integer,
|
|
"detected_performer_name" text,
|
|
"face_match_confidence" real,
|
|
"face_similarity" real,
|
|
"discrepancy_type" text NOT NULL,
|
|
"status" text DEFAULT 'pending' NOT NULL,
|
|
"resolved_by" integer,
|
|
"resolved_at" timestamp with time zone,
|
|
"resolution" text,
|
|
"admin_notes" text,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "performer_faces" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"performer_id" integer,
|
|
"performer_name" text,
|
|
"face_embedding" jsonb NOT NULL,
|
|
"gender" integer,
|
|
"age" integer,
|
|
"detection_score" real,
|
|
"bbox" jsonb,
|
|
"face_crop_path" text,
|
|
"source_frame" text,
|
|
"source_video" text,
|
|
"source_digest_id" integer,
|
|
"frame_timestamp" real,
|
|
"frame_index" integer,
|
|
"faces_in_frame" integer DEFAULT 1,
|
|
"status" text DEFAULT 'pending',
|
|
"match_confidence" real,
|
|
"is_verified" boolean DEFAULT false,
|
|
"created_at" timestamp with time zone DEFAULT now(),
|
|
"updated_at" timestamp with time zone DEFAULT now()
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "pipeline_step_events" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"step_id" integer NOT NULL,
|
|
"event_type" text NOT NULL,
|
|
"event_data" jsonb,
|
|
"created_at" timestamp with time zone DEFAULT now()
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "pipeline_steps" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"pipeline_id" integer NOT NULL,
|
|
"name" text NOT NULL,
|
|
"step_type" text NOT NULL,
|
|
"sequence_order" integer NOT NULL,
|
|
"depends_on" jsonb DEFAULT '[]'::jsonb,
|
|
"resource_category" text DEFAULT 'cpu',
|
|
"vram_required" integer DEFAULT 0,
|
|
"required_containers" jsonb DEFAULT '[]'::jsonb,
|
|
"config" jsonb,
|
|
"status" text DEFAULT 'pending' NOT NULL,
|
|
"progress" integer DEFAULT 0,
|
|
"result" jsonb,
|
|
"error" text,
|
|
"estimated_duration_ms" integer,
|
|
"started_at" timestamp with time zone,
|
|
"completed_at" timestamp with time zone,
|
|
"duration_ms" integer
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "pipeline_templates" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"name" text NOT NULL,
|
|
"display_name" text NOT NULL,
|
|
"description" text,
|
|
"steps" jsonb NOT NULL,
|
|
"context_schema" jsonb,
|
|
"created_at" timestamp with time zone DEFAULT now(),
|
|
"updated_at" timestamp with time zone,
|
|
CONSTRAINT "pipeline_templates_name_unique" UNIQUE("name")
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "pipelines" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"name" text NOT NULL,
|
|
"description" text,
|
|
"status" text DEFAULT 'pending' NOT NULL,
|
|
"priority" integer DEFAULT 5,
|
|
"context" jsonb,
|
|
"total_vram_required" integer DEFAULT 0,
|
|
"estimated_duration_ms" integer,
|
|
"progress" integer DEFAULT 0,
|
|
"current_step_id" integer,
|
|
"completed_steps" integer DEFAULT 0,
|
|
"total_steps" integer DEFAULT 0,
|
|
"error" text,
|
|
"retry_count" integer DEFAULT 0,
|
|
"max_retries" integer DEFAULT 3,
|
|
"created_at" timestamp with time zone DEFAULT now(),
|
|
"queued_at" timestamp with time zone,
|
|
"started_at" timestamp with time zone,
|
|
"completed_at" timestamp with time zone,
|
|
"last_heartbeat" timestamp with time zone,
|
|
"running_on_node" text
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "playlist_videos" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"playlist_id" integer NOT NULL,
|
|
"media_id" integer NOT NULL,
|
|
"position" integer DEFAULT 0 NOT NULL,
|
|
"added_at" timestamp with time zone DEFAULT now()
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "playlist_views" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"playlist_id" integer NOT NULL,
|
|
"session_id" text NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now()
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "playlists" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"user_id" integer NOT NULL,
|
|
"name" text NOT NULL,
|
|
"description" text,
|
|
"is_public" boolean DEFAULT false,
|
|
"share_token" text,
|
|
"thumbnail_media_id" integer,
|
|
"video_count" integer DEFAULT 0,
|
|
"total_duration_seconds" integer DEFAULT 0,
|
|
"view_count" integer DEFAULT 0,
|
|
"created_at" timestamp with time zone DEFAULT now(),
|
|
"updated_at" timestamp with time zone,
|
|
CONSTRAINT "playlists_share_token_unique" UNIQUE("share_token")
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "pokes" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"from_user_id" integer NOT NULL,
|
|
"to_user_id" integer NOT NULL,
|
|
"is_read" boolean DEFAULT false,
|
|
"created_at" timestamp with time zone DEFAULT now()
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "privacy_settings" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"user_id" integer NOT NULL,
|
|
"show_online_status" boolean DEFAULT true,
|
|
"show_currently_watching" boolean DEFAULT true,
|
|
"show_in_friend_activity" boolean DEFAULT true,
|
|
"anonymize_public_comments" boolean DEFAULT false,
|
|
"hide_public_reactions" boolean DEFAULT false,
|
|
"hide_public_finishes" boolean DEFAULT false,
|
|
"allow_friend_requests" boolean DEFAULT true,
|
|
"close_friends_only_watching" boolean DEFAULT false,
|
|
"created_at" timestamp with time zone DEFAULT now(),
|
|
"updated_at" timestamp with time zone,
|
|
CONSTRAINT "privacy_settings_user_id_unique" UNIQUE("user_id")
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "public_media" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"path" text NOT NULL,
|
|
"filename" text NOT NULL,
|
|
"category" text NOT NULL,
|
|
"duration_seconds" integer,
|
|
"quality" text,
|
|
"orientation" text,
|
|
"thumbnail_path" text,
|
|
"file_size" bigint,
|
|
"view_count" integer DEFAULT 0,
|
|
"upvote_count" integer DEFAULT 0,
|
|
"comment_count" integer DEFAULT 0,
|
|
"finish_count" integer DEFAULT 0,
|
|
"total_watch_time" integer DEFAULT 0,
|
|
"created_at" timestamp with time zone DEFAULT now(),
|
|
"is_locked" boolean DEFAULT false,
|
|
"locked_at" timestamp with time zone,
|
|
"locked_by" integer,
|
|
"position" integer DEFAULT 0,
|
|
"uploader_id" integer,
|
|
CONSTRAINT "public_media_path_unique" UNIQUE("path")
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "public_media_performers" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"media_id" integer NOT NULL,
|
|
"performer_id" integer NOT NULL,
|
|
"added_at" timestamp with time zone DEFAULT now()
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "public_media_tags" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"media_id" integer NOT NULL,
|
|
"tag_id" integer NOT NULL,
|
|
"added_at" timestamp with time zone DEFAULT now()
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "published_inbox_files" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"source_inbox_path" text NOT NULL,
|
|
"filename" text NOT NULL,
|
|
"published_at" timestamp with time zone DEFAULT now(),
|
|
"published_to_path" text,
|
|
"public_media_id" integer,
|
|
"file_type" text NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "rate_limits" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"key" text NOT NULL,
|
|
"count" integer DEFAULT 1 NOT NULL,
|
|
"reset_at" timestamp with time zone NOT NULL,
|
|
CONSTRAINT "rate_limits_key_unique" UNIQUE("key")
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "resource_snapshots" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"gpu_index" integer DEFAULT 0,
|
|
"gpu_name" text,
|
|
"vram_used_mb" integer,
|
|
"vram_total_mb" integer,
|
|
"gpu_utilization" integer,
|
|
"gpu_temperature" integer,
|
|
"active_processes" jsonb,
|
|
"pipeline_id" integer,
|
|
"step_id" integer,
|
|
"created_at" timestamp with time zone DEFAULT now()
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "session_bans" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"session_id" text NOT NULL,
|
|
"reason" text,
|
|
"banned_by" integer,
|
|
"created_at" timestamp with time zone DEFAULT now(),
|
|
"expires_at" timestamp with time zone
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "sessions" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now(),
|
|
"last_seen_at" timestamp with time zone,
|
|
"ip_address" text,
|
|
"user_agent" text,
|
|
"device_type" text,
|
|
"browser" text,
|
|
"os" text,
|
|
"country" text,
|
|
"country_name" text,
|
|
"region" text,
|
|
"city" text,
|
|
"timezone" text,
|
|
"latitude" real,
|
|
"longitude" real,
|
|
"user_id" integer,
|
|
"first_seen_at" timestamp with time zone,
|
|
"visit_count" integer DEFAULT 1
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "subscription_plans" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"name" text NOT NULL,
|
|
"display_name" text NOT NULL,
|
|
"description" text,
|
|
"price_cad" integer NOT NULL,
|
|
"duration_days" integer,
|
|
"is_active" boolean DEFAULT true,
|
|
"sort_order" integer DEFAULT 0,
|
|
"created_at" timestamp with time zone DEFAULT now(),
|
|
"updated_at" timestamp with time zone,
|
|
CONSTRAINT "subscription_plans_name_unique" UNIQUE("name")
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "tag_categories" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"name" text NOT NULL,
|
|
"display_order" integer DEFAULT 0 NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now(),
|
|
CONSTRAINT "tag_categories_name_unique" UNIQUE("name")
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "tag_generation_jobs" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"status" text DEFAULT 'pending' NOT NULL,
|
|
"content_type" text NOT NULL,
|
|
"content_ids" jsonb NOT NULL,
|
|
"options" jsonb,
|
|
"results" jsonb,
|
|
"progress" integer DEFAULT 0,
|
|
"current_item" integer DEFAULT 0,
|
|
"total_items" integer DEFAULT 0,
|
|
"error" text,
|
|
"created_at" timestamp with time zone DEFAULT now(),
|
|
"completed_at" timestamp with time zone
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "tags" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"category_id" integer NOT NULL,
|
|
"name" text NOT NULL,
|
|
"display_order" integer DEFAULT 0 NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now()
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "upload_invites" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"code" text NOT NULL,
|
|
"label" text,
|
|
"created_by" integer NOT NULL,
|
|
"status" text DEFAULT 'active' NOT NULL,
|
|
"max_uploads" integer,
|
|
"upload_count" integer DEFAULT 0 NOT NULL,
|
|
"expires_at" timestamp with time zone,
|
|
"created_at" timestamp with time zone DEFAULT now(),
|
|
CONSTRAINT "upload_invites_code_unique" UNIQUE("code")
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "upvotes" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"media_id" integer NOT NULL,
|
|
"session_id" text NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now()
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "user_achievements" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"user_id" integer NOT NULL,
|
|
"achievement_id" text NOT NULL,
|
|
"unlocked_at" timestamp with time zone NOT NULL,
|
|
"progress" integer DEFAULT 0,
|
|
"notified" boolean DEFAULT false
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "user_blocks" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"user_id" integer NOT NULL,
|
|
"blocked_user_id" integer NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now()
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "user_daily_activity" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"user_id" integer NOT NULL,
|
|
"activity_date" text NOT NULL,
|
|
"watch_time_seconds" integer DEFAULT 0,
|
|
"videos_watched" integer DEFAULT 0,
|
|
"first_activity_hour" integer,
|
|
"created_at" timestamp with time zone
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "user_finishes" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"user_id" integer NOT NULL,
|
|
"media_id" integer,
|
|
"session_id" text,
|
|
"created_at" timestamp with time zone NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "user_gallery_images" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"user_id" integer NOT NULL,
|
|
"filename" text NOT NULL,
|
|
"original_filename" text,
|
|
"position" integer DEFAULT 0 NOT NULL,
|
|
"uploaded_at" timestamp with time zone DEFAULT now()
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "user_presence" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"user_id" integer NOT NULL,
|
|
"is_online" boolean DEFAULT false,
|
|
"current_media_id" integer,
|
|
"last_activity_at" timestamp with time zone,
|
|
"last_video_change_at" timestamp with time zone,
|
|
CONSTRAINT "user_presence_user_id_unique" UNIQUE("user_id")
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "user_social_links" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"user_id" integer NOT NULL,
|
|
"platform" text NOT NULL,
|
|
"url" text NOT NULL,
|
|
"display_name" text,
|
|
"position" integer DEFAULT 0 NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now()
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "user_stats" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"user_id" integer NOT NULL,
|
|
"total_watch_time_seconds" integer DEFAULT 0,
|
|
"total_videos_watched" integer DEFAULT 0,
|
|
"total_upvotes_given" integer DEFAULT 0,
|
|
"total_comments_made" integer DEFAULT 0,
|
|
"total_finishes" integer DEFAULT 0,
|
|
"current_day_streak" integer DEFAULT 0,
|
|
"longest_day_streak" integer DEFAULT 0,
|
|
"last_active_date" text,
|
|
"longest_single_session" integer DEFAULT 0,
|
|
"categories_completed" jsonb,
|
|
"night_owl_count" integer DEFAULT 0,
|
|
"early_bird_count" integer DEFAULT 0,
|
|
"updated_at" timestamp with time zone,
|
|
CONSTRAINT "user_stats_user_id_unique" UNIQUE("user_id")
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "user_subscriptions" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"user_id" integer NOT NULL,
|
|
"plan_id" integer,
|
|
"status" text DEFAULT 'inactive' NOT NULL,
|
|
"start_date" timestamp with time zone,
|
|
"end_date" timestamp with time zone,
|
|
"grace_period_end_date" timestamp with time zone,
|
|
"last_payment_id" integer,
|
|
"auto_renew" boolean DEFAULT true,
|
|
"notes" text,
|
|
"created_at" timestamp with time zone DEFAULT now(),
|
|
"updated_at" timestamp with time zone
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "user_tag_preferences" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"user_id" integer NOT NULL,
|
|
"tag_id" integer NOT NULL,
|
|
"saved_at" timestamp with time zone DEFAULT now()
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "user_upload_suggested_tags" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"upload_id" integer NOT NULL,
|
|
"tag_id" integer NOT NULL,
|
|
"suggested_at" timestamp with time zone DEFAULT now()
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "user_uploads" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"user_id" integer NOT NULL,
|
|
"filename" text NOT NULL,
|
|
"original_filename" text,
|
|
"path" text NOT NULL,
|
|
"duration_seconds" integer,
|
|
"quality" text,
|
|
"orientation" text,
|
|
"file_size" bigint,
|
|
"thumbnail_path" text,
|
|
"status" text DEFAULT 'pending' NOT NULL,
|
|
"reviewed_by" integer,
|
|
"reviewed_at" timestamp with time zone,
|
|
"review_notes" text,
|
|
"public_media_id" integer,
|
|
"upload_invite_id" integer,
|
|
"created_at" timestamp with time zone DEFAULT now()
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "users" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"username" text NOT NULL,
|
|
"email" text NOT NULL,
|
|
"password_hash" text NOT NULL,
|
|
"role" text DEFAULT 'user' NOT NULL,
|
|
"status" text DEFAULT 'pending' NOT NULL,
|
|
"email_verified" boolean DEFAULT false,
|
|
"linked_session_id" text,
|
|
"created_at" timestamp with time zone DEFAULT now(),
|
|
"approved_at" timestamp with time zone,
|
|
"approved_by" integer,
|
|
"last_login_at" timestamp with time zone,
|
|
"is_trusted" boolean DEFAULT false,
|
|
"max_upload_duration_seconds" integer DEFAULT 60,
|
|
"auto_accept_uploads" boolean DEFAULT false,
|
|
"trusted_at" timestamp with time zone,
|
|
"trusted_by" integer,
|
|
"default_playlist_id" integer,
|
|
"social_links_public" boolean DEFAULT false,
|
|
"subscription_status" text DEFAULT 'none',
|
|
"subscription_plan_id" integer,
|
|
"subscription_end_date" timestamp with time zone,
|
|
"lifetime_member" boolean DEFAULT false,
|
|
"total_paid_cad" integer DEFAULT 0,
|
|
"last_moderation_action" timestamp with time zone,
|
|
CONSTRAINT "users_username_unique" UNIQUE("username"),
|
|
CONSTRAINT "users_email_unique" UNIQUE("email")
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "video_digests" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"video_id" integer NOT NULL,
|
|
"job_id" integer,
|
|
"status" text DEFAULT 'pending' NOT NULL,
|
|
"progress" integer DEFAULT 0,
|
|
"frame_count" integer,
|
|
"config" jsonb,
|
|
"frame_analyses" jsonb,
|
|
"transcript" jsonb,
|
|
"tags" jsonb,
|
|
"suggested_clips" jsonb,
|
|
"ad_cut_spec" jsonb,
|
|
"stage_results" jsonb,
|
|
"created_at" timestamp with time zone DEFAULT now(),
|
|
"started_at" timestamp with time zone,
|
|
"completed_at" timestamp with time zone,
|
|
"error" text
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "video_ocr_results" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"digest_id" integer NOT NULL,
|
|
"video_id" integer NOT NULL,
|
|
"frame_index" integer NOT NULL,
|
|
"timestamp" real NOT NULL,
|
|
"extracted_text" text NOT NULL,
|
|
"confidence" real,
|
|
"text_type" text,
|
|
"source_frame" text NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now()
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "video_reactions" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"user_id" integer NOT NULL,
|
|
"media_id" integer NOT NULL,
|
|
"reaction_type" text NOT NULL,
|
|
"video_timestamp" integer NOT NULL,
|
|
"created_at" timestamp with time zone NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "video_recommendations" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"from_user_id" integer NOT NULL,
|
|
"to_user_id" integer NOT NULL,
|
|
"media_id" integer NOT NULL,
|
|
"message" text,
|
|
"is_read" boolean DEFAULT false,
|
|
"created_at" timestamp with time zone DEFAULT now()
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "video_scene_cuts" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"video_id" integer NOT NULL,
|
|
"cuts" jsonb NOT NULL,
|
|
"scene_count" integer NOT NULL,
|
|
"duration" real NOT NULL,
|
|
"detector" text DEFAULT 'content' NOT NULL,
|
|
"threshold" real DEFAULT 27 NOT NULL,
|
|
"transnet_cuts" jsonb,
|
|
"pyscenedetect_cuts" jsonb,
|
|
"clip_cuts" jsonb,
|
|
"merged_cuts_detailed" jsonb,
|
|
"merge_strategy" text DEFAULT 'weighted',
|
|
"tolerance_seconds" real DEFAULT 0.75,
|
|
"detectors_used" jsonb,
|
|
"processing_time_ms" integer,
|
|
"created_at" timestamp with time zone DEFAULT now()
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "video_segments" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"digest_id" integer NOT NULL,
|
|
"video_id" integer NOT NULL,
|
|
"segment_type" text NOT NULL,
|
|
"start_time" real NOT NULL,
|
|
"end_time" real NOT NULL,
|
|
"duration" real NOT NULL,
|
|
"tags" jsonb,
|
|
"transcript_snippet" text,
|
|
"vocal_category" text,
|
|
"position_change" text,
|
|
"dominant_position" text,
|
|
"interest_score" real DEFAULT 0,
|
|
"has_eye_contact" boolean DEFAULT false,
|
|
"has_full_sentence" boolean DEFAULT false,
|
|
"is_climax_moment" boolean DEFAULT false,
|
|
"captioned" boolean DEFAULT false,
|
|
"caption_text" text,
|
|
"title" text,
|
|
"keyframe_path" text,
|
|
"keyframe_timestamp" real,
|
|
"is_included" boolean DEFAULT true,
|
|
"sequence_order" integer,
|
|
"is_hook" boolean DEFAULT false,
|
|
"include_in_clips" boolean DEFAULT true,
|
|
"created_at" timestamp with time zone DEFAULT now()
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "video_tag_timeline" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"video_id" integer NOT NULL,
|
|
"digest_id" integer NOT NULL,
|
|
"timestamp" real NOT NULL,
|
|
"tags" jsonb NOT NULL,
|
|
"dominant_position" text,
|
|
"performer_count" integer,
|
|
"intensity" integer,
|
|
"has_dialogue" boolean DEFAULT false,
|
|
"has_eye_contact" boolean DEFAULT false,
|
|
"frame_path" text,
|
|
"created_at" timestamp with time zone DEFAULT now()
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "video_tags" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"video_id" integer NOT NULL,
|
|
"tag_id" integer NOT NULL,
|
|
"confidence" integer,
|
|
"source" text DEFAULT 'manual' NOT NULL,
|
|
"digest_id" integer,
|
|
"created_at" timestamp with time zone DEFAULT now()
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "videos" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"path" text NOT NULL,
|
|
"filename" text NOT NULL,
|
|
"producer" text,
|
|
"creator" text,
|
|
"title" text,
|
|
"duration_seconds" integer,
|
|
"quality" text,
|
|
"orientation" text,
|
|
"has_audio" boolean DEFAULT true,
|
|
"file_size" bigint,
|
|
"file_hash" text,
|
|
"width" integer,
|
|
"height" integer,
|
|
"last_validated" timestamp with time zone,
|
|
"is_valid" boolean DEFAULT true,
|
|
"thumbnail_path" text,
|
|
"created_at" timestamp with time zone DEFAULT now(),
|
|
"tags" jsonb,
|
|
"directory_type" text,
|
|
"public_view_count" integer,
|
|
"public_upvote_count" integer,
|
|
"public_comment_count" integer,
|
|
"public_completion_count" integer,
|
|
"public_total_watch_time" integer,
|
|
"moved_from_public_at" timestamp with time zone,
|
|
"original_filename" text,
|
|
"original_path" text,
|
|
"standardized_at" timestamp with time zone,
|
|
CONSTRAINT "videos_path_unique" UNIQUE("path")
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "views" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"media_id" integer NOT NULL,
|
|
"session_id" text NOT NULL,
|
|
"watch_time_seconds" integer DEFAULT 0,
|
|
"last_updated" timestamp with time zone DEFAULT now(),
|
|
"created_at" timestamp with time zone DEFAULT now()
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "watch_party_chat_messages" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"party_id" integer NOT NULL,
|
|
"user_id" integer NOT NULL,
|
|
"content" text NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now()
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "watch_party_invites" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"party_id" integer NOT NULL,
|
|
"from_user_id" integer NOT NULL,
|
|
"to_user_id" integer NOT NULL,
|
|
"status" text DEFAULT 'pending' NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now(),
|
|
"responded_at" timestamp with time zone
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "watch_party_participants" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"party_id" integer NOT NULL,
|
|
"user_id" integer NOT NULL,
|
|
"is_connected" boolean DEFAULT false,
|
|
"is_kicked" boolean DEFAULT false,
|
|
"joined_at" timestamp with time zone DEFAULT now(),
|
|
"left_at" timestamp with time zone
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "watch_party_reactions" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"party_id" integer NOT NULL,
|
|
"user_id" integer NOT NULL,
|
|
"reaction_type" text NOT NULL,
|
|
"video_timestamp" integer,
|
|
"created_at" timestamp with time zone DEFAULT now()
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "watch_party_sessions" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"host_id" integer NOT NULL,
|
|
"media_id" integer NOT NULL,
|
|
"invite_code" text NOT NULL,
|
|
"status" text DEFAULT 'waiting' NOT NULL,
|
|
"current_time" integer DEFAULT 0,
|
|
"is_playing" boolean DEFAULT false,
|
|
"max_participants" integer DEFAULT 20,
|
|
"allow_chat" boolean DEFAULT true,
|
|
"created_at" timestamp with time zone DEFAULT now(),
|
|
"started_at" timestamp with time zone,
|
|
"ended_at" timestamp with time zone,
|
|
"summary_stats" jsonb,
|
|
CONSTRAINT "watch_party_sessions_invite_code_unique" UNIQUE("invite_code")
|
|
);
|
|
--> statement-breakpoint
|
|
ALTER TABLE "ad_clicks" ADD CONSTRAINT "ad_clicks_ad_id_ads_id_fk" FOREIGN KEY ("ad_id") REFERENCES "public"."ads"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "ad_impressions" ADD CONSTRAINT "ad_impressions_ad_id_ads_id_fk" FOREIGN KEY ("ad_id") REFERENCES "public"."ads"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "close_friends" ADD CONSTRAINT "close_friends_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "close_friends" ADD CONSTRAINT "close_friends_close_friend_id_users_id_fk" FOREIGN KEY ("close_friend_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "geo_blocking_rules" ADD CONSTRAINT "geo_blocking_rules_created_by_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "invoices" ADD CONSTRAINT "invoices_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "invoices" ADD CONSTRAINT "invoices_plan_id_subscription_plans_id_fk" FOREIGN KEY ("plan_id") REFERENCES "public"."subscription_plans"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "notification_preferences" ADD CONSTRAINT "notification_preferences_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "notifications" ADD CONSTRAINT "notifications_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "notifications" ADD CONSTRAINT "notifications_actor_id_users_id_fk" FOREIGN KEY ("actor_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "payment_audit_log" ADD CONSTRAINT "payment_audit_log_payment_id_payments_id_fk" FOREIGN KEY ("payment_id") REFERENCES "public"."payments"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "payment_audit_log" ADD CONSTRAINT "payment_audit_log_invoice_id_invoices_id_fk" FOREIGN KEY ("invoice_id") REFERENCES "public"."invoices"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "payment_audit_log" ADD CONSTRAINT "payment_audit_log_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "payments" ADD CONSTRAINT "payments_invoice_id_invoices_id_fk" FOREIGN KEY ("invoice_id") REFERENCES "public"."invoices"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "payments" ADD CONSTRAINT "payments_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "performer_discrepancies" ADD CONSTRAINT "performer_discrepancies_video_id_videos_id_fk" FOREIGN KEY ("video_id") REFERENCES "public"."videos"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "performer_discrepancies" ADD CONSTRAINT "performer_discrepancies_digest_id_video_digests_id_fk" FOREIGN KEY ("digest_id") REFERENCES "public"."video_digests"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "performer_discrepancies" ADD CONSTRAINT "performer_discrepancies_detected_performer_id_creators_id_fk" FOREIGN KEY ("detected_performer_id") REFERENCES "public"."creators"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "performer_discrepancies" ADD CONSTRAINT "performer_discrepancies_resolved_by_users_id_fk" FOREIGN KEY ("resolved_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "pipeline_step_events" ADD CONSTRAINT "pipeline_step_events_step_id_pipeline_steps_id_fk" FOREIGN KEY ("step_id") REFERENCES "public"."pipeline_steps"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "pipeline_steps" ADD CONSTRAINT "pipeline_steps_pipeline_id_pipelines_id_fk" FOREIGN KEY ("pipeline_id") REFERENCES "public"."pipelines"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "privacy_settings" ADD CONSTRAINT "privacy_settings_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "published_inbox_files" ADD CONSTRAINT "published_inbox_files_public_media_id_public_media_id_fk" FOREIGN KEY ("public_media_id") REFERENCES "public"."public_media"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "user_subscriptions" ADD CONSTRAINT "user_subscriptions_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "user_subscriptions" ADD CONSTRAINT "user_subscriptions_plan_id_subscription_plans_id_fk" FOREIGN KEY ("plan_id") REFERENCES "public"."subscription_plans"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "watch_party_chat_messages" ADD CONSTRAINT "watch_party_chat_messages_party_id_watch_party_sessions_id_fk" FOREIGN KEY ("party_id") REFERENCES "public"."watch_party_sessions"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "watch_party_chat_messages" ADD CONSTRAINT "watch_party_chat_messages_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "watch_party_invites" ADD CONSTRAINT "watch_party_invites_party_id_watch_party_sessions_id_fk" FOREIGN KEY ("party_id") REFERENCES "public"."watch_party_sessions"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "watch_party_invites" ADD CONSTRAINT "watch_party_invites_from_user_id_users_id_fk" FOREIGN KEY ("from_user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "watch_party_invites" ADD CONSTRAINT "watch_party_invites_to_user_id_users_id_fk" FOREIGN KEY ("to_user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "watch_party_participants" ADD CONSTRAINT "watch_party_participants_party_id_watch_party_sessions_id_fk" FOREIGN KEY ("party_id") REFERENCES "public"."watch_party_sessions"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "watch_party_participants" ADD CONSTRAINT "watch_party_participants_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "watch_party_reactions" ADD CONSTRAINT "watch_party_reactions_party_id_watch_party_sessions_id_fk" FOREIGN KEY ("party_id") REFERENCES "public"."watch_party_sessions"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "watch_party_reactions" ADD CONSTRAINT "watch_party_reactions_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "watch_party_sessions" ADD CONSTRAINT "watch_party_sessions_host_id_users_id_fk" FOREIGN KEY ("host_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "watch_party_sessions" ADD CONSTRAINT "watch_party_sessions_media_id_public_media_id_fk" FOREIGN KEY ("media_id") REFERENCES "public"."public_media"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
CREATE INDEX "idx_ad_clicks_ad" ON "ad_clicks" USING btree ("ad_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_ad_clicks_session" ON "ad_clicks" USING btree ("session_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_ad_clicks_date" ON "ad_clicks" USING btree ("created_at");--> statement-breakpoint
|
|
CREATE INDEX "idx_ad_impressions_ad" ON "ad_impressions" USING btree ("ad_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_ad_impressions_session" ON "ad_impressions" USING btree ("session_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_ad_impressions_date" ON "ad_impressions" USING btree ("created_at");--> statement-breakpoint
|
|
CREATE INDEX "idx_ads_type" ON "ads" USING btree ("type");--> statement-breakpoint
|
|
CREATE INDEX "idx_ads_is_active" ON "ads" USING btree ("is_active");--> statement-breakpoint
|
|
CREATE INDEX "idx_ads_visibility" ON "ads" USING btree ("visibility");--> statement-breakpoint
|
|
CREATE INDEX "idx_auth_tokens_token" ON "auth_tokens" USING btree ("token");--> statement-breakpoint
|
|
CREATE INDEX "idx_auth_tokens_user" ON "auth_tokens" USING btree ("user_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_chat_thread_read_unique" ON "chat_thread_read_status" USING btree ("user_id","media_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_chat_thread_read_user" ON "chat_thread_read_status" USING btree ("user_id");--> statement-breakpoint
|
|
CREATE UNIQUE INDEX "idx_close_friends_unique" ON "close_friends" USING btree ("user_id","close_friend_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_close_friends_user" ON "close_friends" USING btree ("user_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_comment_moderation_comment" ON "comment_moderation" USING btree ("comment_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_comment_moderation_status" ON "comment_moderation" USING btree ("status");--> statement-breakpoint
|
|
CREATE INDEX "idx_comments_media" ON "comments" USING btree ("media_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_comments_session" ON "comments" USING btree ("session_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_comments_user" ON "comments" USING btree ("user_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_comments_safety_status" ON "comments" USING btree ("safety_status");--> statement-breakpoint
|
|
CREATE INDEX "idx_comments_is_hidden" ON "comments" USING btree ("is_hidden");--> statement-breakpoint
|
|
CREATE INDEX "idx_content_reports_media" ON "content_reports" USING btree ("media_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_content_reports_status" ON "content_reports" USING btree ("status");--> statement-breakpoint
|
|
CREATE INDEX "idx_content_reports_session" ON "content_reports" USING btree ("session_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_content_reports_created" ON "content_reports" USING btree ("created_at");--> statement-breakpoint
|
|
CREATE INDEX "idx_creators_name" ON "creators" USING btree ("name");--> statement-breakpoint
|
|
CREATE INDEX "idx_creators_slug" ON "creators" USING btree ("slug");--> statement-breakpoint
|
|
CREATE INDEX "idx_creators_gender" ON "creators" USING btree ("gender");--> statement-breakpoint
|
|
CREATE INDEX "idx_creators_tag" ON "creators" USING btree ("tag_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_creators_public" ON "creators" USING btree ("is_public");--> statement-breakpoint
|
|
CREATE INDEX "idx_digest_clip_tags_clip" ON "digest_clip_tags" USING btree ("clip_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_digest_clip_tags_tag" ON "digest_clip_tags" USING btree ("tag_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_digest_clip_tags_unique" ON "digest_clip_tags" USING btree ("clip_id","tag_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_digest_compilations_digest" ON "digest_compilations" USING btree ("digest_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_digest_compilations_video" ON "digest_compilations" USING btree ("video_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_digest_compilations_status" ON "digest_compilations" USING btree ("status");--> statement-breakpoint
|
|
CREATE INDEX "idx_digest_compilations_folder" ON "digest_compilations" USING btree ("folder_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_digest_generated_clips_selected" ON "digest_generated_clips" USING btree ("selected_clip_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_digest_generated_clips_digest" ON "digest_generated_clips" USING btree ("digest_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_digest_generated_clips_status" ON "digest_generated_clips" USING btree ("status");--> statement-breakpoint
|
|
CREATE INDEX "idx_digest_generated_clips_folder" ON "digest_generated_clips" USING btree ("folder_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_digest_generated_scenes_digest" ON "digest_generated_scenes" USING btree ("digest_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_digest_generated_scenes_video" ON "digest_generated_scenes" USING btree ("video_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_digest_generated_scenes_folder" ON "digest_generated_scenes" USING btree ("folder_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_digest_generated_scenes_path" ON "digest_generated_scenes" USING btree ("scene_path");--> statement-breakpoint
|
|
CREATE INDEX "idx_digest_output_folders_digest" ON "digest_output_folders" USING btree ("digest_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_digest_output_folders_video" ON "digest_output_folders" USING btree ("video_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_digest_output_folders_path" ON "digest_output_folders" USING btree ("folder_path");--> statement-breakpoint
|
|
CREATE INDEX "idx_digest_selected_clips_digest" ON "digest_selected_clips" USING btree ("digest_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_digest_selected_clips_video" ON "digest_selected_clips" USING btree ("video_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_digest_selected_clips_type" ON "digest_selected_clips" USING btree ("clip_type");--> statement-breakpoint
|
|
CREATE INDEX "idx_digest_selected_clips_source" ON "digest_selected_clips" USING btree ("source");--> statement-breakpoint
|
|
CREATE INDEX "idx_digest_selected_clips_sequence" ON "digest_selected_clips" USING btree ("sequence_order");--> statement-breakpoint
|
|
CREATE INDEX "idx_digest_selected_clips_is_hook" ON "digest_selected_clips" USING btree ("is_hook");--> statement-breakpoint
|
|
CREATE INDEX "idx_digest_selected_clips_hook_source" ON "digest_selected_clips" USING btree ("hook_source_clip_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_digest_suggested_tags_digest" ON "digest_suggested_tags" USING btree ("digest_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_digest_suggested_tags_video" ON "digest_suggested_tags" USING btree ("video_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_digest_suggested_tags_status" ON "digest_suggested_tags" USING btree ("status");--> statement-breakpoint
|
|
CREATE INDEX "idx_digest_suggested_tags_cat_val" ON "digest_suggested_tags" USING btree ("suggested_category","suggested_value");--> statement-breakpoint
|
|
CREATE INDEX "idx_digest_video_tags_digest" ON "digest_video_tags" USING btree ("digest_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_digest_video_tags_video" ON "digest_video_tags" USING btree ("video_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_digest_video_tags_category" ON "digest_video_tags" USING btree ("category");--> statement-breakpoint
|
|
CREATE INDEX "idx_digest_video_tags_value" ON "digest_video_tags" USING btree ("value");--> statement-breakpoint
|
|
CREATE INDEX "idx_digest_video_tags_cat_val" ON "digest_video_tags" USING btree ("category","value");--> statement-breakpoint
|
|
CREATE INDEX "idx_email_change_tokens_token" ON "email_change_tokens" USING btree ("token");--> statement-breakpoint
|
|
CREATE INDEX "idx_email_change_tokens_user" ON "email_change_tokens" USING btree ("user_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_email_verification_tokens_token" ON "email_verification_tokens" USING btree ("token");--> statement-breakpoint
|
|
CREATE INDEX "idx_email_verification_tokens_user" ON "email_verification_tokens" USING btree ("user_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_featured_playlists_position" ON "featured_playlists" USING btree ("position");--> statement-breakpoint
|
|
CREATE INDEX "idx_friendships_user_friend" ON "friendships" USING btree ("user_id","friend_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_friendships_user" ON "friendships" USING btree ("user_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_friendships_friend" ON "friendships" USING btree ("friend_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_friendships_status" ON "friendships" USING btree ("status");--> statement-breakpoint
|
|
CREATE INDEX "idx_geo_blocking_country" ON "geo_blocking_rules" USING btree ("country");--> statement-breakpoint
|
|
CREATE UNIQUE INDEX "idx_geo_blocking_unique" ON "geo_blocking_rules" USING btree ("country","region","city");--> statement-breakpoint
|
|
CREATE INDEX "idx_highlight_cooldowns_user" ON "highlight_cooldowns" USING btree ("user_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_invoices_user" ON "invoices" USING btree ("user_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_invoices_status" ON "invoices" USING btree ("status");--> statement-breakpoint
|
|
CREATE INDEX "idx_invoices_due_date" ON "invoices" USING btree ("due_date");--> statement-breakpoint
|
|
CREATE INDEX "idx_invoices_number" ON "invoices" USING btree ("invoice_number");--> statement-breakpoint
|
|
CREATE INDEX "idx_jobs_queue" ON "jobs" USING btree ("status","priority","created_at");--> statement-breakpoint
|
|
CREATE INDEX "idx_jobs_resource" ON "jobs" USING btree ("resource_category","status");--> statement-breakpoint
|
|
CREATE INDEX "idx_jobs_pipeline" ON "jobs" USING btree ("pipeline_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_moderation_word_lists_level" ON "moderation_word_lists" USING btree ("level");--> statement-breakpoint
|
|
CREATE INDEX "idx_moderation_word_lists_word" ON "moderation_word_lists" USING btree ("word");--> statement-breakpoint
|
|
CREATE INDEX "idx_notification_preferences_user" ON "notification_preferences" USING btree ("user_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_notifications_user_unread" ON "notifications" USING btree ("user_id","is_read");--> statement-breakpoint
|
|
CREATE INDEX "idx_notifications_user_created" ON "notifications" USING btree ("user_id","created_at");--> statement-breakpoint
|
|
CREATE INDEX "idx_notifications_type" ON "notifications" USING btree ("type");--> statement-breakpoint
|
|
CREATE INDEX "idx_notifications_created" ON "notifications" USING btree ("created_at");--> statement-breakpoint
|
|
CREATE INDEX "idx_notifications_actor" ON "notifications" USING btree ("actor_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_password_reset_tokens_token" ON "password_reset_tokens" USING btree ("token");--> statement-breakpoint
|
|
CREATE INDEX "idx_password_reset_tokens_user" ON "password_reset_tokens" USING btree ("user_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_payment_audit_payment" ON "payment_audit_log" USING btree ("payment_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_payment_audit_invoice" ON "payment_audit_log" USING btree ("invoice_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_payment_audit_user" ON "payment_audit_log" USING btree ("user_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_payment_audit_action" ON "payment_audit_log" USING btree ("action");--> statement-breakpoint
|
|
CREATE INDEX "idx_payment_audit_created" ON "payment_audit_log" USING btree ("created_at");--> statement-breakpoint
|
|
CREATE INDEX "idx_payments_user" ON "payments" USING btree ("user_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_payments_invoice" ON "payments" USING btree ("invoice_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_payments_status" ON "payments" USING btree ("status");--> statement-breakpoint
|
|
CREATE INDEX "idx_payments_sender_email" ON "payments" USING btree ("sender_email");--> statement-breakpoint
|
|
CREATE INDEX "idx_payments_reference" ON "payments" USING btree ("reference_number");--> statement-breakpoint
|
|
CREATE INDEX "idx_payments_received_at" ON "payments" USING btree ("received_at");--> statement-breakpoint
|
|
CREATE INDEX "idx_discrepancies_video" ON "performer_discrepancies" USING btree ("video_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_discrepancies_digest" ON "performer_discrepancies" USING btree ("digest_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_discrepancies_status" ON "performer_discrepancies" USING btree ("status");--> statement-breakpoint
|
|
CREATE INDEX "idx_discrepancies_type" ON "performer_discrepancies" USING btree ("discrepancy_type");--> statement-breakpoint
|
|
CREATE INDEX "idx_discrepancies_detected_performer" ON "performer_discrepancies" USING btree ("detected_performer_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_performer_faces_performer" ON "performer_faces" USING btree ("performer_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_performer_faces_name" ON "performer_faces" USING btree ("performer_name");--> statement-breakpoint
|
|
CREATE INDEX "idx_performer_faces_video" ON "performer_faces" USING btree ("source_video");--> statement-breakpoint
|
|
CREATE INDEX "idx_performer_faces_gender" ON "performer_faces" USING btree ("gender");--> statement-breakpoint
|
|
CREATE INDEX "idx_performer_faces_digest" ON "performer_faces" USING btree ("source_digest_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_performer_faces_crop" ON "performer_faces" USING btree ("face_crop_path");--> statement-breakpoint
|
|
CREATE INDEX "idx_performer_faces_status" ON "performer_faces" USING btree ("status");--> statement-breakpoint
|
|
CREATE INDEX "idx_performer_faces_faces_in_frame" ON "performer_faces" USING btree ("faces_in_frame");--> statement-breakpoint
|
|
CREATE INDEX "idx_performer_faces_det_score" ON "performer_faces" USING btree ("detection_score");--> statement-breakpoint
|
|
CREATE INDEX "idx_pipeline_step_events_step" ON "pipeline_step_events" USING btree ("step_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_pipeline_step_events_created" ON "pipeline_step_events" USING btree ("created_at");--> statement-breakpoint
|
|
CREATE INDEX "idx_pipeline_steps_pipeline" ON "pipeline_steps" USING btree ("pipeline_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_pipeline_steps_sequence" ON "pipeline_steps" USING btree ("pipeline_id","sequence_order");--> statement-breakpoint
|
|
CREATE INDEX "idx_pipeline_steps_status" ON "pipeline_steps" USING btree ("status");--> statement-breakpoint
|
|
CREATE INDEX "idx_pipeline_templates_name" ON "pipeline_templates" USING btree ("name");--> statement-breakpoint
|
|
CREATE INDEX "idx_pipelines_status" ON "pipelines" USING btree ("status");--> statement-breakpoint
|
|
CREATE INDEX "idx_pipelines_priority" ON "pipelines" USING btree ("priority","created_at");--> statement-breakpoint
|
|
CREATE INDEX "idx_pipelines_heartbeat" ON "pipelines" USING btree ("last_heartbeat");--> statement-breakpoint
|
|
CREATE INDEX "idx_playlist_videos_playlist" ON "playlist_videos" USING btree ("playlist_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_playlist_videos_media" ON "playlist_videos" USING btree ("media_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_playlist_videos_unique" ON "playlist_videos" USING btree ("playlist_id","media_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_playlist_views_playlist" ON "playlist_views" USING btree ("playlist_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_playlist_views_unique" ON "playlist_views" USING btree ("playlist_id","session_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_playlists_user" ON "playlists" USING btree ("user_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_playlists_public" ON "playlists" USING btree ("is_public");--> statement-breakpoint
|
|
CREATE INDEX "idx_playlists_share_token" ON "playlists" USING btree ("share_token");--> statement-breakpoint
|
|
CREATE UNIQUE INDEX "idx_playlists_user_name" ON "playlists" USING btree ("user_id","name");--> statement-breakpoint
|
|
CREATE INDEX "idx_pokes_to_user" ON "pokes" USING btree ("to_user_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_pokes_from_user" ON "pokes" USING btree ("from_user_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_privacy_settings_user" ON "privacy_settings" USING btree ("user_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_public_media_category" ON "public_media" USING btree ("category");--> statement-breakpoint
|
|
CREATE INDEX "idx_public_media_path" ON "public_media" USING btree ("path");--> statement-breakpoint
|
|
CREATE INDEX "idx_public_media_is_locked" ON "public_media" USING btree ("is_locked");--> statement-breakpoint
|
|
CREATE INDEX "idx_public_media_position" ON "public_media" USING btree ("position");--> statement-breakpoint
|
|
CREATE INDEX "idx_public_media_uploader" ON "public_media" USING btree ("uploader_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_public_media_category_date" ON "public_media" USING btree ("category","created_at");--> statement-breakpoint
|
|
CREATE INDEX "idx_public_media_orientation" ON "public_media" USING btree ("orientation");--> statement-breakpoint
|
|
CREATE INDEX "idx_public_media_category_locked_date" ON "public_media" USING btree ("category","is_locked","created_at");--> statement-breakpoint
|
|
CREATE INDEX "idx_public_media_performers_media" ON "public_media_performers" USING btree ("media_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_public_media_performers_performer" ON "public_media_performers" USING btree ("performer_id");--> statement-breakpoint
|
|
CREATE UNIQUE INDEX "idx_public_media_performers_unique" ON "public_media_performers" USING btree ("media_id","performer_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_public_media_tags_media" ON "public_media_tags" USING btree ("media_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_public_media_tags_tag" ON "public_media_tags" USING btree ("tag_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_public_media_tags_unique" ON "public_media_tags" USING btree ("media_id","tag_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_published_inbox_source" ON "published_inbox_files" USING btree ("source_inbox_path");--> statement-breakpoint
|
|
CREATE INDEX "idx_published_inbox_file_type" ON "published_inbox_files" USING btree ("file_type");--> statement-breakpoint
|
|
CREATE UNIQUE INDEX "idx_rate_limits_key" ON "rate_limits" USING btree ("key");--> statement-breakpoint
|
|
CREATE INDEX "idx_rate_limits_reset_at" ON "rate_limits" USING btree ("reset_at");--> statement-breakpoint
|
|
CREATE INDEX "idx_resource_snapshots_created" ON "resource_snapshots" USING btree ("created_at");--> statement-breakpoint
|
|
CREATE INDEX "idx_resource_snapshots_pipeline" ON "resource_snapshots" USING btree ("pipeline_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_session_bans_session" ON "session_bans" USING btree ("session_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_sessions_user_id" ON "sessions" USING btree ("user_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_sessions_country" ON "sessions" USING btree ("country");--> statement-breakpoint
|
|
CREATE INDEX "idx_tag_categories_display_order" ON "tag_categories" USING btree ("display_order");--> statement-breakpoint
|
|
CREATE INDEX "idx_tag_gen_status" ON "tag_generation_jobs" USING btree ("status");--> statement-breakpoint
|
|
CREATE INDEX "idx_tag_gen_content_type" ON "tag_generation_jobs" USING btree ("content_type");--> statement-breakpoint
|
|
CREATE INDEX "idx_tag_gen_created_at" ON "tag_generation_jobs" USING btree ("created_at");--> statement-breakpoint
|
|
CREATE INDEX "idx_tags_category" ON "tags" USING btree ("category_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_tags_display_order" ON "tags" USING btree ("display_order");--> statement-breakpoint
|
|
CREATE INDEX "idx_tags_unique_name" ON "tags" USING btree ("category_id","name");--> statement-breakpoint
|
|
CREATE INDEX "idx_upload_invites_code" ON "upload_invites" USING btree ("code");--> statement-breakpoint
|
|
CREATE INDEX "idx_upload_invites_status" ON "upload_invites" USING btree ("status");--> statement-breakpoint
|
|
CREATE INDEX "idx_upload_invites_created_by" ON "upload_invites" USING btree ("created_by");--> statement-breakpoint
|
|
CREATE INDEX "idx_upvotes_unique" ON "upvotes" USING btree ("media_id","session_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_upvotes_media" ON "upvotes" USING btree ("media_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_user_achievements_user" ON "user_achievements" USING btree ("user_id");--> statement-breakpoint
|
|
CREATE UNIQUE INDEX "idx_user_achievements_unique" ON "user_achievements" USING btree ("user_id","achievement_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_user_blocks_unique" ON "user_blocks" USING btree ("user_id","blocked_user_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_user_blocks_user" ON "user_blocks" USING btree ("user_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_user_daily_activity_unique" ON "user_daily_activity" USING btree ("user_id","activity_date");--> statement-breakpoint
|
|
CREATE INDEX "idx_user_finishes_user" ON "user_finishes" USING btree ("user_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_user_finishes_date" ON "user_finishes" USING btree ("created_at");--> statement-breakpoint
|
|
CREATE INDEX "idx_user_gallery_user" ON "user_gallery_images" USING btree ("user_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_user_gallery_position" ON "user_gallery_images" USING btree ("user_id","position");--> statement-breakpoint
|
|
CREATE INDEX "idx_user_presence_online" ON "user_presence" USING btree ("is_online");--> statement-breakpoint
|
|
CREATE INDEX "idx_user_presence_user" ON "user_presence" USING btree ("user_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_user_social_links_user" ON "user_social_links" USING btree ("user_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_user_social_links_position" ON "user_social_links" USING btree ("user_id","position");--> statement-breakpoint
|
|
CREATE UNIQUE INDEX "idx_user_subscriptions_user" ON "user_subscriptions" USING btree ("user_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_user_subscriptions_status" ON "user_subscriptions" USING btree ("status");--> statement-breakpoint
|
|
CREATE INDEX "idx_user_subscriptions_end_date" ON "user_subscriptions" USING btree ("end_date");--> statement-breakpoint
|
|
CREATE INDEX "idx_user_tag_preferences_user" ON "user_tag_preferences" USING btree ("user_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_user_tag_preferences_tag" ON "user_tag_preferences" USING btree ("tag_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_user_tag_preferences_unique" ON "user_tag_preferences" USING btree ("user_id","tag_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_user_upload_suggested_tags_upload" ON "user_upload_suggested_tags" USING btree ("upload_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_user_upload_suggested_tags_tag" ON "user_upload_suggested_tags" USING btree ("tag_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_user_upload_suggested_tags_unique" ON "user_upload_suggested_tags" USING btree ("upload_id","tag_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_user_uploads_user" ON "user_uploads" USING btree ("user_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_user_uploads_status" ON "user_uploads" USING btree ("status");--> statement-breakpoint
|
|
CREATE INDEX "idx_user_uploads_created" ON "user_uploads" USING btree ("created_at");--> statement-breakpoint
|
|
CREATE INDEX "idx_user_uploads_invite" ON "user_uploads" USING btree ("upload_invite_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_users_email" ON "users" USING btree ("email");--> statement-breakpoint
|
|
CREATE INDEX "idx_users_username" ON "users" USING btree ("username");--> statement-breakpoint
|
|
CREATE INDEX "idx_users_status" ON "users" USING btree ("status");--> statement-breakpoint
|
|
CREATE INDEX "idx_users_trusted" ON "users" USING btree ("is_trusted");--> statement-breakpoint
|
|
CREATE INDEX "idx_users_subscription_status" ON "users" USING btree ("subscription_status");--> statement-breakpoint
|
|
CREATE INDEX "idx_video_digests_video" ON "video_digests" USING btree ("video_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_video_digests_status" ON "video_digests" USING btree ("status");--> statement-breakpoint
|
|
CREATE INDEX "idx_video_digests_created" ON "video_digests" USING btree ("created_at");--> statement-breakpoint
|
|
CREATE INDEX "idx_video_ocr_results_digest" ON "video_ocr_results" USING btree ("digest_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_video_ocr_results_video" ON "video_ocr_results" USING btree ("video_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_video_reactions_user_media_type" ON "video_reactions" USING btree ("user_id","media_id","reaction_type");--> statement-breakpoint
|
|
CREATE INDEX "idx_video_reactions_media_timestamp" ON "video_reactions" USING btree ("media_id","video_timestamp");--> statement-breakpoint
|
|
CREATE INDEX "idx_video_reactions_media" ON "video_reactions" USING btree ("media_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_video_reactions_created" ON "video_reactions" USING btree ("created_at");--> statement-breakpoint
|
|
CREATE INDEX "idx_video_recommendations_to_user" ON "video_recommendations" USING btree ("to_user_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_video_recommendations_from_user" ON "video_recommendations" USING btree ("from_user_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_video_recommendations_media" ON "video_recommendations" USING btree ("media_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_video_scene_cuts_video" ON "video_scene_cuts" USING btree ("video_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_video_segments_digest" ON "video_segments" USING btree ("digest_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_video_segments_video" ON "video_segments" USING btree ("video_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_video_segments_type" ON "video_segments" USING btree ("segment_type");--> statement-breakpoint
|
|
CREATE INDEX "idx_video_segments_time" ON "video_segments" USING btree ("video_id","start_time");--> statement-breakpoint
|
|
CREATE INDEX "idx_video_segments_included" ON "video_segments" USING btree ("digest_id","is_included");--> statement-breakpoint
|
|
CREATE INDEX "idx_video_segments_sequence" ON "video_segments" USING btree ("digest_id","sequence_order");--> statement-breakpoint
|
|
CREATE INDEX "idx_video_segments_clips" ON "video_segments" USING btree ("digest_id","include_in_clips");--> statement-breakpoint
|
|
CREATE INDEX "idx_video_tag_timeline_video" ON "video_tag_timeline" USING btree ("video_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_video_tag_timeline_digest" ON "video_tag_timeline" USING btree ("digest_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_video_tag_timeline_timestamp" ON "video_tag_timeline" USING btree ("video_id","timestamp");--> statement-breakpoint
|
|
CREATE INDEX "idx_video_tag_timeline_position" ON "video_tag_timeline" USING btree ("dominant_position");--> statement-breakpoint
|
|
CREATE INDEX "idx_video_tags_video" ON "video_tags" USING btree ("video_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_video_tags_tag" ON "video_tags" USING btree ("tag_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_video_tags_source" ON "video_tags" USING btree ("source");--> statement-breakpoint
|
|
CREATE INDEX "idx_video_tags_unique" ON "video_tags" USING btree ("video_id","tag_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_orientation" ON "videos" USING btree ("orientation");--> statement-breakpoint
|
|
CREATE INDEX "idx_producer" ON "videos" USING btree ("producer");--> statement-breakpoint
|
|
CREATE INDEX "idx_is_valid" ON "videos" USING btree ("is_valid");--> statement-breakpoint
|
|
CREATE INDEX "idx_directory_type" ON "videos" USING btree ("directory_type");--> statement-breakpoint
|
|
CREATE INDEX "idx_videos_fingerprint" ON "videos" USING btree ("duration_seconds","file_size","width","height");--> statement-breakpoint
|
|
CREATE INDEX "idx_videos_directory_valid_orientation" ON "videos" USING btree ("directory_type","is_valid","orientation");--> statement-breakpoint
|
|
CREATE INDEX "idx_views_unique" ON "views" USING btree ("media_id","session_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_views_media" ON "views" USING btree ("media_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_watch_party_chat_party" ON "watch_party_chat_messages" USING btree ("party_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_watch_party_chat_created" ON "watch_party_chat_messages" USING btree ("created_at");--> statement-breakpoint
|
|
CREATE INDEX "idx_watch_party_invites_party" ON "watch_party_invites" USING btree ("party_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_watch_party_invites_to_user" ON "watch_party_invites" USING btree ("to_user_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_watch_party_invites_from_user" ON "watch_party_invites" USING btree ("from_user_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_watch_party_invites_status" ON "watch_party_invites" USING btree ("status");--> statement-breakpoint
|
|
CREATE INDEX "idx_watch_party_participants_party" ON "watch_party_participants" USING btree ("party_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_watch_party_participants_user" ON "watch_party_participants" USING btree ("user_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_watch_party_participants_unique" ON "watch_party_participants" USING btree ("party_id","user_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_watch_party_reactions_party" ON "watch_party_reactions" USING btree ("party_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_watch_party_reactions_user" ON "watch_party_reactions" USING btree ("user_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_watch_party_sessions_host" ON "watch_party_sessions" USING btree ("host_id");--> statement-breakpoint
|
|
CREATE INDEX "idx_watch_party_sessions_invite" ON "watch_party_sessions" USING btree ("invite_code");--> statement-breakpoint
|
|
CREATE INDEX "idx_watch_party_sessions_status" ON "watch_party_sessions" USING btree ("status");--> statement-breakpoint
|
|
CREATE INDEX "idx_watch_party_sessions_created" ON "watch_party_sessions" USING btree ("created_at"); |