diff --git a/biome.json b/biome.json index e157f0ee..fd659d01 100644 --- a/biome.json +++ b/biome.json @@ -7,7 +7,14 @@ }, "files": { "ignoreUnknown": false, - "includes": ["**", "!node_modules", "!.next", "!dist", "!build"] + "includes": [ + "**", + "!node_modules", + "!.next", + "!dist", + "!build", + "!drizzle/meta" + ] }, "formatter": { "enabled": true, diff --git a/server/drizzle/0001_robust_captain_america.sql b/server/drizzle/0001_robust_captain_america.sql new file mode 100644 index 00000000..46399c5f --- /dev/null +++ b/server/drizzle/0001_robust_captain_america.sql @@ -0,0 +1,191 @@ +ALTER TABLE "account" DROP CONSTRAINT "account_id_not_null";--> statement-breakpoint +ALTER TABLE "account" DROP CONSTRAINT "account_account_id_not_null";--> statement-breakpoint +ALTER TABLE "account" DROP CONSTRAINT "account_provider_id_not_null";--> statement-breakpoint +ALTER TABLE "account" DROP CONSTRAINT "account_user_id_not_null";--> statement-breakpoint +ALTER TABLE "account" DROP CONSTRAINT "account_created_at_not_null";--> statement-breakpoint +ALTER TABLE "account" DROP CONSTRAINT "account_updated_at_not_null";--> statement-breakpoint +ALTER TABLE "channel_subscriptions" DROP CONSTRAINT "channel_subscriptions_subscription_id_not_null";--> statement-breakpoint +ALTER TABLE "channel_subscriptions" DROP CONSTRAINT "channel_subscriptions_user_id_not_null";--> statement-breakpoint +ALTER TABLE "channel_subscriptions" DROP CONSTRAINT "channel_subscriptions_channel_id_not_null";--> statement-breakpoint +ALTER TABLE "channel_subscriptions" DROP CONSTRAINT "channel_subscriptions_notifications_enabled_not_null";--> statement-breakpoint +ALTER TABLE "channel_subscriptions" DROP CONSTRAINT "channel_subscriptions_created_at_not_null";--> statement-breakpoint +ALTER TABLE "channels" DROP CONSTRAINT "channels_channel_id_not_null";--> statement-breakpoint +ALTER TABLE "channels" DROP CONSTRAINT "channels_name_not_null";--> statement-breakpoint +ALTER TABLE "channels" DROP CONSTRAINT "channels_created_at_not_null";--> statement-breakpoint +ALTER TABLE "channels" DROP CONSTRAINT "channels_post_permission_level_not_null";--> statement-breakpoint +ALTER TABLE "files" DROP CONSTRAINT "files_file_id_not_null";--> statement-breakpoint +ALTER TABLE "files" DROP CONSTRAINT "files_file_name_not_null";--> statement-breakpoint +ALTER TABLE "files" DROP CONSTRAINT "files_location_not_null";--> statement-breakpoint +ALTER TABLE "invite_codes" DROP CONSTRAINT "invite_codes_code_id_not_null";--> statement-breakpoint +ALTER TABLE "invite_codes" DROP CONSTRAINT "invite_codes_code_not_null";--> statement-breakpoint +ALTER TABLE "invite_codes" DROP CONSTRAINT "invite_codes_role_keys_not_null";--> statement-breakpoint +ALTER TABLE "invite_codes" DROP CONSTRAINT "invite_codes_created_by_not_null";--> statement-breakpoint +ALTER TABLE "invite_codes" DROP CONSTRAINT "invite_codes_created_at_not_null";--> statement-breakpoint +ALTER TABLE "invite_codes" DROP CONSTRAINT "invite_codes_expires_at_not_null";--> statement-breakpoint +ALTER TABLE "mentees" DROP CONSTRAINT "mentees_mentee_id_not_null";--> statement-breakpoint +ALTER TABLE "mentees" DROP CONSTRAINT "mentees_user_id_not_null";--> statement-breakpoint +ALTER TABLE "mentees" DROP CONSTRAINT "mentees_status_not_null";--> statement-breakpoint +ALTER TABLE "mentees" DROP CONSTRAINT "mentees_created_at_not_null";--> statement-breakpoint +ALTER TABLE "mentees" DROP CONSTRAINT "mentees_updated_at_not_null";--> statement-breakpoint +ALTER TABLE "mentor_recommendations" DROP CONSTRAINT "mentor_recommendations_recommendation_id_not_null";--> statement-breakpoint +ALTER TABLE "mentor_recommendations" DROP CONSTRAINT "mentor_recommendations_user_id_not_null";--> statement-breakpoint +ALTER TABLE "mentor_recommendations" DROP CONSTRAINT "mentor_recommendations_recommended_mentor_ids_not_null";--> statement-breakpoint +ALTER TABLE "mentor_recommendations" DROP CONSTRAINT "mentor_recommendations_created_at_not_null";--> statement-breakpoint +ALTER TABLE "mentors" DROP CONSTRAINT "mentors_mentor_id_not_null";--> statement-breakpoint +ALTER TABLE "mentors" DROP CONSTRAINT "mentors_user_id_not_null";--> statement-breakpoint +ALTER TABLE "mentors" DROP CONSTRAINT "mentors_status_not_null";--> statement-breakpoint +ALTER TABLE "mentors" DROP CONSTRAINT "mentors_created_at_not_null";--> statement-breakpoint +ALTER TABLE "mentors" DROP CONSTRAINT "mentors_updated_at_not_null";--> statement-breakpoint +ALTER TABLE "mentorship_embeddings" DROP CONSTRAINT "mentorship_embeddings_embedding_id_not_null";--> statement-breakpoint +ALTER TABLE "mentorship_embeddings" DROP CONSTRAINT "mentorship_embeddings_user_id_not_null";--> statement-breakpoint +ALTER TABLE "mentorship_embeddings" DROP CONSTRAINT "mentorship_embeddings_user_type_not_null";--> statement-breakpoint +ALTER TABLE "mentorship_embeddings" DROP CONSTRAINT "mentorship_embeddings_created_at_not_null";--> statement-breakpoint +ALTER TABLE "mentorship_embeddings" DROP CONSTRAINT "mentorship_embeddings_updated_at_not_null";--> statement-breakpoint +ALTER TABLE "mentorship_matches" DROP CONSTRAINT "mentorship_matches_match_id_not_null";--> statement-breakpoint +ALTER TABLE "mentorship_matches" DROP CONSTRAINT "mentorship_matches_status_not_null";--> statement-breakpoint +ALTER TABLE "mentorship_matches" DROP CONSTRAINT "mentorship_matches_matched_at_not_null";--> statement-breakpoint +ALTER TABLE "message_attachments" DROP CONSTRAINT "message_attachments_attachment_id_not_null";--> statement-breakpoint +ALTER TABLE "message_attachments" DROP CONSTRAINT "message_attachments_message_id_not_null";--> statement-breakpoint +ALTER TABLE "message_attachments" DROP CONSTRAINT "message_attachments_file_id_not_null";--> statement-breakpoint +ALTER TABLE "message_attachments" DROP CONSTRAINT "message_attachments_created_at_not_null";--> statement-breakpoint +ALTER TABLE "message_blasts" DROP CONSTRAINT "message_blasts_blast_id_not_null";--> statement-breakpoint +ALTER TABLE "message_blasts" DROP CONSTRAINT "message_blasts_sender_id_not_null";--> statement-breakpoint +ALTER TABLE "message_blasts" DROP CONSTRAINT "message_blasts_title_not_null";--> statement-breakpoint +ALTER TABLE "message_blasts" DROP CONSTRAINT "message_blasts_content_not_null";--> statement-breakpoint +ALTER TABLE "message_blasts" DROP CONSTRAINT "message_blasts_valid_until_not_null";--> statement-breakpoint +ALTER TABLE "message_blasts" DROP CONSTRAINT "message_blasts_status_not_null";--> statement-breakpoint +ALTER TABLE "message_blasts" DROP CONSTRAINT "message_blasts_created_at_not_null";--> statement-breakpoint +ALTER TABLE "message_blasts" DROP CONSTRAINT "message_blasts_updated_at_not_null";--> statement-breakpoint +ALTER TABLE "message_reactions" DROP CONSTRAINT "message_reactions_reaction_id_not_null";--> statement-breakpoint +ALTER TABLE "message_reactions" DROP CONSTRAINT "message_reactions_message_id_not_null";--> statement-breakpoint +ALTER TABLE "message_reactions" DROP CONSTRAINT "message_reactions_user_id_not_null";--> statement-breakpoint +ALTER TABLE "message_reactions" DROP CONSTRAINT "message_reactions_emoji_not_null";--> statement-breakpoint +ALTER TABLE "message_reactions" DROP CONSTRAINT "message_reactions_created_at_not_null";--> statement-breakpoint +ALTER TABLE "messages" DROP CONSTRAINT "messages_message_id_not_null";--> statement-breakpoint +ALTER TABLE "messages" DROP CONSTRAINT "messages_channel_id_not_null";--> statement-breakpoint +ALTER TABLE "messages" DROP CONSTRAINT "messages_created_at_not_null";--> statement-breakpoint +ALTER TABLE "push_subscriptions" DROP CONSTRAINT "push_subscriptions_subscription_id_not_null";--> statement-breakpoint +ALTER TABLE "push_subscriptions" DROP CONSTRAINT "push_subscriptions_user_id_not_null";--> statement-breakpoint +ALTER TABLE "push_subscriptions" DROP CONSTRAINT "push_subscriptions_endpoint_not_null";--> statement-breakpoint +ALTER TABLE "push_subscriptions" DROP CONSTRAINT "push_subscriptions_p256dh_not_null";--> statement-breakpoint +ALTER TABLE "push_subscriptions" DROP CONSTRAINT "push_subscriptions_auth_not_null";--> statement-breakpoint +ALTER TABLE "push_subscriptions" DROP CONSTRAINT "push_subscriptions_created_at_not_null";--> statement-breakpoint +ALTER TABLE "push_subscriptions" DROP CONSTRAINT "push_subscriptions_is_active_not_null";--> statement-breakpoint +ALTER TABLE "report_attachments" DROP CONSTRAINT "report_attachments_attachment_id_not_null";--> statement-breakpoint +ALTER TABLE "report_attachments" DROP CONSTRAINT "report_attachments_report_id_not_null";--> statement-breakpoint +ALTER TABLE "report_attachments" DROP CONSTRAINT "report_attachments_file_id_not_null";--> statement-breakpoint +ALTER TABLE "report_attachments" DROP CONSTRAINT "report_attachments_created_at_not_null";--> statement-breakpoint +ALTER TABLE "reports" DROP CONSTRAINT "reports_report_id_not_null";--> statement-breakpoint +ALTER TABLE "reports" DROP CONSTRAINT "reports_title_not_null";--> statement-breakpoint +ALTER TABLE "reports" DROP CONSTRAINT "reports_description_not_null";--> statement-breakpoint +ALTER TABLE "reports" DROP CONSTRAINT "reports_status_not_null";--> statement-breakpoint +ALTER TABLE "reports" DROP CONSTRAINT "reports_submitted_by_not_null";--> statement-breakpoint +ALTER TABLE "reports" DROP CONSTRAINT "reports_created_at_not_null";--> statement-breakpoint +ALTER TABLE "reports" DROP CONSTRAINT "reports_updated_at_not_null";--> statement-breakpoint +ALTER TABLE "roles" DROP CONSTRAINT "roles_role_id_not_null";--> statement-breakpoint +ALTER TABLE "roles" DROP CONSTRAINT "roles_namespace_not_null";--> statement-breakpoint +ALTER TABLE "roles" DROP CONSTRAINT "roles_action_not_null";--> statement-breakpoint +ALTER TABLE "roles" DROP CONSTRAINT "roles_role_key_not_null";--> statement-breakpoint +ALTER TABLE "roles" DROP CONSTRAINT "roles_created_at_not_null";--> statement-breakpoint +ALTER TABLE "roles" DROP CONSTRAINT "roles_updated_at_not_null";--> statement-breakpoint +ALTER TABLE "session" DROP CONSTRAINT "session_id_not_null";--> statement-breakpoint +ALTER TABLE "session" DROP CONSTRAINT "session_expires_at_not_null";--> statement-breakpoint +ALTER TABLE "session" DROP CONSTRAINT "session_token_not_null";--> statement-breakpoint +ALTER TABLE "session" DROP CONSTRAINT "session_created_at_not_null";--> statement-breakpoint +ALTER TABLE "session" DROP CONSTRAINT "session_updated_at_not_null";--> statement-breakpoint +ALTER TABLE "session" DROP CONSTRAINT "session_user_id_not_null";--> statement-breakpoint +ALTER TABLE "user" DROP CONSTRAINT "user_id_not_null";--> statement-breakpoint +ALTER TABLE "user" DROP CONSTRAINT "user_name_not_null";--> statement-breakpoint +ALTER TABLE "user" DROP CONSTRAINT "user_email_not_null";--> statement-breakpoint +ALTER TABLE "user" DROP CONSTRAINT "user_email_verified_not_null";--> statement-breakpoint +ALTER TABLE "user" DROP CONSTRAINT "user_signal_visibility_not_null";--> statement-breakpoint +ALTER TABLE "user" DROP CONSTRAINT "user_email_visibility_not_null";--> statement-breakpoint +ALTER TABLE "user" DROP CONSTRAINT "user_linkedin_visibility_not_null";--> statement-breakpoint +ALTER TABLE "user" DROP CONSTRAINT "user_created_at_not_null";--> statement-breakpoint +ALTER TABLE "user" DROP CONSTRAINT "user_updated_at_not_null";--> statement-breakpoint +ALTER TABLE "verification" DROP CONSTRAINT "verification_id_not_null";--> statement-breakpoint +ALTER TABLE "verification" DROP CONSTRAINT "verification_identifier_not_null";--> statement-breakpoint +ALTER TABLE "verification" DROP CONSTRAINT "verification_value_not_null";--> statement-breakpoint +ALTER TABLE "verification" DROP CONSTRAINT "verification_expires_at_not_null";--> statement-breakpoint +ALTER TABLE "verification" DROP CONSTRAINT "verification_created_at_not_null";--> statement-breakpoint +ALTER TABLE "verification" DROP CONSTRAINT "verification_updated_at_not_null";--> statement-breakpoint +ALTER TABLE "user_roles" DROP CONSTRAINT "user_roles_user_id_not_null";--> statement-breakpoint +ALTER TABLE "user_roles" DROP CONSTRAINT "user_roles_role_id_not_null";--> statement-breakpoint +ALTER TABLE "user_roles" DROP CONSTRAINT "user_roles_assigned_at_not_null";--> statement-breakpoint +ALTER TABLE "message_blasts" ALTER COLUMN "valid_until" SET DEFAULT NOW() + INTERVAL '24 hours';--> statement-breakpoint +ALTER TABLE "account" ADD CONSTRAINT "account_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "channel_subscriptions" ADD CONSTRAINT "channel_subscriptions_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "channel_subscriptions" ADD CONSTRAINT "channel_subscriptions_channel_id_channels_channel_id_fk" FOREIGN KEY ("channel_id") REFERENCES "public"."channels"("channel_id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "invite_codes" ADD CONSTRAINT "invite_codes_created_by_user_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."user"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "invite_codes" ADD CONSTRAINT "invite_codes_used_by_user_id_fk" FOREIGN KEY ("used_by") REFERENCES "public"."user"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "invite_codes" ADD CONSTRAINT "invite_codes_revoked_by_user_id_fk" FOREIGN KEY ("revoked_by") REFERENCES "public"."user"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mentees" ADD CONSTRAINT "mentees_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mentees" ADD CONSTRAINT "mentees_resume_file_id_files_file_id_fk" FOREIGN KEY ("resume_file_id") REFERENCES "public"."files"("file_id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mentor_recommendations" ADD CONSTRAINT "mentor_recommendations_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mentors" ADD CONSTRAINT "mentors_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mentors" ADD CONSTRAINT "mentors_resume_file_id_files_file_id_fk" FOREIGN KEY ("resume_file_id") REFERENCES "public"."files"("file_id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mentorship_embeddings" ADD CONSTRAINT "mentorship_embeddings_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mentorship_matches" ADD CONSTRAINT "mentorship_matches_requestor_user_id_user_id_fk" FOREIGN KEY ("requestor_user_id") REFERENCES "public"."user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mentorship_matches" ADD CONSTRAINT "mentorship_matches_mentor_user_id_user_id_fk" FOREIGN KEY ("mentor_user_id") REFERENCES "public"."user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "message_attachments" ADD CONSTRAINT "message_attachments_message_id_messages_message_id_fk" FOREIGN KEY ("message_id") REFERENCES "public"."messages"("message_id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "message_attachments" ADD CONSTRAINT "message_attachments_file_id_files_file_id_fk" FOREIGN KEY ("file_id") REFERENCES "public"."files"("file_id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "message_blasts" ADD CONSTRAINT "message_blasts_sender_id_user_id_fk" FOREIGN KEY ("sender_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "message_reactions" ADD CONSTRAINT "message_reactions_message_id_messages_message_id_fk" FOREIGN KEY ("message_id") REFERENCES "public"."messages"("message_id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "message_reactions" ADD CONSTRAINT "message_reactions_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "messages" ADD CONSTRAINT "messages_channel_id_channels_channel_id_fk" FOREIGN KEY ("channel_id") REFERENCES "public"."channels"("channel_id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "messages" ADD CONSTRAINT "messages_sender_id_user_id_fk" FOREIGN KEY ("sender_id") REFERENCES "public"."user"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "push_subscriptions" ADD CONSTRAINT "push_subscriptions_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "report_attachments" ADD CONSTRAINT "report_attachments_report_id_reports_report_id_fk" FOREIGN KEY ("report_id") REFERENCES "public"."reports"("report_id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "report_attachments" ADD CONSTRAINT "report_attachments_file_id_files_file_id_fk" FOREIGN KEY ("file_id") REFERENCES "public"."files"("file_id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "reports" ADD CONSTRAINT "reports_submitted_by_user_id_fk" FOREIGN KEY ("submitted_by") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "reports" ADD CONSTRAINT "reports_assigned_to_user_id_fk" FOREIGN KEY ("assigned_to") REFERENCES "public"."user"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "reports" ADD CONSTRAINT "reports_assigned_by_user_id_fk" FOREIGN KEY ("assigned_by") REFERENCES "public"."user"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "roles" ADD CONSTRAINT "roles_channel_id_channels_channel_id_fk" FOREIGN KEY ("channel_id") REFERENCES "public"."channels"("channel_id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "session" ADD CONSTRAINT "session_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "user" ADD CONSTRAINT "user_image_files_file_id_fk" FOREIGN KEY ("image") REFERENCES "public"."files"("file_id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "user_roles" ADD CONSTRAINT "user_roles_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "user_roles" ADD CONSTRAINT "user_roles_role_id_roles_role_id_fk" FOREIGN KEY ("role_id") REFERENCES "public"."roles"("role_id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "user_roles" ADD CONSTRAINT "user_roles_assigned_by_user_id_fk" FOREIGN KEY ("assigned_by") REFERENCES "public"."user"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +CREATE UNIQUE INDEX "ux_channel_subscriptions_user_channel" ON "channel_subscriptions" USING btree ("user_id","channel_id");--> statement-breakpoint +CREATE INDEX "ix_channel_subscriptions_user_id" ON "channel_subscriptions" USING btree ("user_id");--> statement-breakpoint +CREATE INDEX "ix_channel_subscriptions_channel_id" ON "channel_subscriptions" USING btree ("channel_id");--> statement-breakpoint +CREATE UNIQUE INDEX "ux_channels_name" ON "channels" USING btree ("name");--> statement-breakpoint +CREATE UNIQUE INDEX "ux_invite_codes_code" ON "invite_codes" USING btree ("code");--> statement-breakpoint +CREATE INDEX "ix_invite_codes_created_by" ON "invite_codes" USING btree ("created_by");--> statement-breakpoint +CREATE INDEX "ix_invite_codes_used_by" ON "invite_codes" USING btree ("used_by");--> statement-breakpoint +CREATE INDEX "ix_invite_codes_expires_at" ON "invite_codes" USING btree ("expires_at");--> statement-breakpoint +CREATE INDEX "ix_mentees_user_id" ON "mentees" USING btree ("user_id");--> statement-breakpoint +CREATE INDEX "ix_mentees_status" ON "mentees" USING btree ("status");--> statement-breakpoint +CREATE INDEX "ix_mentees_resume_file_id" ON "mentees" USING btree ("resume_file_id");--> statement-breakpoint +CREATE UNIQUE INDEX "ux_mentor_recommendations_user_id" ON "mentor_recommendations" USING btree ("user_id");--> statement-breakpoint +CREATE INDEX "ix_mentors_user_id" ON "mentors" USING btree ("user_id");--> statement-breakpoint +CREATE INDEX "ix_mentors_status" ON "mentors" USING btree ("status");--> statement-breakpoint +CREATE INDEX "ix_mentors_resume_file_id" ON "mentors" USING btree ("resume_file_id");--> statement-breakpoint +CREATE UNIQUE INDEX "ux_mentorship_embeddings_user_type" ON "mentorship_embeddings" USING btree ("user_id","user_type");--> statement-breakpoint +CREATE INDEX "ix_mentorship_embeddings_user_id" ON "mentorship_embeddings" USING btree ("user_id");--> statement-breakpoint +CREATE INDEX "ix_mentorship_embeddings_user_type" ON "mentorship_embeddings" USING btree ("user_type");--> statement-breakpoint +CREATE UNIQUE INDEX "ux_mentorship_matches_pair" ON "mentorship_matches" USING btree ("requestor_user_id","mentor_user_id");--> statement-breakpoint +CREATE INDEX "ix_mentorship_matches_requestor_user_id" ON "mentorship_matches" USING btree ("requestor_user_id");--> statement-breakpoint +CREATE INDEX "ix_mentorship_matches_mentor_user_id" ON "mentorship_matches" USING btree ("mentor_user_id");--> statement-breakpoint +CREATE INDEX "ix_mentorship_matches_status" ON "mentorship_matches" USING btree ("status");--> statement-breakpoint +CREATE INDEX "ix_message_attachments_message_id" ON "message_attachments" USING btree ("message_id");--> statement-breakpoint +CREATE INDEX "ix_message_attachments_file_id" ON "message_attachments" USING btree ("file_id");--> statement-breakpoint +CREATE UNIQUE INDEX "ux_message_attachments_message_file" ON "message_attachments" USING btree ("message_id","file_id");--> statement-breakpoint +CREATE INDEX "ix_message_blasts_sender_id" ON "message_blasts" USING btree ("sender_id");--> statement-breakpoint +CREATE INDEX "ix_message_blasts_status" ON "message_blasts" USING btree ("status");--> statement-breakpoint +CREATE INDEX "ix_message_blasts_valid_until" ON "message_blasts" USING btree ("valid_until");--> statement-breakpoint +CREATE UNIQUE INDEX "ux_message_reactions_user" ON "message_reactions" USING btree ("message_id","user_id","emoji");--> statement-breakpoint +CREATE INDEX "ix_message_reactions_message_id" ON "message_reactions" USING btree ("message_id");--> statement-breakpoint +CREATE INDEX "ix_message_reactions_user_id" ON "message_reactions" USING btree ("user_id");--> statement-breakpoint +CREATE INDEX "ix_messages_channel_id" ON "messages" USING btree ("channel_id");--> statement-breakpoint +CREATE INDEX "ix_messages_sender_id" ON "messages" USING btree ("sender_id");--> statement-breakpoint +CREATE UNIQUE INDEX "ux_push_subscriptions_endpoint" ON "push_subscriptions" USING btree ("endpoint");--> statement-breakpoint +CREATE INDEX "ix_push_subscriptions_user_id" ON "push_subscriptions" USING btree ("user_id");--> statement-breakpoint +CREATE UNIQUE INDEX "ux_report_attachments_report_file" ON "report_attachments" USING btree ("report_id","file_id");--> statement-breakpoint +CREATE INDEX "ix_report_attachments_report_id" ON "report_attachments" USING btree ("report_id");--> statement-breakpoint +CREATE UNIQUE INDEX "ux_roles_role_key" ON "roles" USING btree ("role_key");--> statement-breakpoint +CREATE INDEX "ix_roles_namespace_subject" ON "roles" USING btree ("namespace","subject_id");--> statement-breakpoint +CREATE INDEX "ix_roles_channel_id" ON "roles" USING btree ("channel_id");--> statement-breakpoint +CREATE UNIQUE INDEX "ux_users_email" ON "user" USING btree ("email");--> statement-breakpoint +CREATE INDEX "ix_user_roles_role_id" ON "user_roles" USING btree ("role_id");--> statement-breakpoint +CREATE INDEX "ix_user_roles_user_assigned_by" ON "user_roles" USING btree ("user_id","assigned_by"); \ No newline at end of file diff --git a/server/drizzle/meta/0001_snapshot.json b/server/drizzle/meta/0001_snapshot.json new file mode 100644 index 00000000..0dd44766 --- /dev/null +++ b/server/drizzle/meta/0001_snapshot.json @@ -0,0 +1,2975 @@ +{ + "id": "aa3f16d5-c170-4b17-81d6-3d0612bbc26b", + "prevId": "00000000-0000-0000-0000-000000000000", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.account": { + "name": "account", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "account_id": { + "name": "account_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "id_token": { + "name": "id_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_token_expires_at": { + "name": "access_token_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refresh_token_expires_at": { + "name": "refresh_token_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "account_user_id_user_id_fk": { + "name": "account_user_id_user_id_fk", + "tableFrom": "account", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.channel_subscriptions": { + "name": "channel_subscriptions", + "schema": "", + "columns": { + "subscription_id": { + "name": "subscription_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "channel_subscriptions_subscription_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel_id": { + "name": "channel_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "notifications_enabled": { + "name": "notifications_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "ux_channel_subscriptions_user_channel": { + "name": "ux_channel_subscriptions_user_channel", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "channel_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ix_channel_subscriptions_user_id": { + "name": "ix_channel_subscriptions_user_id", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ix_channel_subscriptions_channel_id": { + "name": "ix_channel_subscriptions_channel_id", + "columns": [ + { + "expression": "channel_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "channel_subscriptions_user_id_user_id_fk": { + "name": "channel_subscriptions_user_id_user_id_fk", + "tableFrom": "channel_subscriptions", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "channel_subscriptions_channel_id_channels_channel_id_fk": { + "name": "channel_subscriptions_channel_id_channels_channel_id_fk", + "tableFrom": "channel_subscriptions", + "tableTo": "channels", + "columnsFrom": [ + "channel_id" + ], + "columnsTo": [ + "channel_id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.channels": { + "name": "channels", + "schema": "", + "columns": { + "channel_id": { + "name": "channel_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "channels_channel_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "post_permission_level": { + "name": "post_permission_level", + "type": "channel_post_permission_enum", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'admin'" + } + }, + "indexes": { + "ux_channels_name": { + "name": "ux_channels_name", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.files": { + "name": "files", + "schema": "", + "columns": { + "file_id": { + "name": "file_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "location": { + "name": "location", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.invite_codes": { + "name": "invite_codes", + "schema": "", + "columns": { + "code_id": { + "name": "code_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "invite_codes_code_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "code": { + "name": "code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role_keys": { + "name": "role_keys", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "used_by": { + "name": "used_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "used_at": { + "name": "used_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "revoked_by": { + "name": "revoked_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "revoked_at": { + "name": "revoked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "ux_invite_codes_code": { + "name": "ux_invite_codes_code", + "columns": [ + { + "expression": "code", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ix_invite_codes_created_by": { + "name": "ix_invite_codes_created_by", + "columns": [ + { + "expression": "created_by", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ix_invite_codes_used_by": { + "name": "ix_invite_codes_used_by", + "columns": [ + { + "expression": "used_by", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ix_invite_codes_expires_at": { + "name": "ix_invite_codes_expires_at", + "columns": [ + { + "expression": "expires_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "invite_codes_created_by_user_id_fk": { + "name": "invite_codes_created_by_user_id_fk", + "tableFrom": "invite_codes", + "tableTo": "user", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "invite_codes_used_by_user_id_fk": { + "name": "invite_codes_used_by_user_id_fk", + "tableFrom": "invite_codes", + "tableTo": "user", + "columnsFrom": [ + "used_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "invite_codes_revoked_by_user_id_fk": { + "name": "invite_codes_revoked_by_user_id_fk", + "tableFrom": "invite_codes", + "tableTo": "user", + "columnsFrom": [ + "revoked_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.mentees": { + "name": "mentees", + "schema": "", + "columns": { + "mentee_id": { + "name": "mentee_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "mentees_mentee_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "learning_goals": { + "name": "learning_goals", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "experience_level": { + "name": "experience_level", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "preferred_mentor_type": { + "name": "preferred_mentor_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "mentee_status_enum", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "resume_file_id": { + "name": "resume_file_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "personal_interests": { + "name": "personal_interests", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "role_model_inspiration": { + "name": "role_model_inspiration", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "hope_to_gain_responses": { + "name": "hope_to_gain_responses", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "mentor_qualities": { + "name": "mentor_qualities", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "preferred_meeting_format": { + "name": "preferred_meeting_format", + "type": "meeting_format_enum", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "hours_per_month_commitment": { + "name": "hours_per_month_commitment", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "ix_mentees_user_id": { + "name": "ix_mentees_user_id", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ix_mentees_status": { + "name": "ix_mentees_status", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ix_mentees_resume_file_id": { + "name": "ix_mentees_resume_file_id", + "columns": [ + { + "expression": "resume_file_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mentees_user_id_user_id_fk": { + "name": "mentees_user_id_user_id_fk", + "tableFrom": "mentees", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mentees_resume_file_id_files_file_id_fk": { + "name": "mentees_resume_file_id_files_file_id_fk", + "tableFrom": "mentees", + "tableTo": "files", + "columnsFrom": [ + "resume_file_id" + ], + "columnsTo": [ + "file_id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.mentor_recommendations": { + "name": "mentor_recommendations", + "schema": "", + "columns": { + "recommendation_id": { + "name": "recommendation_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "mentor_recommendations_recommendation_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "recommended_mentor_ids": { + "name": "recommended_mentor_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "ux_mentor_recommendations_user_id": { + "name": "ux_mentor_recommendations_user_id", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mentor_recommendations_user_id_user_id_fk": { + "name": "mentor_recommendations_user_id_user_id_fk", + "tableFrom": "mentor_recommendations", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.mentors": { + "name": "mentors", + "schema": "", + "columns": { + "mentor_id": { + "name": "mentor_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "mentors_mentor_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "mentorship_preferences": { + "name": "mentorship_preferences", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "years_of_service": { + "name": "years_of_service", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "eligibility_data": { + "name": "eligibility_data", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "mentor_status_enum", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'requested'" + }, + "resume_file_id": { + "name": "resume_file_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "strengths": { + "name": "strengths", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "personal_interests": { + "name": "personal_interests", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "why_interested_responses": { + "name": "why_interested_responses", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "career_advice": { + "name": "career_advice", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "preferred_mentee_career_stages": { + "name": "preferred_mentee_career_stages", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "preferred_meeting_format": { + "name": "preferred_meeting_format", + "type": "meeting_format_enum", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "hours_per_month_commitment": { + "name": "hours_per_month_commitment", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "ix_mentors_user_id": { + "name": "ix_mentors_user_id", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ix_mentors_status": { + "name": "ix_mentors_status", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ix_mentors_resume_file_id": { + "name": "ix_mentors_resume_file_id", + "columns": [ + { + "expression": "resume_file_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mentors_user_id_user_id_fk": { + "name": "mentors_user_id_user_id_fk", + "tableFrom": "mentors", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mentors_resume_file_id_files_file_id_fk": { + "name": "mentors_resume_file_id_files_file_id_fk", + "tableFrom": "mentors", + "tableTo": "files", + "columnsFrom": [ + "resume_file_id" + ], + "columnsTo": [ + "file_id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.mentorship_embeddings": { + "name": "mentorship_embeddings", + "schema": "", + "columns": { + "embedding_id": { + "name": "embedding_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "mentorship_embeddings_embedding_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_type": { + "name": "user_type", + "type": "mentorship_user_type_enum", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "why_interested_embedding": { + "name": "why_interested_embedding", + "type": "vector(512)", + "primaryKey": false, + "notNull": false + }, + "hope_to_gain_embedding": { + "name": "hope_to_gain_embedding", + "type": "vector(512)", + "primaryKey": false, + "notNull": false + }, + "profile_embedding": { + "name": "profile_embedding", + "type": "vector(512)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "ux_mentorship_embeddings_user_type": { + "name": "ux_mentorship_embeddings_user_type", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ix_mentorship_embeddings_user_id": { + "name": "ix_mentorship_embeddings_user_id", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ix_mentorship_embeddings_user_type": { + "name": "ix_mentorship_embeddings_user_type", + "columns": [ + { + "expression": "user_type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mentorship_embeddings_user_id_user_id_fk": { + "name": "mentorship_embeddings_user_id_user_id_fk", + "tableFrom": "mentorship_embeddings", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.mentorship_matches": { + "name": "mentorship_matches", + "schema": "", + "columns": { + "match_id": { + "name": "match_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "mentorship_matches_match_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "requestor_user_id": { + "name": "requestor_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "mentor_user_id": { + "name": "mentor_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "match_status_enum", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "matched_at": { + "name": "matched_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "ux_mentorship_matches_pair": { + "name": "ux_mentorship_matches_pair", + "columns": [ + { + "expression": "requestor_user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "mentor_user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ix_mentorship_matches_requestor_user_id": { + "name": "ix_mentorship_matches_requestor_user_id", + "columns": [ + { + "expression": "requestor_user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ix_mentorship_matches_mentor_user_id": { + "name": "ix_mentorship_matches_mentor_user_id", + "columns": [ + { + "expression": "mentor_user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ix_mentorship_matches_status": { + "name": "ix_mentorship_matches_status", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mentorship_matches_requestor_user_id_user_id_fk": { + "name": "mentorship_matches_requestor_user_id_user_id_fk", + "tableFrom": "mentorship_matches", + "tableTo": "user", + "columnsFrom": [ + "requestor_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "mentorship_matches_mentor_user_id_user_id_fk": { + "name": "mentorship_matches_mentor_user_id_user_id_fk", + "tableFrom": "mentorship_matches", + "tableTo": "user", + "columnsFrom": [ + "mentor_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.message_attachments": { + "name": "message_attachments", + "schema": "", + "columns": { + "attachment_id": { + "name": "attachment_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "message_attachments_attachment_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "message_id": { + "name": "message_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "file_id": { + "name": "file_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "ix_message_attachments_message_id": { + "name": "ix_message_attachments_message_id", + "columns": [ + { + "expression": "message_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ix_message_attachments_file_id": { + "name": "ix_message_attachments_file_id", + "columns": [ + { + "expression": "file_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ux_message_attachments_message_file": { + "name": "ux_message_attachments_message_file", + "columns": [ + { + "expression": "message_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "file_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "message_attachments_message_id_messages_message_id_fk": { + "name": "message_attachments_message_id_messages_message_id_fk", + "tableFrom": "message_attachments", + "tableTo": "messages", + "columnsFrom": [ + "message_id" + ], + "columnsTo": [ + "message_id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "message_attachments_file_id_files_file_id_fk": { + "name": "message_attachments_file_id_files_file_id_fk", + "tableFrom": "message_attachments", + "tableTo": "files", + "columnsFrom": [ + "file_id" + ], + "columnsTo": [ + "file_id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.message_blasts": { + "name": "message_blasts", + "schema": "", + "columns": { + "blast_id": { + "name": "blast_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "message_blasts_blast_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "sender_id": { + "name": "sender_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "target_audience": { + "name": "target_audience", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "sent_at": { + "name": "sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "valid_until": { + "name": "valid_until", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "NOW() + INTERVAL '24 hours'" + }, + "status": { + "name": "status", + "type": "message_blast_status_enum", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "ix_message_blasts_sender_id": { + "name": "ix_message_blasts_sender_id", + "columns": [ + { + "expression": "sender_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ix_message_blasts_status": { + "name": "ix_message_blasts_status", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ix_message_blasts_valid_until": { + "name": "ix_message_blasts_valid_until", + "columns": [ + { + "expression": "valid_until", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "message_blasts_sender_id_user_id_fk": { + "name": "message_blasts_sender_id_user_id_fk", + "tableFrom": "message_blasts", + "tableTo": "user", + "columnsFrom": [ + "sender_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.message_reactions": { + "name": "message_reactions", + "schema": "", + "columns": { + "reaction_id": { + "name": "reaction_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "message_reactions_reaction_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "message_id": { + "name": "message_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "emoji": { + "name": "emoji", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "ux_message_reactions_user": { + "name": "ux_message_reactions_user", + "columns": [ + { + "expression": "message_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "emoji", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ix_message_reactions_message_id": { + "name": "ix_message_reactions_message_id", + "columns": [ + { + "expression": "message_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ix_message_reactions_user_id": { + "name": "ix_message_reactions_user_id", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "message_reactions_message_id_messages_message_id_fk": { + "name": "message_reactions_message_id_messages_message_id_fk", + "tableFrom": "message_reactions", + "tableTo": "messages", + "columnsFrom": [ + "message_id" + ], + "columnsTo": [ + "message_id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "message_reactions_user_id_user_id_fk": { + "name": "message_reactions_user_id_user_id_fk", + "tableFrom": "message_reactions", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.messages": { + "name": "messages", + "schema": "", + "columns": { + "message_id": { + "name": "message_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "messages_message_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "channel_id": { + "name": "channel_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "sender_id": { + "name": "sender_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "attachment_url": { + "name": "attachment_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "ix_messages_channel_id": { + "name": "ix_messages_channel_id", + "columns": [ + { + "expression": "channel_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ix_messages_sender_id": { + "name": "ix_messages_sender_id", + "columns": [ + { + "expression": "sender_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "messages_channel_id_channels_channel_id_fk": { + "name": "messages_channel_id_channels_channel_id_fk", + "tableFrom": "messages", + "tableTo": "channels", + "columnsFrom": [ + "channel_id" + ], + "columnsTo": [ + "channel_id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "messages_sender_id_user_id_fk": { + "name": "messages_sender_id_user_id_fk", + "tableFrom": "messages", + "tableTo": "user", + "columnsFrom": [ + "sender_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.push_subscriptions": { + "name": "push_subscriptions", + "schema": "", + "columns": { + "subscription_id": { + "name": "subscription_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "push_subscriptions_subscription_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "endpoint": { + "name": "endpoint", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "p256dh": { + "name": "p256dh", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "auth": { + "name": "auth", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "keys": { + "name": "keys", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "topics": { + "name": "topics", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + } + }, + "indexes": { + "ux_push_subscriptions_endpoint": { + "name": "ux_push_subscriptions_endpoint", + "columns": [ + { + "expression": "endpoint", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ix_push_subscriptions_user_id": { + "name": "ix_push_subscriptions_user_id", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "push_subscriptions_user_id_user_id_fk": { + "name": "push_subscriptions_user_id_user_id_fk", + "tableFrom": "push_subscriptions", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.report_attachments": { + "name": "report_attachments", + "schema": "", + "columns": { + "attachment_id": { + "name": "attachment_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "report_attachments_attachment_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "report_id": { + "name": "report_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "file_id": { + "name": "file_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "ux_report_attachments_report_file": { + "name": "ux_report_attachments_report_file", + "columns": [ + { + "expression": "report_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "file_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ix_report_attachments_report_id": { + "name": "ix_report_attachments_report_id", + "columns": [ + { + "expression": "report_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "report_attachments_report_id_reports_report_id_fk": { + "name": "report_attachments_report_id_reports_report_id_fk", + "tableFrom": "report_attachments", + "tableTo": "reports", + "columnsFrom": [ + "report_id" + ], + "columnsTo": [ + "report_id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "report_attachments_file_id_files_file_id_fk": { + "name": "report_attachments_file_id_files_file_id_fk", + "tableFrom": "report_attachments", + "tableTo": "files", + "columnsFrom": [ + "file_id" + ], + "columnsTo": [ + "file_id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.reports": { + "name": "reports", + "schema": "", + "columns": { + "report_id": { + "name": "report_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "category": { + "name": "category", + "type": "report_category_enum", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "report_status_enum", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'Pending'" + }, + "submitted_by": { + "name": "submitted_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "assigned_to": { + "name": "assigned_to", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "assigned_by": { + "name": "assigned_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "resolved": { + "name": "resolved", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "reports_submitted_by_user_id_fk": { + "name": "reports_submitted_by_user_id_fk", + "tableFrom": "reports", + "tableTo": "user", + "columnsFrom": [ + "submitted_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reports_assigned_to_user_id_fk": { + "name": "reports_assigned_to_user_id_fk", + "tableFrom": "reports", + "tableTo": "user", + "columnsFrom": [ + "assigned_to" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "reports_assigned_by_user_id_fk": { + "name": "reports_assigned_by_user_id_fk", + "tableFrom": "reports", + "tableTo": "user", + "columnsFrom": [ + "assigned_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.roles": { + "name": "roles", + "schema": "", + "columns": { + "role_id": { + "name": "role_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "roles_role_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "namespace": { + "name": "namespace", + "type": "role_namespace_enum", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "subject_id": { + "name": "subject_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "action": { + "name": "action", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role_key": { + "name": "role_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel_id": { + "name": "channel_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "ux_roles_role_key": { + "name": "ux_roles_role_key", + "columns": [ + { + "expression": "role_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ix_roles_namespace_subject": { + "name": "ix_roles_namespace_subject", + "columns": [ + { + "expression": "namespace", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "subject_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ix_roles_channel_id": { + "name": "ix_roles_channel_id", + "columns": [ + { + "expression": "channel_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "roles_channel_id_channels_channel_id_fk": { + "name": "roles_channel_id_channels_channel_id_fk", + "tableFrom": "roles", + "tableTo": "channels", + "columnsFrom": [ + "channel_id" + ], + "columnsTo": [ + "channel_id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.session": { + "name": "session", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "session_user_id_user_id_fk": { + "name": "session_user_id_user_id_fk", + "tableFrom": "session", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "session_token_unique": { + "name": "session_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_roles": { + "name": "user_roles", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role_id": { + "name": "role_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "assigned_at": { + "name": "assigned_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "assigned_by": { + "name": "assigned_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "ix_user_roles_role_id": { + "name": "ix_user_roles_role_id", + "columns": [ + { + "expression": "role_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ix_user_roles_user_assigned_by": { + "name": "ix_user_roles_user_assigned_by", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "assigned_by", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "user_roles_user_id_user_id_fk": { + "name": "user_roles_user_id_user_id_fk", + "tableFrom": "user_roles", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_roles_role_id_roles_role_id_fk": { + "name": "user_roles_role_id_roles_role_id_fk", + "tableFrom": "user_roles", + "tableTo": "roles", + "columnsFrom": [ + "role_id" + ], + "columnsTo": [ + "role_id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_roles_assigned_by_user_id_fk": { + "name": "user_roles_assigned_by_user_id_fk", + "tableFrom": "user_roles", + "tableTo": "user", + "columnsFrom": [ + "assigned_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "pk_user_roles": { + "name": "pk_user_roles", + "columns": [ + "user_id", + "role_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user": { + "name": "user", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email_verified": { + "name": "email_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "phone_number": { + "name": "phone_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "image": { + "name": "image", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "rank": { + "name": "rank", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "department": { + "name": "department", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "branch": { + "name": "branch", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "position_type": { + "name": "position_type", + "type": "position_type_enum", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "location": { + "name": "location", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "about": { + "name": "about", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "interests": { + "name": "interests", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "civilian_career": { + "name": "civilian_career", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "linkedin": { + "name": "linkedin", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "signal_visibility": { + "name": "signal_visibility", + "type": "visibility_enum", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'private'" + }, + "email_visibility": { + "name": "email_visibility", + "type": "visibility_enum", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'private'" + }, + "linkedin_visibility": { + "name": "linkedin_visibility", + "type": "visibility_enum", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'public'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "ux_users_email": { + "name": "ux_users_email", + "columns": [ + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "user_image_files_file_id_fk": { + "name": "user_image_files_file_id_fk", + "tableFrom": "user", + "tableTo": "files", + "columnsFrom": [ + "image" + ], + "columnsTo": [ + "file_id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_email_unique": { + "name": "user_email_unique", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.verification": { + "name": "verification", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "identifier": { + "name": "identifier", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.career_stage_enum": { + "name": "career_stage_enum", + "schema": "public", + "values": [ + "new-soldiers", + "junior-ncos", + "senior-ncos", + "junior-officers", + "senior-officers", + "transitioning", + "no-preference" + ] + }, + "public.channel_post_permission_enum": { + "name": "channel_post_permission_enum", + "schema": "public", + "values": [ + "admin", + "everyone", + "custom" + ] + }, + "public.match_status_enum": { + "name": "match_status_enum", + "schema": "public", + "values": [ + "pending", + "accepted", + "declined" + ] + }, + "public.meeting_format_enum": { + "name": "meeting_format_enum", + "schema": "public", + "values": [ + "in-person", + "virtual", + "hybrid", + "no-preference" + ] + }, + "public.mentee_status_enum": { + "name": "mentee_status_enum", + "schema": "public", + "values": [ + "active", + "inactive", + "matched" + ] + }, + "public.mentor_status_enum": { + "name": "mentor_status_enum", + "schema": "public", + "values": [ + "requested", + "approved", + "active" + ] + }, + "public.mentorship_user_type_enum": { + "name": "mentorship_user_type_enum", + "schema": "public", + "values": [ + "mentor", + "mentee" + ] + }, + "public.message_blast_status_enum": { + "name": "message_blast_status_enum", + "schema": "public", + "values": [ + "draft", + "sent", + "failed" + ] + }, + "public.permission_enum": { + "name": "permission_enum", + "schema": "public", + "values": [ + "read", + "write", + "both" + ] + }, + "public.position_type_enum": { + "name": "position_type_enum", + "schema": "public", + "values": [ + "active", + "part-time" + ] + }, + "public.report_category_enum": { + "name": "report_category_enum", + "schema": "public", + "values": [ + "Communication", + "Mentorship", + "Training", + "Resources" + ] + }, + "public.report_status_enum": { + "name": "report_status_enum", + "schema": "public", + "values": [ + "Pending", + "Assigned", + "Resolved" + ] + }, + "public.role_namespace_enum": { + "name": "role_namespace_enum", + "schema": "public", + "values": [ + "global", + "channel", + "mentor", + "broadcast", + "reporting" + ] + }, + "public.service_type_enum": { + "name": "service_type_enum", + "schema": "public", + "values": [ + "enlisted", + "officer" + ] + }, + "public.visibility_enum": { + "name": "visibility_enum", + "schema": "public", + "values": [ + "private", + "public" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/server/drizzle/meta/_journal.json b/server/drizzle/meta/_journal.json index 931a2309..6fa13926 100644 --- a/server/drizzle/meta/_journal.json +++ b/server/drizzle/meta/_journal.json @@ -8,6 +8,13 @@ "when": 1770863706443, "tag": "0000_safe_unicorn", "breakpoints": true + }, + { + "idx": 1, + "version": "7", + "when": 1771880763918, + "tag": "0001_robust_captain_america", + "breakpoints": true } ] -} +} \ No newline at end of file diff --git a/server/src/data/repository/user-repo.ts b/server/src/data/repository/user-repo.ts index f9435d0d..40173d56 100644 --- a/server/src/data/repository/user-repo.ts +++ b/server/src/data/repository/user-repo.ts @@ -9,6 +9,30 @@ import type { CreateUserInput } from "../../types/user-types.js"; * Repository to handle database queries/communication related to users */ export class UserRepository { + private normalizeInterests(interests: unknown): string[] | null { + if (Array.isArray(interests)) { + return interests.filter( + (value): value is string => typeof value === "string", + ); + } + + if (typeof interests === "string") { + return interests + .split(",") + .map((value) => value.trim()) + .filter((value) => value.length > 0); + } + + return null; + } + + private normalizeUserRow(row: T) { + return { + ...row, + interests: this.normalizeInterests(row.interests), + }; + } + async searchUsers(name: string) { const searchTerm = name.trim().toLowerCase(); if (!searchTerm) return []; @@ -68,7 +92,7 @@ export class UserRepository { if (!userRow) { throw new NotFoundError(`User ${user_id} not found`); } - return userRow; + return this.normalizeUserRow(userRow); } /** @@ -167,7 +191,7 @@ export class UserRepository { throw new NotFoundError(`User ${userId} not found`); } - return updated; + return this.normalizeUserRow(updated); } async updateUserProfile( @@ -252,7 +276,7 @@ export class UserRepository { throw new NotFoundError(`User ${userId} not found`); } - return updated; + return this.normalizeUserRow(updated); } /** @@ -284,7 +308,7 @@ export class UserRepository { .from(users) .where(inArray(users.id, user_ids)); - return userRows; + return userRows.map((row) => this.normalizeUserRow(row)); } async createUser(userData: CreateUserInput["userData"]) { diff --git a/server/src/types/user-types.ts b/server/src/types/user-types.ts index caede7cc..c34c2fde 100644 --- a/server/src/types/user-types.ts +++ b/server/src/types/user-types.ts @@ -37,26 +37,21 @@ export const getUserDataInputSchema = z.object({ export const userDataOutputSchema = z.object({ id: z.string(), name: z.string(), - email: z.email(), + email: z.string(), phoneNumber: z.string().nullable(), rank: z.string().nullable(), department: z.string().nullable(), branch: z.string().nullable(), - createdAt: z.date(), - updatedAt: z.date(), - image: z.uuid().nullable(), + createdAt: z.coerce.date(), + updatedAt: z.coerce.date(), + image: z.string().nullable(), location: z.string().nullable(), about: z.string().nullable(), interests: z.array(z.string()).nullable(), - signalVisibility: z.enum(["private", "public"]), - emailVisibility: z.enum(["private", "public"]), - linkedin: z - .url() - .refine((url) => url.startsWith("https://www.linkedin.com/in/"), { - message: "LinkedIn URL must start with https://www.linkedin.com/in/", - }) - .nullable(), - linkedinVisibility: z.enum(["private", "public"]), + signalVisibility: z.enum(["private", "public"]).nullable(), + emailVisibility: z.enum(["private", "public"]).nullable(), + linkedin: z.string().nullable(), + linkedinVisibility: z.enum(["private", "public"]).nullable(), }); export const checkEmailExistsInputSchema = z.object({