Barazo AppView backend barazo.forum
at main 498 lines 29 kB view raw
1CREATE ROLE "barazo_app";--> statement-breakpoint 2CREATE TABLE "users" ( 3 "did" text PRIMARY KEY NOT NULL, 4 "handle" text NOT NULL, 5 "display_name" text, 6 "avatar_url" text, 7 "banner_url" text, 8 "bio" text, 9 "role" text DEFAULT 'user' NOT NULL, 10 "is_banned" boolean DEFAULT false NOT NULL, 11 "reputation_score" integer DEFAULT 0 NOT NULL, 12 "first_seen_at" timestamp with time zone DEFAULT now() NOT NULL, 13 "last_active_at" timestamp with time zone DEFAULT now() NOT NULL, 14 "declared_age" integer, 15 "maturity_pref" text DEFAULT 'safe' NOT NULL, 16 "account_created_at" timestamp with time zone, 17 "followers_count" integer DEFAULT 0 NOT NULL, 18 "follows_count" integer DEFAULT 0 NOT NULL, 19 "atproto_posts_count" integer DEFAULT 0 NOT NULL, 20 "has_bluesky_profile" boolean DEFAULT false NOT NULL, 21 "atproto_labels" jsonb DEFAULT '[]'::jsonb NOT NULL 22); 23--> statement-breakpoint 24CREATE TABLE "firehose_cursor" ( 25 "id" text PRIMARY KEY DEFAULT 'default' NOT NULL, 26 "cursor" bigint, 27 "updated_at" timestamp with time zone DEFAULT now() NOT NULL 28); 29--> statement-breakpoint 30CREATE TABLE "topics" ( 31 "uri" text PRIMARY KEY NOT NULL, 32 "rkey" text NOT NULL, 33 "author_did" text NOT NULL, 34 "title" text NOT NULL, 35 "content" text NOT NULL, 36 "content_format" text, 37 "category" text NOT NULL, 38 "tags" jsonb, 39 "community_did" text NOT NULL, 40 "cid" text NOT NULL, 41 "labels" jsonb, 42 "reply_count" integer DEFAULT 0 NOT NULL, 43 "reaction_count" integer DEFAULT 0 NOT NULL, 44 "vote_count" integer DEFAULT 0 NOT NULL, 45 "last_activity_at" timestamp with time zone DEFAULT now() NOT NULL, 46 "created_at" timestamp with time zone NOT NULL, 47 "indexed_at" timestamp with time zone DEFAULT now() NOT NULL, 48 "is_locked" boolean DEFAULT false NOT NULL, 49 "is_pinned" boolean DEFAULT false NOT NULL, 50 "is_mod_deleted" boolean DEFAULT false NOT NULL, 51 "is_author_deleted" boolean DEFAULT false NOT NULL, 52 "moderation_status" text DEFAULT 'approved' NOT NULL, 53 "trust_status" text DEFAULT 'trusted' NOT NULL 54); 55--> statement-breakpoint 56ALTER TABLE "topics" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint 57CREATE TABLE "replies" ( 58 "uri" text PRIMARY KEY NOT NULL, 59 "rkey" text NOT NULL, 60 "author_did" text NOT NULL, 61 "content" text NOT NULL, 62 "content_format" text, 63 "root_uri" text NOT NULL, 64 "root_cid" text NOT NULL, 65 "parent_uri" text NOT NULL, 66 "parent_cid" text NOT NULL, 67 "community_did" text NOT NULL, 68 "cid" text NOT NULL, 69 "labels" jsonb, 70 "reaction_count" integer DEFAULT 0 NOT NULL, 71 "vote_count" integer DEFAULT 0 NOT NULL, 72 "created_at" timestamp with time zone NOT NULL, 73 "indexed_at" timestamp with time zone DEFAULT now() NOT NULL, 74 "is_author_deleted" boolean DEFAULT false NOT NULL, 75 "is_mod_deleted" boolean DEFAULT false NOT NULL, 76 "moderation_status" text DEFAULT 'approved' NOT NULL, 77 "trust_status" text DEFAULT 'trusted' NOT NULL 78); 79--> statement-breakpoint 80ALTER TABLE "replies" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint 81CREATE TABLE "reactions" ( 82 "uri" text PRIMARY KEY NOT NULL, 83 "rkey" text NOT NULL, 84 "author_did" text NOT NULL, 85 "subject_uri" text NOT NULL, 86 "subject_cid" text NOT NULL, 87 "type" text NOT NULL, 88 "community_did" text NOT NULL, 89 "cid" text NOT NULL, 90 "created_at" timestamp with time zone NOT NULL, 91 "indexed_at" timestamp with time zone DEFAULT now() NOT NULL, 92 CONSTRAINT "reactions_author_subject_type_uniq" UNIQUE("author_did","subject_uri","type") 93); 94--> statement-breakpoint 95ALTER TABLE "reactions" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint 96CREATE TABLE "votes" ( 97 "uri" text PRIMARY KEY NOT NULL, 98 "rkey" text NOT NULL, 99 "author_did" text NOT NULL, 100 "subject_uri" text NOT NULL, 101 "subject_cid" text NOT NULL, 102 "direction" text NOT NULL, 103 "community_did" text NOT NULL, 104 "cid" text NOT NULL, 105 "created_at" timestamp with time zone NOT NULL, 106 "indexed_at" timestamp with time zone DEFAULT now() NOT NULL, 107 CONSTRAINT "votes_author_subject_uniq" UNIQUE("author_did","subject_uri") 108); 109--> statement-breakpoint 110CREATE TABLE "tracked_repos" ( 111 "did" text PRIMARY KEY NOT NULL, 112 "tracked_at" timestamp with time zone DEFAULT now() NOT NULL 113); 114--> statement-breakpoint 115CREATE TABLE "community_settings" ( 116 "community_did" text PRIMARY KEY NOT NULL, 117 "domains" jsonb DEFAULT '[]'::jsonb NOT NULL, 118 "initialized" boolean DEFAULT false NOT NULL, 119 "admin_did" text, 120 "community_name" text DEFAULT 'Barazo Community' NOT NULL, 121 "maturity_rating" text DEFAULT 'safe' NOT NULL, 122 "reaction_set" jsonb DEFAULT '["like"]'::jsonb NOT NULL, 123 "moderation_thresholds" jsonb DEFAULT '{"autoBlockReportCount":5,"warnThreshold":3,"firstPostQueueCount":3,"newAccountDays":7,"newAccountWriteRatePerMin":3,"establishedWriteRatePerMin":10,"linkHoldEnabled":true,"topicCreationDelayEnabled":true,"burstPostCount":5,"burstWindowMinutes":10,"trustedPostThreshold":10}'::jsonb NOT NULL, 124 "word_filter" jsonb DEFAULT '[]'::jsonb NOT NULL, 125 "jurisdiction_country" text, 126 "age_threshold" integer DEFAULT 16 NOT NULL, 127 "require_login_for_mature" boolean DEFAULT true NOT NULL, 128 "community_description" text, 129 "handle" text, 130 "service_endpoint" text, 131 "signing_key" text, 132 "rotation_key" text, 133 "community_logo_url" text, 134 "primary_color" text, 135 "accent_color" text, 136 "created_at" timestamp with time zone DEFAULT now() NOT NULL, 137 "updated_at" timestamp with time zone DEFAULT now() NOT NULL 138); 139--> statement-breakpoint 140ALTER TABLE "community_settings" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint 141CREATE TABLE "categories" ( 142 "id" text PRIMARY KEY NOT NULL, 143 "slug" text NOT NULL, 144 "name" text NOT NULL, 145 "description" text, 146 "parent_id" text, 147 "sort_order" integer DEFAULT 0 NOT NULL, 148 "community_did" text NOT NULL, 149 "maturity_rating" text DEFAULT 'safe' NOT NULL, 150 "created_at" timestamp with time zone DEFAULT now() NOT NULL, 151 "updated_at" timestamp with time zone DEFAULT now() NOT NULL 152); 153--> statement-breakpoint 154ALTER TABLE "categories" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint 155CREATE TABLE "moderation_actions" ( 156 "id" serial PRIMARY KEY NOT NULL, 157 "action" text NOT NULL, 158 "target_uri" text, 159 "target_did" text, 160 "moderator_did" text NOT NULL, 161 "community_did" text NOT NULL, 162 "reason" text, 163 "created_at" timestamp with time zone DEFAULT now() NOT NULL 164); 165--> statement-breakpoint 166ALTER TABLE "moderation_actions" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint 167CREATE TABLE "reports" ( 168 "id" serial PRIMARY KEY NOT NULL, 169 "reporter_did" text NOT NULL, 170 "target_uri" text NOT NULL, 171 "target_did" text NOT NULL, 172 "reason_type" text NOT NULL, 173 "description" text, 174 "community_did" text NOT NULL, 175 "status" text DEFAULT 'pending' NOT NULL, 176 "resolution_type" text, 177 "resolved_by" text, 178 "resolved_at" timestamp with time zone, 179 "appeal_reason" text, 180 "appealed_at" timestamp with time zone, 181 "appeal_status" text DEFAULT 'none' NOT NULL, 182 "created_at" timestamp with time zone DEFAULT now() NOT NULL 183); 184--> statement-breakpoint 185ALTER TABLE "reports" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint 186CREATE TABLE "notifications" ( 187 "id" serial PRIMARY KEY NOT NULL, 188 "recipient_did" text NOT NULL, 189 "type" text NOT NULL, 190 "subject_uri" text NOT NULL, 191 "actor_did" text NOT NULL, 192 "community_did" text NOT NULL, 193 "read" boolean DEFAULT false NOT NULL, 194 "created_at" timestamp with time zone DEFAULT now() NOT NULL 195); 196--> statement-breakpoint 197ALTER TABLE "notifications" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint 198CREATE TABLE "user_community_preferences" ( 199 "did" text NOT NULL, 200 "community_did" text NOT NULL, 201 "maturity_override" text, 202 "muted_words" jsonb, 203 "blocked_dids" jsonb, 204 "muted_dids" jsonb, 205 "notification_prefs" jsonb, 206 "updated_at" timestamp with time zone DEFAULT now() NOT NULL, 207 CONSTRAINT "user_community_preferences_did_community_did_pk" PRIMARY KEY("did","community_did") 208); 209--> statement-breakpoint 210ALTER TABLE "user_community_preferences" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint 211CREATE TABLE "user_preferences" ( 212 "did" text PRIMARY KEY NOT NULL, 213 "maturity_level" text DEFAULT 'sfw' NOT NULL, 214 "declared_age" integer, 215 "muted_words" jsonb DEFAULT '[]'::jsonb NOT NULL, 216 "blocked_dids" jsonb DEFAULT '[]'::jsonb NOT NULL, 217 "muted_dids" jsonb DEFAULT '[]'::jsonb NOT NULL, 218 "cross_post_bluesky" boolean DEFAULT false NOT NULL, 219 "cross_post_frontpage" boolean DEFAULT false NOT NULL, 220 "cross_post_scopes_granted" boolean DEFAULT false NOT NULL, 221 "updated_at" timestamp with time zone DEFAULT now() NOT NULL 222); 223--> statement-breakpoint 224CREATE TABLE "cross_posts" ( 225 "id" text PRIMARY KEY NOT NULL, 226 "topic_uri" text NOT NULL, 227 "service" text NOT NULL, 228 "cross_post_uri" text NOT NULL, 229 "cross_post_cid" text NOT NULL, 230 "author_did" text NOT NULL, 231 "created_at" timestamp with time zone DEFAULT now() NOT NULL 232); 233--> statement-breakpoint 234CREATE TABLE "community_onboarding_fields" ( 235 "id" text PRIMARY KEY NOT NULL, 236 "community_did" text NOT NULL, 237 "field_type" text NOT NULL, 238 "label" text NOT NULL, 239 "description" text, 240 "is_mandatory" boolean DEFAULT true NOT NULL, 241 "sort_order" integer DEFAULT 0 NOT NULL, 242 "config" jsonb, 243 "created_at" timestamp with time zone DEFAULT now() NOT NULL, 244 "updated_at" timestamp with time zone DEFAULT now() NOT NULL 245); 246--> statement-breakpoint 247ALTER TABLE "community_onboarding_fields" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint 248CREATE TABLE "user_onboarding_responses" ( 249 "did" text NOT NULL, 250 "community_did" text NOT NULL, 251 "field_id" text NOT NULL, 252 "response" jsonb NOT NULL, 253 "completed_at" timestamp with time zone DEFAULT now() NOT NULL, 254 CONSTRAINT "user_onboarding_responses_did_community_did_field_id_pk" PRIMARY KEY("did","community_did","field_id") 255); 256--> statement-breakpoint 257ALTER TABLE "user_onboarding_responses" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint 258CREATE TABLE "moderation_queue" ( 259 "id" serial PRIMARY KEY NOT NULL, 260 "content_uri" text NOT NULL, 261 "content_type" text NOT NULL, 262 "author_did" text NOT NULL, 263 "community_did" text NOT NULL, 264 "queue_reason" text NOT NULL, 265 "matched_words" jsonb, 266 "status" text DEFAULT 'pending' NOT NULL, 267 "reviewed_by" text, 268 "created_at" timestamp with time zone DEFAULT now() NOT NULL, 269 "reviewed_at" timestamp with time zone 270); 271--> statement-breakpoint 272ALTER TABLE "moderation_queue" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint 273CREATE TABLE "account_trust" ( 274 "id" serial PRIMARY KEY NOT NULL, 275 "did" text NOT NULL, 276 "community_did" text NOT NULL, 277 "approved_post_count" integer DEFAULT 0 NOT NULL, 278 "is_trusted" boolean DEFAULT false NOT NULL, 279 "trusted_at" timestamp with time zone 280); 281--> statement-breakpoint 282ALTER TABLE "account_trust" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint 283CREATE TABLE "community_filters" ( 284 "community_did" text PRIMARY KEY NOT NULL, 285 "status" text DEFAULT 'active' NOT NULL, 286 "admin_did" text, 287 "reason" text, 288 "report_count" integer DEFAULT 0 NOT NULL, 289 "last_reviewed_at" timestamp with time zone, 290 "filtered_by" text, 291 "created_at" timestamp with time zone DEFAULT now() NOT NULL, 292 "updated_at" timestamp with time zone DEFAULT now() NOT NULL 293); 294--> statement-breakpoint 295ALTER TABLE "community_filters" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint 296CREATE TABLE "account_filters" ( 297 "id" serial PRIMARY KEY NOT NULL, 298 "did" text NOT NULL, 299 "community_did" text NOT NULL, 300 "status" text DEFAULT 'active' NOT NULL, 301 "reason" text, 302 "report_count" integer DEFAULT 0 NOT NULL, 303 "ban_count" integer DEFAULT 0 NOT NULL, 304 "last_reviewed_at" timestamp with time zone, 305 "filtered_by" text, 306 "created_at" timestamp with time zone DEFAULT now() NOT NULL, 307 "updated_at" timestamp with time zone DEFAULT now() NOT NULL 308); 309--> statement-breakpoint 310ALTER TABLE "account_filters" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint 311CREATE TABLE "ozone_labels" ( 312 "id" serial PRIMARY KEY NOT NULL, 313 "src" text NOT NULL, 314 "uri" text NOT NULL, 315 "val" text NOT NULL, 316 "neg" boolean DEFAULT false NOT NULL, 317 "cts" timestamp with time zone NOT NULL, 318 "exp" timestamp with time zone, 319 "indexed_at" timestamp with time zone DEFAULT now() NOT NULL 320); 321--> statement-breakpoint 322CREATE TABLE "community_profiles" ( 323 "did" text NOT NULL, 324 "community_did" text NOT NULL, 325 "display_name" text, 326 "avatar_url" text, 327 "banner_url" text, 328 "bio" text, 329 "updated_at" timestamp with time zone DEFAULT now() NOT NULL, 330 CONSTRAINT "community_profiles_did_community_did_pk" PRIMARY KEY("did","community_did") 331); 332--> statement-breakpoint 333ALTER TABLE "community_profiles" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint 334CREATE TABLE "interaction_graph" ( 335 "source_did" text NOT NULL, 336 "target_did" text NOT NULL, 337 "community_id" text NOT NULL, 338 "interaction_type" text NOT NULL, 339 "weight" integer DEFAULT 1 NOT NULL, 340 "first_interaction_at" timestamp with time zone DEFAULT now() NOT NULL, 341 "last_interaction_at" timestamp with time zone DEFAULT now() NOT NULL, 342 CONSTRAINT "interaction_graph_source_did_target_did_community_id_interaction_type_pk" PRIMARY KEY("source_did","target_did","community_id","interaction_type") 343); 344--> statement-breakpoint 345CREATE TABLE "trust_seeds" ( 346 "id" serial PRIMARY KEY NOT NULL, 347 "did" text NOT NULL, 348 "community_id" text DEFAULT '' NOT NULL, 349 "added_by" text NOT NULL, 350 "reason" text, 351 "created_at" timestamp with time zone DEFAULT now() NOT NULL 352); 353--> statement-breakpoint 354CREATE TABLE "trust_scores" ( 355 "did" text NOT NULL, 356 "community_id" text DEFAULT '' NOT NULL, 357 "score" real NOT NULL, 358 "computed_at" timestamp with time zone DEFAULT now() NOT NULL, 359 CONSTRAINT "trust_scores_did_community_id_pk" PRIMARY KEY("did","community_id") 360); 361--> statement-breakpoint 362CREATE TABLE "sybil_clusters" ( 363 "id" serial PRIMARY KEY NOT NULL, 364 "cluster_hash" text NOT NULL, 365 "internal_edge_count" integer NOT NULL, 366 "external_edge_count" integer NOT NULL, 367 "member_count" integer NOT NULL, 368 "status" text DEFAULT 'flagged' NOT NULL, 369 "reviewed_by" text, 370 "reviewed_at" timestamp with time zone, 371 "detected_at" timestamp with time zone DEFAULT now() NOT NULL, 372 "updated_at" timestamp with time zone DEFAULT now() NOT NULL 373); 374--> statement-breakpoint 375CREATE TABLE "sybil_cluster_members" ( 376 "cluster_id" integer NOT NULL, 377 "did" text NOT NULL, 378 "role_in_cluster" text NOT NULL, 379 "joined_at" timestamp with time zone DEFAULT now() NOT NULL, 380 CONSTRAINT "sybil_cluster_members_cluster_id_did_pk" PRIMARY KEY("cluster_id","did") 381); 382--> statement-breakpoint 383CREATE TABLE "behavioral_flags" ( 384 "id" serial PRIMARY KEY NOT NULL, 385 "flag_type" text NOT NULL, 386 "affected_dids" jsonb NOT NULL, 387 "details" text NOT NULL, 388 "community_did" text, 389 "status" text DEFAULT 'pending' NOT NULL, 390 "detected_at" timestamp with time zone DEFAULT now() NOT NULL 391); 392--> statement-breakpoint 393CREATE TABLE "pds_trust_factors" ( 394 "id" serial PRIMARY KEY NOT NULL, 395 "pds_host" text NOT NULL, 396 "trust_factor" real NOT NULL, 397 "is_default" boolean DEFAULT false NOT NULL, 398 "updated_at" timestamp with time zone DEFAULT now() NOT NULL 399); 400--> statement-breakpoint 401ALTER TABLE "categories" ADD CONSTRAINT "categories_parent_id_fk" FOREIGN KEY ("parent_id") REFERENCES "public"."categories"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint 402ALTER TABLE "sybil_cluster_members" ADD CONSTRAINT "sybil_cluster_members_cluster_id_sybil_clusters_id_fk" FOREIGN KEY ("cluster_id") REFERENCES "public"."sybil_clusters"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint 403CREATE INDEX "users_role_elevated_idx" ON "users" USING btree ("role") WHERE role IN ('moderator', 'admin');--> statement-breakpoint 404CREATE INDEX "users_handle_idx" ON "users" USING btree ("handle");--> statement-breakpoint 405CREATE INDEX "users_account_created_at_idx" ON "users" USING btree ("account_created_at");--> statement-breakpoint 406CREATE INDEX "topics_author_did_idx" ON "topics" USING btree ("author_did");--> statement-breakpoint 407CREATE INDEX "topics_category_idx" ON "topics" USING btree ("category");--> statement-breakpoint 408CREATE INDEX "topics_created_at_idx" ON "topics" USING btree ("created_at");--> statement-breakpoint 409CREATE INDEX "topics_last_activity_at_idx" ON "topics" USING btree ("last_activity_at");--> statement-breakpoint 410CREATE INDEX "topics_community_did_idx" ON "topics" USING btree ("community_did");--> statement-breakpoint 411CREATE INDEX "topics_moderation_status_idx" ON "topics" USING btree ("moderation_status");--> statement-breakpoint 412CREATE INDEX "topics_trust_status_idx" ON "topics" USING btree ("trust_status");--> statement-breakpoint 413CREATE INDEX "topics_community_category_activity_idx" ON "topics" USING btree ("community_did","category","last_activity_at");--> statement-breakpoint 414CREATE INDEX "replies_author_did_idx" ON "replies" USING btree ("author_did");--> statement-breakpoint 415CREATE INDEX "replies_root_uri_idx" ON "replies" USING btree ("root_uri");--> statement-breakpoint 416CREATE INDEX "replies_parent_uri_idx" ON "replies" USING btree ("parent_uri");--> statement-breakpoint 417CREATE INDEX "replies_created_at_idx" ON "replies" USING btree ("created_at");--> statement-breakpoint 418CREATE INDEX "replies_community_did_idx" ON "replies" USING btree ("community_did");--> statement-breakpoint 419CREATE INDEX "replies_moderation_status_idx" ON "replies" USING btree ("moderation_status");--> statement-breakpoint 420CREATE INDEX "replies_trust_status_idx" ON "replies" USING btree ("trust_status");--> statement-breakpoint 421CREATE INDEX "replies_root_uri_created_at_idx" ON "replies" USING btree ("root_uri","created_at");--> statement-breakpoint 422CREATE INDEX "reactions_author_did_idx" ON "reactions" USING btree ("author_did");--> statement-breakpoint 423CREATE INDEX "reactions_subject_uri_idx" ON "reactions" USING btree ("subject_uri");--> statement-breakpoint 424CREATE INDEX "reactions_community_did_idx" ON "reactions" USING btree ("community_did");--> statement-breakpoint 425CREATE INDEX "reactions_subject_uri_type_idx" ON "reactions" USING btree ("subject_uri","type");--> statement-breakpoint 426CREATE INDEX "votes_author_did_idx" ON "votes" USING btree ("author_did");--> statement-breakpoint 427CREATE INDEX "votes_subject_uri_idx" ON "votes" USING btree ("subject_uri");--> statement-breakpoint 428CREATE INDEX "votes_community_did_idx" ON "votes" USING btree ("community_did");--> statement-breakpoint 429CREATE UNIQUE INDEX "categories_slug_community_did_idx" ON "categories" USING btree ("slug","community_did");--> statement-breakpoint 430CREATE INDEX "categories_parent_id_idx" ON "categories" USING btree ("parent_id");--> statement-breakpoint 431CREATE INDEX "categories_community_did_idx" ON "categories" USING btree ("community_did");--> statement-breakpoint 432CREATE INDEX "categories_maturity_rating_idx" ON "categories" USING btree ("maturity_rating");--> statement-breakpoint 433CREATE INDEX "mod_actions_moderator_did_idx" ON "moderation_actions" USING btree ("moderator_did");--> statement-breakpoint 434CREATE INDEX "mod_actions_community_did_idx" ON "moderation_actions" USING btree ("community_did");--> statement-breakpoint 435CREATE INDEX "mod_actions_created_at_idx" ON "moderation_actions" USING btree ("created_at");--> statement-breakpoint 436CREATE INDEX "mod_actions_target_uri_idx" ON "moderation_actions" USING btree ("target_uri");--> statement-breakpoint 437CREATE INDEX "mod_actions_target_did_idx" ON "moderation_actions" USING btree ("target_did");--> statement-breakpoint 438CREATE INDEX "reports_reporter_did_idx" ON "reports" USING btree ("reporter_did");--> statement-breakpoint 439CREATE INDEX "reports_target_uri_idx" ON "reports" USING btree ("target_uri");--> statement-breakpoint 440CREATE INDEX "reports_target_did_idx" ON "reports" USING btree ("target_did");--> statement-breakpoint 441CREATE INDEX "reports_community_did_idx" ON "reports" USING btree ("community_did");--> statement-breakpoint 442CREATE INDEX "reports_status_idx" ON "reports" USING btree ("status");--> statement-breakpoint 443CREATE INDEX "reports_created_at_idx" ON "reports" USING btree ("created_at");--> statement-breakpoint 444CREATE UNIQUE INDEX "reports_unique_reporter_target_idx" ON "reports" USING btree ("reporter_did","target_uri","community_did");--> statement-breakpoint 445CREATE INDEX "notifications_recipient_did_idx" ON "notifications" USING btree ("recipient_did");--> statement-breakpoint 446CREATE INDEX "notifications_recipient_read_idx" ON "notifications" USING btree ("recipient_did","read");--> statement-breakpoint 447CREATE INDEX "notifications_created_at_idx" ON "notifications" USING btree ("created_at");--> statement-breakpoint 448CREATE INDEX "user_community_prefs_did_idx" ON "user_community_preferences" USING btree ("did");--> statement-breakpoint 449CREATE INDEX "user_community_prefs_community_idx" ON "user_community_preferences" USING btree ("community_did");--> statement-breakpoint 450CREATE INDEX "cross_posts_topic_uri_idx" ON "cross_posts" USING btree ("topic_uri");--> statement-breakpoint 451CREATE INDEX "cross_posts_author_did_idx" ON "cross_posts" USING btree ("author_did");--> statement-breakpoint 452CREATE INDEX "onboarding_fields_community_idx" ON "community_onboarding_fields" USING btree ("community_did");--> statement-breakpoint 453CREATE INDEX "onboarding_responses_did_community_idx" ON "user_onboarding_responses" USING btree ("did","community_did");--> statement-breakpoint 454CREATE INDEX "mod_queue_author_did_idx" ON "moderation_queue" USING btree ("author_did");--> statement-breakpoint 455CREATE INDEX "mod_queue_community_did_idx" ON "moderation_queue" USING btree ("community_did");--> statement-breakpoint 456CREATE INDEX "mod_queue_status_idx" ON "moderation_queue" USING btree ("status");--> statement-breakpoint 457CREATE INDEX "mod_queue_created_at_idx" ON "moderation_queue" USING btree ("created_at");--> statement-breakpoint 458CREATE INDEX "mod_queue_content_uri_idx" ON "moderation_queue" USING btree ("content_uri");--> statement-breakpoint 459CREATE UNIQUE INDEX "account_trust_did_community_idx" ON "account_trust" USING btree ("did","community_did");--> statement-breakpoint 460CREATE INDEX "account_trust_did_idx" ON "account_trust" USING btree ("did");--> statement-breakpoint 461CREATE INDEX "community_filters_status_idx" ON "community_filters" USING btree ("status");--> statement-breakpoint 462CREATE INDEX "community_filters_admin_did_idx" ON "community_filters" USING btree ("admin_did");--> statement-breakpoint 463CREATE INDEX "community_filters_updated_at_idx" ON "community_filters" USING btree ("updated_at");--> statement-breakpoint 464CREATE UNIQUE INDEX "account_filters_did_community_idx" ON "account_filters" USING btree ("did","community_did");--> statement-breakpoint 465CREATE INDEX "account_filters_did_idx" ON "account_filters" USING btree ("did");--> statement-breakpoint 466CREATE INDEX "account_filters_community_did_idx" ON "account_filters" USING btree ("community_did");--> statement-breakpoint 467CREATE INDEX "account_filters_status_idx" ON "account_filters" USING btree ("status");--> statement-breakpoint 468CREATE INDEX "account_filters_updated_at_idx" ON "account_filters" USING btree ("updated_at");--> statement-breakpoint 469CREATE UNIQUE INDEX "ozone_labels_src_uri_val_idx" ON "ozone_labels" USING btree ("src","uri","val");--> statement-breakpoint 470CREATE INDEX "ozone_labels_uri_idx" ON "ozone_labels" USING btree ("uri");--> statement-breakpoint 471CREATE INDEX "ozone_labels_val_idx" ON "ozone_labels" USING btree ("val");--> statement-breakpoint 472CREATE INDEX "ozone_labels_indexed_at_idx" ON "ozone_labels" USING btree ("indexed_at");--> statement-breakpoint 473CREATE INDEX "community_profiles_did_idx" ON "community_profiles" USING btree ("did");--> statement-breakpoint 474CREATE INDEX "community_profiles_community_idx" ON "community_profiles" USING btree ("community_did");--> statement-breakpoint 475CREATE INDEX "interaction_graph_source_target_community_idx" ON "interaction_graph" USING btree ("source_did","target_did","community_id");--> statement-breakpoint 476CREATE UNIQUE INDEX "trust_seeds_did_community_idx" ON "trust_seeds" USING btree ("did","community_id");--> statement-breakpoint 477CREATE INDEX "trust_scores_did_community_idx" ON "trust_scores" USING btree ("did","community_id");--> statement-breakpoint 478CREATE UNIQUE INDEX "sybil_clusters_hash_idx" ON "sybil_clusters" USING btree ("cluster_hash");--> statement-breakpoint 479CREATE INDEX "behavioral_flags_flag_type_idx" ON "behavioral_flags" USING btree ("flag_type");--> statement-breakpoint 480CREATE INDEX "behavioral_flags_status_idx" ON "behavioral_flags" USING btree ("status");--> statement-breakpoint 481CREATE INDEX "behavioral_flags_detected_at_idx" ON "behavioral_flags" USING btree ("detected_at");--> statement-breakpoint 482CREATE UNIQUE INDEX "pds_trust_factors_pds_host_idx" ON "pds_trust_factors" USING btree ("pds_host");--> statement-breakpoint 483CREATE POLICY "tenant_isolation" ON "topics" AS PERMISSIVE FOR ALL TO "barazo_app" USING (community_did = current_setting('app.current_community_did', true)) WITH CHECK (community_did = current_setting('app.current_community_did', true));--> statement-breakpoint 484CREATE POLICY "tenant_isolation" ON "replies" AS PERMISSIVE FOR ALL TO "barazo_app" USING (community_did = current_setting('app.current_community_did', true)) WITH CHECK (community_did = current_setting('app.current_community_did', true));--> statement-breakpoint 485CREATE POLICY "tenant_isolation" ON "reactions" AS PERMISSIVE FOR ALL TO "barazo_app" USING (community_did = current_setting('app.current_community_did', true)) WITH CHECK (community_did = current_setting('app.current_community_did', true));--> statement-breakpoint 486CREATE POLICY "tenant_isolation" ON "community_settings" AS PERMISSIVE FOR ALL TO "barazo_app" USING (community_did = current_setting('app.current_community_did', true)) WITH CHECK (community_did = current_setting('app.current_community_did', true));--> statement-breakpoint 487CREATE POLICY "tenant_isolation" ON "categories" AS PERMISSIVE FOR ALL TO "barazo_app" USING (community_did = current_setting('app.current_community_did', true)) WITH CHECK (community_did = current_setting('app.current_community_did', true));--> statement-breakpoint 488CREATE POLICY "tenant_isolation" ON "moderation_actions" AS PERMISSIVE FOR ALL TO "barazo_app" USING (community_did = current_setting('app.current_community_did', true)) WITH CHECK (community_did = current_setting('app.current_community_did', true));--> statement-breakpoint 489CREATE POLICY "tenant_isolation" ON "reports" AS PERMISSIVE FOR ALL TO "barazo_app" USING (community_did = current_setting('app.current_community_did', true)) WITH CHECK (community_did = current_setting('app.current_community_did', true));--> statement-breakpoint 490CREATE POLICY "tenant_isolation" ON "notifications" AS PERMISSIVE FOR ALL TO "barazo_app" USING (community_did = current_setting('app.current_community_did', true)) WITH CHECK (community_did = current_setting('app.current_community_did', true));--> statement-breakpoint 491CREATE POLICY "tenant_isolation" ON "user_community_preferences" AS PERMISSIVE FOR ALL TO "barazo_app" USING (community_did = current_setting('app.current_community_did', true)) WITH CHECK (community_did = current_setting('app.current_community_did', true));--> statement-breakpoint 492CREATE POLICY "tenant_isolation" ON "community_onboarding_fields" AS PERMISSIVE FOR ALL TO "barazo_app" USING (community_did = current_setting('app.current_community_did', true)) WITH CHECK (community_did = current_setting('app.current_community_did', true));--> statement-breakpoint 493CREATE POLICY "tenant_isolation" ON "user_onboarding_responses" AS PERMISSIVE FOR ALL TO "barazo_app" USING (community_did = current_setting('app.current_community_did', true)) WITH CHECK (community_did = current_setting('app.current_community_did', true));--> statement-breakpoint 494CREATE POLICY "tenant_isolation" ON "moderation_queue" AS PERMISSIVE FOR ALL TO "barazo_app" USING (community_did = current_setting('app.current_community_did', true)) WITH CHECK (community_did = current_setting('app.current_community_did', true));--> statement-breakpoint 495CREATE POLICY "tenant_isolation" ON "account_trust" AS PERMISSIVE FOR ALL TO "barazo_app" USING (community_did = current_setting('app.current_community_did', true)) WITH CHECK (community_did = current_setting('app.current_community_did', true));--> statement-breakpoint 496CREATE POLICY "tenant_isolation" ON "community_filters" AS PERMISSIVE FOR ALL TO "barazo_app" USING (community_did = current_setting('app.current_community_did', true)) WITH CHECK (community_did = current_setting('app.current_community_did', true));--> statement-breakpoint 497CREATE POLICY "tenant_isolation" ON "account_filters" AS PERMISSIVE FOR ALL TO "barazo_app" USING (community_did = current_setting('app.current_community_did', true)) WITH CHECK (community_did = current_setting('app.current_community_did', true));--> statement-breakpoint 498CREATE POLICY "tenant_isolation" ON "community_profiles" AS PERMISSIVE FOR ALL TO "barazo_app" USING (community_did = current_setting('app.current_community_did', true)) WITH CHECK (community_did = current_setting('app.current_community_did', true));