The open source coding agent.
TypeScript
wip: black
Frankdd5ec26c8c09
diff --git a/packages/console/app/src/routes/workspace/[id]/billing/payment-section.tsx b/packages/console/app/src/routes/workspace/[id]/billing/payment-section.tsxindex e51ccc9f531..d21c4edce92 100644--- a/packages/console/app/src/routes/workspace/[id]/billing/payment-section.tsx+++ b/packages/console/app/src/routes/workspace/[id]/billing/payment-section.tsx@@ -1,6 +1,6 @@import { Billing } from "@opencode-ai/console-core/billing.js"import { query, action, useParams, createAsync, useAction } from "@solidjs/router"-import { For, Show } from "solid-js"+import { For, Match, Show, Switch } from "solid-js"import { withActor } from "~/context/auth.withActor"import { formatDateUTC, formatDateForTable } from "../../common"import styles from "./payment-section.module.css"@@ -77,7 +77,8 @@ export function PaymentSection() {<For each={payments()!}>{(payment) => {const date = new Date(payment.timeCreated)- const isCredit = !payment.paymentID+ const amount =+ payment.enrichment?.type === "subscription" && payment.enrichment.couponID ? 0 : payment.amountreturn (<tr><td data-slot="payment-date" title={formatDateUTC(date)}>@@ -85,13 +86,14 @@ export function PaymentSection() {</td><td data-slot="payment-id">{payment.id}</td><td data-slot="payment-amount" data-refunded={!!payment.timeRefunded}>- ${((payment.amount ?? 0) / 100000000).toFixed(2)}- {isCredit ? " (credit)" : ""}+ ${((amount ?? 0) / 100000000).toFixed(2)}+ <Switch>+ <Match when={payment.enrichment?.type === "credit"}> (credit)</Match>+ <Match when={payment.enrichment?.type === "subscription"}> (subscription)</Match>+ </Switch></td><td data-slot="payment-receipt">- {isCredit ? (- <span>-</span>- ) : (+ {payment.paymentID ? (<buttononClick={async () => {const receiptUrl = await downloadReceiptAction(params.id!, payment.paymentID!)@@ -103,6 +105,8 @@ export function PaymentSection() {>View</button>+ ) : (+ <span>-</span>)}</td></tr>diff --git a/packages/console/core/migrations/0049_noisy_domino.sql b/packages/console/core/migrations/0049_noisy_domino.sqlnew file mode 100644index 00000000000..654a5a81db9--- /dev/null+++ b/packages/console/core/migrations/0049_noisy_domino.sql@@ -0,0 +1 @@+ALTER TABLE `billing` ADD `subscription_coupon_id` varchar(28);\ No newline at end of filediff --git a/packages/console/core/migrations/0050_bumpy_mephistopheles.sql b/packages/console/core/migrations/0050_bumpy_mephistopheles.sqlnew file mode 100644index 00000000000..2c3d554f095--- /dev/null+++ b/packages/console/core/migrations/0050_bumpy_mephistopheles.sql@@ -0,0 +1 @@+ALTER TABLE `payment` ADD `enrichment` json;\ No newline at end of filediff --git a/packages/console/core/migrations/meta/0049_snapshot.json b/packages/console/core/migrations/meta/0049_snapshot.jsonnew file mode 100644index 00000000000..5c77033fa15--- /dev/null+++ b/packages/console/core/migrations/meta/0049_snapshot.json@@ -0,0 +1,1288 @@+{+ "version": "5",+ "dialect": "mysql",+ "id": "2fd0308b-0653-437d-aea3-29428a4de9f1",+ "prevId": "bb90bb3e-fd08-439a-b92f-5f433807480e",+ "tables": {+ "account": {+ "name": "account",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "account_id_pk": {+ "name": "account_id_pk",+ "columns": [+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "auth": {+ "name": "auth",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "provider": {+ "name": "provider",+ "type": "enum('email','github','google')",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "subject": {+ "name": "subject",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "account_id": {+ "name": "account_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "provider": {+ "name": "provider",+ "columns": [+ "provider",+ "subject"+ ],+ "isUnique": true+ },+ "account_id": {+ "name": "account_id",+ "columns": [+ "account_id"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "auth_id_pk": {+ "name": "auth_id_pk",+ "columns": [+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "benchmark": {+ "name": "benchmark",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "model": {+ "name": "model",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "agent": {+ "name": "agent",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "result": {+ "name": "result",+ "type": "mediumtext",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "time_created": {+ "name": "time_created",+ "columns": [+ "time_created"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "benchmark_id_pk": {+ "name": "benchmark_id_pk",+ "columns": [+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "billing": {+ "name": "billing",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "customer_id": {+ "name": "customer_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "payment_method_id": {+ "name": "payment_method_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "payment_method_type": {+ "name": "payment_method_type",+ "type": "varchar(32)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "payment_method_last4": {+ "name": "payment_method_last4",+ "type": "varchar(4)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "balance": {+ "name": "balance",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "monthly_limit": {+ "name": "monthly_limit",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "monthly_usage": {+ "name": "monthly_usage",+ "type": "bigint",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "time_monthly_usage_updated": {+ "name": "time_monthly_usage_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "reload": {+ "name": "reload",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "reload_trigger": {+ "name": "reload_trigger",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "reload_amount": {+ "name": "reload_amount",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "reload_error": {+ "name": "reload_error",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "time_reload_error": {+ "name": "time_reload_error",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "time_reload_locked_till": {+ "name": "time_reload_locked_till",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "subscription_id": {+ "name": "subscription_id",+ "type": "varchar(28)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "subscription_coupon_id": {+ "name": "subscription_coupon_id",+ "type": "varchar(28)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "global_customer_id": {+ "name": "global_customer_id",+ "columns": [+ "customer_id"+ ],+ "isUnique": true+ },+ "global_subscription_id": {+ "name": "global_subscription_id",+ "columns": [+ "subscription_id"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "billing_workspace_id_id_pk": {+ "name": "billing_workspace_id_id_pk",+ "columns": [+ "workspace_id",+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "payment": {+ "name": "payment",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "customer_id": {+ "name": "customer_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "invoice_id": {+ "name": "invoice_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "payment_id": {+ "name": "payment_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "amount": {+ "name": "amount",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_refunded": {+ "name": "time_refunded",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "payment_workspace_id_id_pk": {+ "name": "payment_workspace_id_id_pk",+ "columns": [+ "workspace_id",+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "subscription": {+ "name": "subscription",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "rolling_usage": {+ "name": "rolling_usage",+ "type": "bigint",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "fixed_usage": {+ "name": "fixed_usage",+ "type": "bigint",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "time_rolling_updated": {+ "name": "time_rolling_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "time_fixed_updated": {+ "name": "time_fixed_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "workspace_user_id": {+ "name": "workspace_user_id",+ "columns": [+ "workspace_id",+ "user_id"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "subscription_workspace_id_id_pk": {+ "name": "subscription_workspace_id_id_pk",+ "columns": [+ "workspace_id",+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "usage": {+ "name": "usage",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "model": {+ "name": "model",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "provider": {+ "name": "provider",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "input_tokens": {+ "name": "input_tokens",+ "type": "int",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "output_tokens": {+ "name": "output_tokens",+ "type": "int",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "reasoning_tokens": {+ "name": "reasoning_tokens",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "cache_read_tokens": {+ "name": "cache_read_tokens",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "cache_write_5m_tokens": {+ "name": "cache_write_5m_tokens",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "cache_write_1h_tokens": {+ "name": "cache_write_1h_tokens",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "cost": {+ "name": "cost",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "key_id": {+ "name": "key_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "enrichment": {+ "name": "enrichment",+ "type": "json",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "usage_time_created": {+ "name": "usage_time_created",+ "columns": [+ "workspace_id",+ "time_created"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "usage_workspace_id_id_pk": {+ "name": "usage_workspace_id_id_pk",+ "columns": [+ "workspace_id",+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "ip_rate_limit": {+ "name": "ip_rate_limit",+ "columns": {+ "ip": {+ "name": "ip",+ "type": "varchar(45)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "interval": {+ "name": "interval",+ "type": "varchar(10)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "count": {+ "name": "count",+ "type": "int",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "ip_rate_limit_ip_interval_pk": {+ "name": "ip_rate_limit_ip_interval_pk",+ "columns": [+ "ip",+ "interval"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "ip": {+ "name": "ip",+ "columns": {+ "ip": {+ "name": "ip",+ "type": "varchar(45)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "usage": {+ "name": "usage",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "ip_ip_pk": {+ "name": "ip_ip_pk",+ "columns": [+ "ip"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "key": {+ "name": "key",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "key": {+ "name": "key",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_used": {+ "name": "time_used",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "global_key": {+ "name": "global_key",+ "columns": [+ "key"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "key_workspace_id_id_pk": {+ "name": "key_workspace_id_id_pk",+ "columns": [+ "workspace_id",+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "model": {+ "name": "model",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "model": {+ "name": "model",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "model_workspace_model": {+ "name": "model_workspace_model",+ "columns": [+ "workspace_id",+ "model"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "model_workspace_id_id_pk": {+ "name": "model_workspace_id_id_pk",+ "columns": [+ "workspace_id",+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "provider": {+ "name": "provider",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "provider": {+ "name": "provider",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "credentials": {+ "name": "credentials",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "workspace_provider": {+ "name": "workspace_provider",+ "columns": [+ "workspace_id",+ "provider"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "provider_workspace_id_id_pk": {+ "name": "provider_workspace_id_id_pk",+ "columns": [+ "workspace_id",+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "user": {+ "name": "user",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "account_id": {+ "name": "account_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "email": {+ "name": "email",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_seen": {+ "name": "time_seen",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "color": {+ "name": "color",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "role": {+ "name": "role",+ "type": "enum('admin','member')",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "monthly_limit": {+ "name": "monthly_limit",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "monthly_usage": {+ "name": "monthly_usage",+ "type": "bigint",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "time_monthly_usage_updated": {+ "name": "time_monthly_usage_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "user_account_id": {+ "name": "user_account_id",+ "columns": [+ "workspace_id",+ "account_id"+ ],+ "isUnique": true+ },+ "user_email": {+ "name": "user_email",+ "columns": [+ "workspace_id",+ "email"+ ],+ "isUnique": true+ },+ "global_account_id": {+ "name": "global_account_id",+ "columns": [+ "account_id"+ ],+ "isUnique": false+ },+ "global_email": {+ "name": "global_email",+ "columns": [+ "email"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "user_workspace_id_id_pk": {+ "name": "user_workspace_id_id_pk",+ "columns": [+ "workspace_id",+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "workspace": {+ "name": "workspace",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "slug": {+ "name": "slug",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "slug": {+ "name": "slug",+ "columns": [+ "slug"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "workspace_id": {+ "name": "workspace_id",+ "columns": [+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ }+ },+ "views": {},+ "_meta": {+ "schemas": {},+ "tables": {},+ "columns": {}+ },+ "internal": {+ "tables": {},+ "indexes": {}+ }+}\ No newline at end of filediff --git a/packages/console/core/migrations/meta/0050_snapshot.json b/packages/console/core/migrations/meta/0050_snapshot.jsonnew file mode 100644index 00000000000..d3050f36e5d--- /dev/null+++ b/packages/console/core/migrations/meta/0050_snapshot.json@@ -0,0 +1,1295 @@+{+ "version": "5",+ "dialect": "mysql",+ "id": "a0d18802-c390-47d4-98f1-d1f83869cf0c",+ "prevId": "2fd0308b-0653-437d-aea3-29428a4de9f1",+ "tables": {+ "account": {+ "name": "account",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "account_id_pk": {+ "name": "account_id_pk",+ "columns": [+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "auth": {+ "name": "auth",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "provider": {+ "name": "provider",+ "type": "enum('email','github','google')",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "subject": {+ "name": "subject",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "account_id": {+ "name": "account_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "provider": {+ "name": "provider",+ "columns": [+ "provider",+ "subject"+ ],+ "isUnique": true+ },+ "account_id": {+ "name": "account_id",+ "columns": [+ "account_id"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "auth_id_pk": {+ "name": "auth_id_pk",+ "columns": [+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "benchmark": {+ "name": "benchmark",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "model": {+ "name": "model",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "agent": {+ "name": "agent",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "result": {+ "name": "result",+ "type": "mediumtext",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "time_created": {+ "name": "time_created",+ "columns": [+ "time_created"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "benchmark_id_pk": {+ "name": "benchmark_id_pk",+ "columns": [+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "billing": {+ "name": "billing",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "customer_id": {+ "name": "customer_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "payment_method_id": {+ "name": "payment_method_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "payment_method_type": {+ "name": "payment_method_type",+ "type": "varchar(32)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "payment_method_last4": {+ "name": "payment_method_last4",+ "type": "varchar(4)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "balance": {+ "name": "balance",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "monthly_limit": {+ "name": "monthly_limit",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "monthly_usage": {+ "name": "monthly_usage",+ "type": "bigint",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "time_monthly_usage_updated": {+ "name": "time_monthly_usage_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "reload": {+ "name": "reload",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "reload_trigger": {+ "name": "reload_trigger",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "reload_amount": {+ "name": "reload_amount",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "reload_error": {+ "name": "reload_error",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "time_reload_error": {+ "name": "time_reload_error",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "time_reload_locked_till": {+ "name": "time_reload_locked_till",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "subscription_id": {+ "name": "subscription_id",+ "type": "varchar(28)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "subscription_coupon_id": {+ "name": "subscription_coupon_id",+ "type": "varchar(28)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "global_customer_id": {+ "name": "global_customer_id",+ "columns": [+ "customer_id"+ ],+ "isUnique": true+ },+ "global_subscription_id": {+ "name": "global_subscription_id",+ "columns": [+ "subscription_id"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "billing_workspace_id_id_pk": {+ "name": "billing_workspace_id_id_pk",+ "columns": [+ "workspace_id",+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "payment": {+ "name": "payment",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "customer_id": {+ "name": "customer_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "invoice_id": {+ "name": "invoice_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "payment_id": {+ "name": "payment_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "amount": {+ "name": "amount",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_refunded": {+ "name": "time_refunded",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "enrichment": {+ "name": "enrichment",+ "type": "json",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "payment_workspace_id_id_pk": {+ "name": "payment_workspace_id_id_pk",+ "columns": [+ "workspace_id",+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "subscription": {+ "name": "subscription",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "rolling_usage": {+ "name": "rolling_usage",+ "type": "bigint",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "fixed_usage": {+ "name": "fixed_usage",+ "type": "bigint",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "time_rolling_updated": {+ "name": "time_rolling_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "time_fixed_updated": {+ "name": "time_fixed_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "workspace_user_id": {+ "name": "workspace_user_id",+ "columns": [+ "workspace_id",+ "user_id"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "subscription_workspace_id_id_pk": {+ "name": "subscription_workspace_id_id_pk",+ "columns": [+ "workspace_id",+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "usage": {+ "name": "usage",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "model": {+ "name": "model",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "provider": {+ "name": "provider",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "input_tokens": {+ "name": "input_tokens",+ "type": "int",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "output_tokens": {+ "name": "output_tokens",+ "type": "int",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "reasoning_tokens": {+ "name": "reasoning_tokens",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "cache_read_tokens": {+ "name": "cache_read_tokens",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "cache_write_5m_tokens": {+ "name": "cache_write_5m_tokens",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "cache_write_1h_tokens": {+ "name": "cache_write_1h_tokens",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "cost": {+ "name": "cost",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "key_id": {+ "name": "key_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "enrichment": {+ "name": "enrichment",+ "type": "json",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "usage_time_created": {+ "name": "usage_time_created",+ "columns": [+ "workspace_id",+ "time_created"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "usage_workspace_id_id_pk": {+ "name": "usage_workspace_id_id_pk",+ "columns": [+ "workspace_id",+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "ip_rate_limit": {+ "name": "ip_rate_limit",+ "columns": {+ "ip": {+ "name": "ip",+ "type": "varchar(45)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "interval": {+ "name": "interval",+ "type": "varchar(10)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "count": {+ "name": "count",+ "type": "int",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "ip_rate_limit_ip_interval_pk": {+ "name": "ip_rate_limit_ip_interval_pk",+ "columns": [+ "ip",+ "interval"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "ip": {+ "name": "ip",+ "columns": {+ "ip": {+ "name": "ip",+ "type": "varchar(45)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "usage": {+ "name": "usage",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "ip_ip_pk": {+ "name": "ip_ip_pk",+ "columns": [+ "ip"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "key": {+ "name": "key",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "key": {+ "name": "key",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_used": {+ "name": "time_used",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "global_key": {+ "name": "global_key",+ "columns": [+ "key"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "key_workspace_id_id_pk": {+ "name": "key_workspace_id_id_pk",+ "columns": [+ "workspace_id",+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "model": {+ "name": "model",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "model": {+ "name": "model",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "model_workspace_model": {+ "name": "model_workspace_model",+ "columns": [+ "workspace_id",+ "model"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "model_workspace_id_id_pk": {+ "name": "model_workspace_id_id_pk",+ "columns": [+ "workspace_id",+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "provider": {+ "name": "provider",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "provider": {+ "name": "provider",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "credentials": {+ "name": "credentials",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "workspace_provider": {+ "name": "workspace_provider",+ "columns": [+ "workspace_id",+ "provider"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "provider_workspace_id_id_pk": {+ "name": "provider_workspace_id_id_pk",+ "columns": [+ "workspace_id",+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "user": {+ "name": "user",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "account_id": {+ "name": "account_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "email": {+ "name": "email",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_seen": {+ "name": "time_seen",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "color": {+ "name": "color",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "role": {+ "name": "role",+ "type": "enum('admin','member')",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "monthly_limit": {+ "name": "monthly_limit",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "monthly_usage": {+ "name": "monthly_usage",+ "type": "bigint",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "time_monthly_usage_updated": {+ "name": "time_monthly_usage_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "user_account_id": {+ "name": "user_account_id",+ "columns": [+ "workspace_id",+ "account_id"+ ],+ "isUnique": true+ },+ "user_email": {+ "name": "user_email",+ "columns": [+ "workspace_id",+ "email"+ ],+ "isUnique": true+ },+ "global_account_id": {+ "name": "global_account_id",+ "columns": [+ "account_id"+ ],+ "isUnique": false+ },+ "global_email": {+ "name": "global_email",+ "columns": [+ "email"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "user_workspace_id_id_pk": {+ "name": "user_workspace_id_id_pk",+ "columns": [+ "workspace_id",+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "workspace": {+ "name": "workspace",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "slug": {+ "name": "slug",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "time_created": {+ "name": "time_created",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "time_updated": {+ "name": "time_updated",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)"+ },+ "time_deleted": {+ "name": "time_deleted",+ "type": "timestamp(3)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "slug": {+ "name": "slug",+ "columns": [+ "slug"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "workspace_id": {+ "name": "workspace_id",+ "columns": [+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ }+ },+ "views": {},+ "_meta": {+ "schemas": {},+ "tables": {},+ "columns": {}+ },+ "internal": {+ "tables": {},+ "indexes": {}+ }+}\ No newline at end of filediff --git a/packages/console/core/migrations/meta/_journal.json b/packages/console/core/migrations/meta/_journal.jsonindex c534aaa590c..46d2db82130 100644--- a/packages/console/core/migrations/meta/_journal.json+++ b/packages/console/core/migrations/meta/_journal.json@@ -344,6 +344,20 @@"when": 1767917785224,"tag": "0048_mean_frank_castle","breakpoints": true+ },+ {+ "idx": 49,+ "version": "5",+ "when": 1767922954153,+ "tag": "0049_noisy_domino",+ "breakpoints": true+ },+ {+ "idx": 50,+ "version": "5",+ "when": 1767931290031,+ "tag": "0050_bumpy_mephistopheles",+ "breakpoints": true}]-}+}\ No newline at end of filediff --git a/packages/console/core/script/onboard-zen-black.ts b/packages/console/core/script/onboard-zen-black.tsindex 06e5afe1225..6ae4f2a2a40 100644--- a/packages/console/core/script/onboard-zen-black.ts+++ b/packages/console/core/script/onboard-zen-black.ts@@ -39,6 +39,9 @@ if (amountInCents !== 20000) {process.exit(1)}+const subscriptionData = await Billing.stripe().subscriptions.retrieve(subscription.id, { expand: ["discounts"] })+const couponID = subscriptionData.discounts[0]?.coupon?.id+// Check if subscription is already tied to another workspaceconst existingSubscription = await Database.use((tx) =>tx@@ -122,6 +125,7 @@ await Database.transaction(async (tx) => {.set({customerID,subscriptionID,+ subscriptionCouponID: couponID,paymentMethodID,paymentMethodLast4,paymentMethodType,@@ -143,6 +147,10 @@ await Database.transaction(async (tx) => {customerID,invoiceID,paymentID,+ enrichment: {+ type: "subscription",+ couponID,+ },})})diff --git a/packages/console/core/src/billing.ts b/packages/console/core/src/billing.tsindex c97dfff1ba1..181055c4e0d 100644--- a/packages/console/core/src/billing.ts+++ b/packages/console/core/src/billing.ts@@ -171,6 +171,9 @@ export namespace Billing {workspaceID,id: Identifier.create("payment"),amount: amountInMicroCents,+ enrichment: {+ type: "credit",+ },})})return amountInMicroCentsdiff --git a/packages/console/core/src/schema/billing.sql.ts b/packages/console/core/src/schema/billing.sql.tsindex f56cf4182d0..6c2cfcf96f8 100644--- a/packages/console/core/src/schema/billing.sql.ts+++ b/packages/console/core/src/schema/billing.sql.ts@@ -22,6 +22,7 @@ export const BillingTable = mysqlTable(timeReloadError: utc("time_reload_error"),timeReloadLockedTill: utc("time_reload_locked_till"),subscriptionID: varchar("subscription_id", { length: 28 }),+ subscriptionCouponID: varchar("subscription_coupon_id", { length: 28 }),},(table) => [...workspaceIndexes(table),@@ -54,6 +55,15 @@ export const PaymentTable = mysqlTable(paymentID: varchar("payment_id", { length: 255 }),amount: bigint("amount", { mode: "number" }).notNull(),timeRefunded: utc("time_refunded"),+ enrichment: json("enrichment").$type<+ | {+ type: "subscription"+ couponID?: string+ }+ | {+ type: "credit"+ }+ >(),},(table) => [...workspaceIndexes(table)],)