fix(db): use bigint for token counter columns in user_stats (#3755)

This commit is contained in:
Waleed
2026-03-24 21:08:07 -07:00
committed by GitHub
parent 7af7a225f2
commit 666dc67aa2
4 changed files with 14441 additions and 2 deletions

View File

@@ -0,0 +1,2 @@
ALTER TABLE "user_stats" ALTER COLUMN "total_tokens_used" SET DATA TYPE bigint;--> statement-breakpoint
ALTER TABLE "user_stats" ALTER COLUMN "total_copilot_tokens" SET DATA TYPE bigint;

File diff suppressed because it is too large Load Diff

View File

@@ -1261,6 +1261,13 @@
"when": 1774305252055,
"tag": "0180_amused_marvel_boy",
"breakpoints": true
},
{
"idx": 181,
"version": "7",
"when": 1774411211528,
"tag": "0181_dazzling_the_leader",
"breakpoints": true
}
]
}

View File

@@ -753,7 +753,7 @@ export const userStats = pgTable('user_stats', {
totalChatExecutions: integer('total_chat_executions').notNull().default(0),
totalMcpExecutions: integer('total_mcp_executions').notNull().default(0),
totalA2aExecutions: integer('total_a2a_executions').notNull().default(0),
totalTokensUsed: integer('total_tokens_used').notNull().default(0),
totalTokensUsed: bigint('total_tokens_used', { mode: 'number' }).notNull().default(0),
totalCost: decimal('total_cost').notNull().default('0'),
currentUsageLimit: decimal('current_usage_limit').default(DEFAULT_FREE_CREDITS.toString()), // Default $5 (1,000 credits) for free plan, null for team/enterprise
usageLimitUpdatedAt: timestamp('usage_limit_updated_at').defaultNow(),
@@ -769,7 +769,7 @@ export const userStats = pgTable('user_stats', {
totalCopilotCost: decimal('total_copilot_cost').notNull().default('0'),
currentPeriodCopilotCost: decimal('current_period_copilot_cost').notNull().default('0'),
lastPeriodCopilotCost: decimal('last_period_copilot_cost').default('0'),
totalCopilotTokens: integer('total_copilot_tokens').notNull().default(0),
totalCopilotTokens: bigint('total_copilot_tokens', { mode: 'number' }).notNull().default(0),
totalCopilotCalls: integer('total_copilot_calls').notNull().default(0),
// MCP Copilot usage tracking
totalMcpCopilotCalls: integer('total_mcp_copilot_calls').notNull().default(0),