Files
sim/packages/db/migrations/0021_shocking_korath.sql
Vikhyath Mondreti 9de7a00373 improvement(code-structure): move db into separate package (#1364)
* improvement(code-structure): move db into separate package

* make db separate package

* remake bun lock

* update imports to not maintain two separate ones

* fix CI for tests by adding dummy url

* vercel build fix attempt

* update bun lock

* regenerate bun lock

* fix mocks

* remove db commands from apps/sim package json
2025-09-17 15:41:13 -07:00

16 lines
877 B
SQL

CREATE TABLE "user_stats" (
"id" text PRIMARY KEY NOT NULL,
"user_id" text NOT NULL,
"total_manual_executions" integer DEFAULT 0 NOT NULL,
"total_api_calls" integer DEFAULT 0 NOT NULL,
"total_webhook_triggers" integer DEFAULT 0 NOT NULL,
"total_scheduled_executions" integer DEFAULT 0 NOT NULL,
"total_tokens_used" integer DEFAULT 0 NOT NULL,
"total_cost" numeric DEFAULT '0' NOT NULL,
"last_active" timestamp DEFAULT now() NOT NULL,
CONSTRAINT "user_stats_user_id_unique" UNIQUE("user_id")
);
--> statement-breakpoint
ALTER TABLE "workflow" ADD COLUMN "run_count" integer DEFAULT 0 NOT NULL;--> statement-breakpoint
ALTER TABLE "workflow" ADD COLUMN "last_run_at" timestamp;--> statement-breakpoint
ALTER TABLE "user_stats" ADD CONSTRAINT "user_stats_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;