/
opt
/
canhelp
/
packages
/
db
/
migrations
/
/opt/canhelp/packages/db/migrations
mkdir
upload
Name
Size
Mode
Actions
meta/
-
0755
rm
0000_organic_ultimo.sql
23071
0644
edit
dl
rm
0001_demonic_vertigo.sql
272
0644
edit
dl
rm
0002_tricky_wild_child.sql
1116
0644
edit
dl
rm
0003_absent_carlie_cooper.sql
67
0644
edit
dl
rm
0004_clean_kid_colt.sql
857
0644
edit
dl
rm
0005_support_tickets.sql
821
0644
edit
dl
rm
0006_plan_history.sql
453
0644
edit
dl
rm
0007_unknown_ricochet.sql
1179
0644
edit
dl
rm
0008_massive_cable.sql
68
0644
edit
dl
rm
0009_talented_stepford_cuckoos.sql
372
0644
edit
dl
rm
0010_gorgeous_ironclad.sql
387
0644
edit
dl
rm
0011_gifted_nightcrawler.sql
107
0644
edit
dl
rm
0012_quiet_santa_claus.sql
65
0644
edit
dl
rm
0013_single_role_unification.sql
732
0644
edit
dl
rm
0014_jazzy_menace.sql
59
0644
edit
dl
rm
0015_moaning_nightshade.sql
1736
0644
edit
dl
rm
0016_gorgeous_maximus.sql
93
0644
edit
dl
rm
0017_outstanding_daimon_hellstrom.sql
557
0644
edit
dl
rm
0018_price_list_i18n.sql
2808
0644
edit
dl
rm
0019_typical_harry_osborn.sql
2417
0644
edit
dl
rm
0020_simple_queen_noir.sql
190
0644
edit
dl
rm
0021_specialist_card_publication_status.sql
426
0644
edit
dl
rm
0022_youthful_brother_voodoo.sql
1594
0644
edit
dl
rm
Edit:
/opt/canhelp/packages/db/migrations/0000_organic_ultimo.sql
(23071B)
CREATE TABLE "accounts" ( "id" text PRIMARY KEY NOT NULL, "user_id" text NOT NULL, "account_id" text NOT NULL, "provider_id" text NOT NULL, "access_token" text, "refresh_token" text, "access_token_expires_at" timestamp, "refresh_token_expires_at" timestamp, "scope" text, "id_token" text, "password" text, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "activity_logs" ( "id" text PRIMARY KEY NOT NULL, "user_id" text, "user_email" text, "user_name" text, "event" varchar(100) NOT NULL, "details" text, "ip_address" text, "user_agent" text, "created_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "ai_logs" ( "id" text PRIMARY KEY NOT NULL, "provider" varchar(20) NOT NULL, "model" varchar(100) NOT NULL, "action" varchar(50) NOT NULL, "from_locale" varchar(5), "to_locale" varchar(5), "input_tokens" integer, "output_tokens" integer, "total_tokens" integer, "duration_ms" integer, "cost_usd" real, "success" boolean DEFAULT true NOT NULL, "error" text, "created_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "auto_response_settings" ( "id" text PRIMARY KEY NOT NULL, "specialist_id" text NOT NULL, "is_enabled" boolean DEFAULT false NOT NULL, "categories" text[], "locations" text[], "min_budget" numeric(10, 2), "max_budget" numeric(10, 2), "default_price" numeric(10, 2), "default_message" text, "max_auto_offers_per_day" integer DEFAULT 10 NOT NULL, "today_auto_offers" integer DEFAULT 0 NOT NULL, "today_date" varchar(10), "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL, CONSTRAINT "auto_response_settings_specialist_id_unique" UNIQUE("specialist_id") ); --> statement-breakpoint CREATE TABLE "categories" ( "id" text PRIMARY KEY NOT NULL, "slug" varchar(100) NOT NULL, "icon" text DEFAULT '📦' NOT NULL, "names_el" text NOT NULL, "names_en" text NOT NULL, "names_ru" text NOT NULL, "parent_id" text, "order" integer DEFAULT 0 NOT NULL, "is_active" boolean DEFAULT true NOT NULL, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL, CONSTRAINT "categories_slug_unique" UNIQUE("slug") ); --> statement-breakpoint CREATE TABLE "chat_rooms" ( "id" text PRIMARY KEY NOT NULL, "task_id" text, "customer_id" text NOT NULL, "specialist_id" text NOT NULL, "created_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "daily_specialist_stats" ( "id" text PRIMARY KEY NOT NULL, "specialist_id" text NOT NULL, "date" varchar(10) NOT NULL, "missed_total" integer DEFAULT 0 NOT NULL, "missed_by_pro" integer DEFAULT 0 NOT NULL, "missed_revenue" numeric(10, 2) DEFAULT '0' NOT NULL, "received_orders" integer DEFAULT 0 NOT NULL, "total_available" integer DEFAULT 0 NOT NULL, "hot_orders_missed" integer DEFAULT 0 NOT NULL, "created_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "daily_usage" ( "id" text PRIMARY KEY NOT NULL, "user_id" text NOT NULL, "date" varchar(10) NOT NULL, "messages_sent" integer DEFAULT 0 NOT NULL, "orders_made" integer DEFAULT 0 NOT NULL, "created_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "email_templates" ( "key" varchar(100) PRIMARY KEY NOT NULL, "subject" text DEFAULT '' NOT NULL, "body" text DEFAULT '' NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "favorites" ( "id" text PRIMARY KEY NOT NULL, "user_id" text NOT NULL, "task_id" text NOT NULL, "created_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "google_calendar_tokens" ( "id" text PRIMARY KEY NOT NULL, "user_id" text NOT NULL, "google_user_id" text, "access_token" text NOT NULL, "refresh_token" text, "expires_at" timestamp, "calendar_email" text, "scopes" text, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL, CONSTRAINT "google_calendar_tokens_user_id_unique" UNIQUE("user_id"), CONSTRAINT "google_calendar_tokens_google_user_id_unique" UNIQUE("google_user_id") ); --> statement-breakpoint CREATE TABLE "locations" ( "id" text PRIMARY KEY NOT NULL, "slug" varchar(100) NOT NULL, "name_el" text NOT NULL, "name_en" text NOT NULL, "name_ru" text NOT NULL, "parent_id" text, "order" integer DEFAULT 0 NOT NULL, "is_active" boolean DEFAULT true NOT NULL, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL, CONSTRAINT "locations_slug_unique" UNIQUE("slug") ); --> statement-breakpoint CREATE TABLE "messages" ( "id" text PRIMARY KEY NOT NULL, "room_id" text NOT NULL, "sender_id" text NOT NULL, "body" text NOT NULL, "is_read" boolean DEFAULT false NOT NULL, "created_at" timestamp DEFAULT now() NOT NULL, "translations" jsonb ); --> statement-breakpoint CREATE TABLE "missed_orders" ( "id" text PRIMARY KEY NOT NULL, "specialist_id" text NOT NULL, "task_id" text NOT NULL, "reason" text, "estimated_value" numeric(10, 2), "taken_by_pro" boolean DEFAULT false NOT NULL, "date" varchar(10) NOT NULL, "created_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "notifications" ( "id" text PRIMARY KEY NOT NULL, "recipient_id" text NOT NULL, "type" text NOT NULL, "title" text NOT NULL, "body" text, "reference_id" text, "is_read" boolean DEFAULT false NOT NULL, "created_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "offers" ( "id" text PRIMARY KEY NOT NULL, "task_id" text NOT NULL, "specialist_id" text NOT NULL, "price" numeric(10, 2) NOT NULL, "currency" varchar(3) DEFAULT 'EUR' NOT NULL, "message" text, "counter_price" numeric(10, 2), "status" text DEFAULT 'pending' NOT NULL, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "payments" ( "id" text PRIMARY KEY NOT NULL, "user_id" text NOT NULL, "order_ref" text NOT NULL, "amount" numeric(12, 2) NOT NULL, "currency" varchar(3) DEFAULT 'EUR' NOT NULL, "type" text DEFAULT 'balance' NOT NULL, "status" text DEFAULT 'pending' NOT NULL, "description" text, "transaction_id" text, "epay_response" jsonb, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL, CONSTRAINT "payments_order_ref_unique" UNIQUE("order_ref") ); --> statement-breakpoint CREATE TABLE "plans" ( "id" text PRIMARY KEY NOT NULL, "name" text NOT NULL, "description" text, "role" text DEFAULT 'customer' NOT NULL, "tier" text DEFAULT 'free' NOT NULL, "price" numeric(10, 2) DEFAULT '0' NOT NULL, "currency" varchar(3) DEFAULT 'EUR' NOT NULL, "max_tasks" integer, "max_offers" integer, "max_cards" integer, "max_messages_per_day" integer, "max_orders_per_day" integer, "max_skills" integer, "max_profiles" integer, "max_portfolio_items" integer, "notify_new_tasks" boolean DEFAULT false NOT NULL, "can_contact_free_plan" boolean DEFAULT false NOT NULL, "can_contact_pro_plan" boolean DEFAULT true NOT NULL, "can_contact_all" boolean DEFAULT false NOT NULL, "can_show_contact_info" boolean DEFAULT false NOT NULL, "can_view_phone" boolean DEFAULT false NOT NULL, "can_upload_video" boolean DEFAULT false NOT NULL, "has_favorites" boolean DEFAULT false NOT NULL, "has_google_calendar" boolean DEFAULT false NOT NULL, "has_verified_badge" boolean DEFAULT false NOT NULL, "highlighted_reviews" boolean DEFAULT false NOT NULL, "search_boost" integer DEFAULT 0 NOT NULL, "has_personal_site" boolean DEFAULT false NOT NULL, "has_canhelp_now_status" boolean DEFAULT false NOT NULL, "has_need_help_status" boolean DEFAULT false NOT NULL, "has_auto_response" boolean DEFAULT false NOT NULL, "has_auto_match" boolean DEFAULT false NOT NULL, "offers_multiplier" numeric(4, 2) DEFAULT '1.00' NOT NULL, "receive_instant_dispatch_free" boolean DEFAULT false NOT NULL, "receive_instant_dispatch_pro" boolean DEFAULT false NOT NULL, "features" text[], "duration_days" integer, "is_default" boolean DEFAULT false NOT NULL, "is_active" boolean DEFAULT true NOT NULL, "order" integer DEFAULT 0 NOT NULL, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "portfolio_items" ( "id" text PRIMARY KEY NOT NULL, "specialist_id" text NOT NULL, "card_id" text, "image_url" text NOT NULL, "title" varchar(200), "description" text, "order" integer DEFAULT 0 NOT NULL, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "referral_rewards" ( "id" text PRIMARY KEY NOT NULL, "referrer_id" text NOT NULL, "referee_id" text NOT NULL, "plan_id" text NOT NULL, "days_added" integer NOT NULL, "expires_at" timestamp NOT NULL, "created_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "reports" ( "id" text PRIMARY KEY NOT NULL, "reporter_id" text NOT NULL, "target_type" text NOT NULL, "target_id" text NOT NULL, "reason" text NOT NULL, "description" text, "status" text DEFAULT 'pending' NOT NULL, "created_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "reviews" ( "id" text PRIMARY KEY NOT NULL, "task_id" text NOT NULL, "author_id" text NOT NULL, "target_id" text NOT NULL, "rating" smallint NOT NULL, "comment" text, "created_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "sessions" ( "id" text PRIMARY KEY NOT NULL, "user_id" text NOT NULL, "token" text NOT NULL, "expires_at" timestamp NOT NULL, "ip_address" text, "user_agent" text, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL, CONSTRAINT "sessions_token_unique" UNIQUE("token") ); --> statement-breakpoint CREATE TABLE "settings" ( "key" varchar(100) PRIMARY KEY NOT NULL, "value" text NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "skill_suggestions" ( "id" text PRIMARY KEY NOT NULL, "category_slug" varchar(100) NOT NULL, "name_el" text NOT NULL, "name_en" text NOT NULL, "name_ru" text NOT NULL, "order" integer DEFAULT 0 NOT NULL ); --> statement-breakpoint CREATE TABLE "specialist_availability" ( "id" text PRIMARY KEY NOT NULL, "specialist_id" text NOT NULL, "date" varchar(10) NOT NULL, "status" text NOT NULL, "note" text, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "specialist_cards" ( "id" text PRIMARY KEY NOT NULL, "specialist_id" text NOT NULL, "title" varchar(200) NOT NULL, "description" text, "skills" text[], "categories" text[], "locations" text[], "is_active" boolean DEFAULT true NOT NULL, "order" integer DEFAULT 0 NOT NULL, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "specialist_favorites" ( "id" text PRIMARY KEY NOT NULL, "user_id" text NOT NULL, "specialist_id" text NOT NULL, "created_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "task_stats" ( "id" text PRIMARY KEY NOT NULL, "task_id" text NOT NULL, "total_views" integer DEFAULT 0 NOT NULL, "pro_views" integer DEFAULT 0 NOT NULL, "total_offers" integer DEFAULT 0 NOT NULL, "avg_response_min" integer, "updated_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "task_views" ( "id" text PRIMARY KEY NOT NULL, "task_id" text NOT NULL, "user_id" text NOT NULL, "user_plan_tier" text, "viewed_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "tasks" ( "id" text PRIMARY KEY NOT NULL, "title" text NOT NULL, "description" text NOT NULL, "original_locale" varchar(5) DEFAULT 'el' NOT NULL, "title_el" text, "title_en" text, "title_ru" text, "description_el" text, "description_en" text, "description_ru" text, "status" text DEFAULT 'open' NOT NULL, "budget" numeric(10, 2), "budget_negotiable" boolean DEFAULT false NOT NULL, "currency" varchar(3) DEFAULT 'EUR' NOT NULL, "category" text, "location" text, "district" text, "street" text, "house_number" text, "time_slot" text, "confidential_note" text, "images" text[], "deadline" timestamp, "customer_id" text NOT NULL, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "user_statuses" ( "id" text PRIMARY KEY NOT NULL, "user_id" text NOT NULL, "status_type" text NOT NULL, "is_active" boolean DEFAULT false NOT NULL, "activated_at" timestamp, "expires_at" timestamp, "created_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "users" ( "id" text PRIMARY KEY NOT NULL, "name" text NOT NULL, "email" text NOT NULL, "email_verified" boolean DEFAULT false NOT NULL, "image" text, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL, "first_name" text DEFAULT '' NOT NULL, "last_name" text DEFAULT '' NOT NULL, "role" text DEFAULT 'customer' NOT NULL, "phone" text, "bio" text, "skills" text[], "specialist_categories" text[], "specialist_locations" text[], "plan_id" text, "locale" varchar(5) DEFAULT 'el' NOT NULL, "languages" text[] DEFAULT '{}', "is_active" boolean DEFAULT true NOT NULL, "last_seen_at" timestamp, "notify_new_tasks" boolean DEFAULT false NOT NULL, "notif_messages" boolean DEFAULT true NOT NULL, "balance" numeric(12, 2) DEFAULT '0' NOT NULL, "plan_expires_at" timestamp, "referral_code" varchar(16), "referred_by" text, "show_contact_info" boolean DEFAULT false NOT NULL, "phone_verified" boolean DEFAULT false NOT NULL, "personal_site_slug" varchar(50), CONSTRAINT "users_email_unique" UNIQUE("email"), CONSTRAINT "users_referral_code_unique" UNIQUE("referral_code"), CONSTRAINT "users_personal_site_slug_unique" UNIQUE("personal_site_slug") ); --> statement-breakpoint CREATE TABLE "verifications" ( "id" text PRIMARY KEY NOT NULL, "identifier" text NOT NULL, "value" text NOT NULL, "expires_at" timestamp NOT NULL, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint ALTER TABLE "accounts" ADD CONSTRAINT "accounts_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "activity_logs" ADD CONSTRAINT "activity_logs_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint ALTER TABLE "auto_response_settings" ADD CONSTRAINT "auto_response_settings_specialist_id_users_id_fk" FOREIGN KEY ("specialist_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "categories" ADD CONSTRAINT "categories_parent_id_categories_id_fk" FOREIGN KEY ("parent_id") REFERENCES "public"."categories"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "chat_rooms" ADD CONSTRAINT "chat_rooms_task_id_tasks_id_fk" FOREIGN KEY ("task_id") REFERENCES "public"."tasks"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "chat_rooms" ADD CONSTRAINT "chat_rooms_customer_id_users_id_fk" FOREIGN KEY ("customer_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint ALTER TABLE "chat_rooms" ADD CONSTRAINT "chat_rooms_specialist_id_users_id_fk" FOREIGN KEY ("specialist_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint ALTER TABLE "daily_specialist_stats" ADD CONSTRAINT "daily_specialist_stats_specialist_id_users_id_fk" FOREIGN KEY ("specialist_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "daily_usage" ADD CONSTRAINT "daily_usage_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "favorites" ADD CONSTRAINT "favorites_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "favorites" ADD CONSTRAINT "favorites_task_id_tasks_id_fk" FOREIGN KEY ("task_id") REFERENCES "public"."tasks"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "google_calendar_tokens" ADD CONSTRAINT "google_calendar_tokens_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "locations" ADD CONSTRAINT "locations_parent_id_locations_id_fk" FOREIGN KEY ("parent_id") REFERENCES "public"."locations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "messages" ADD CONSTRAINT "messages_room_id_chat_rooms_id_fk" FOREIGN KEY ("room_id") REFERENCES "public"."chat_rooms"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "messages" ADD CONSTRAINT "messages_sender_id_users_id_fk" FOREIGN KEY ("sender_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint ALTER TABLE "missed_orders" ADD CONSTRAINT "missed_orders_specialist_id_users_id_fk" FOREIGN KEY ("specialist_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "missed_orders" ADD CONSTRAINT "missed_orders_task_id_tasks_id_fk" FOREIGN KEY ("task_id") REFERENCES "public"."tasks"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "notifications" ADD CONSTRAINT "notifications_recipient_id_users_id_fk" FOREIGN KEY ("recipient_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "offers" ADD CONSTRAINT "offers_task_id_tasks_id_fk" FOREIGN KEY ("task_id") REFERENCES "public"."tasks"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "offers" ADD CONSTRAINT "offers_specialist_id_users_id_fk" FOREIGN KEY ("specialist_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint ALTER TABLE "portfolio_items" ADD CONSTRAINT "portfolio_items_specialist_id_users_id_fk" FOREIGN KEY ("specialist_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "portfolio_items" ADD CONSTRAINT "portfolio_items_card_id_specialist_cards_id_fk" FOREIGN KEY ("card_id") REFERENCES "public"."specialist_cards"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "referral_rewards" ADD CONSTRAINT "referral_rewards_referrer_id_users_id_fk" FOREIGN KEY ("referrer_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "referral_rewards" ADD CONSTRAINT "referral_rewards_referee_id_users_id_fk" FOREIGN KEY ("referee_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "reports" ADD CONSTRAINT "reports_reporter_id_users_id_fk" FOREIGN KEY ("reporter_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint ALTER TABLE "reviews" ADD CONSTRAINT "reviews_task_id_tasks_id_fk" FOREIGN KEY ("task_id") REFERENCES "public"."tasks"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint ALTER TABLE "reviews" ADD CONSTRAINT "reviews_author_id_users_id_fk" FOREIGN KEY ("author_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint ALTER TABLE "reviews" ADD CONSTRAINT "reviews_target_id_users_id_fk" FOREIGN KEY ("target_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint ALTER TABLE "sessions" ADD CONSTRAINT "sessions_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "specialist_availability" ADD CONSTRAINT "specialist_availability_specialist_id_users_id_fk" FOREIGN KEY ("specialist_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "specialist_cards" ADD CONSTRAINT "specialist_cards_specialist_id_users_id_fk" FOREIGN KEY ("specialist_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "specialist_favorites" ADD CONSTRAINT "specialist_favorites_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "specialist_favorites" ADD CONSTRAINT "specialist_favorites_specialist_id_users_id_fk" FOREIGN KEY ("specialist_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "task_stats" ADD CONSTRAINT "task_stats_task_id_tasks_id_fk" FOREIGN KEY ("task_id") REFERENCES "public"."tasks"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "task_views" ADD CONSTRAINT "task_views_task_id_tasks_id_fk" FOREIGN KEY ("task_id") REFERENCES "public"."tasks"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "task_views" ADD CONSTRAINT "task_views_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "tasks" ADD CONSTRAINT "tasks_customer_id_users_id_fk" FOREIGN KEY ("customer_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint ALTER TABLE "user_statuses" ADD CONSTRAINT "user_statuses_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint CREATE UNIQUE INDEX "daily_spec_stats_idx" ON "daily_specialist_stats" USING btree ("specialist_id","date");--> statement-breakpoint CREATE UNIQUE INDEX "daily_usage_user_date_idx" ON "daily_usage" USING btree ("user_id","date");--> statement-breakpoint CREATE UNIQUE INDEX "favorites_user_task_idx" ON "favorites" USING btree ("user_id","task_id");--> statement-breakpoint CREATE UNIQUE INDEX "specialist_favorites_user_specialist_idx" ON "specialist_favorites" USING btree ("user_id","specialist_id");--> statement-breakpoint CREATE UNIQUE INDEX "task_stats_task_idx" ON "task_stats" USING btree ("task_id");--> statement-breakpoint CREATE UNIQUE INDEX "task_views_task_user_idx" ON "task_views" USING btree ("task_id","user_id");--> statement-breakpoint CREATE UNIQUE INDEX "user_statuses_user_type_idx" ON "user_statuses" USING btree ("user_id","status_type");
Save
cmd:
run