feat(go): referral support (#28345)

Co-authored-by: Jack <jack@anoma.ly>
This commit is contained in:
Victor Navarro 2026-05-19 17:51:39 +02:00 committed by GitHub
commit b32f071502
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
54 changed files with 20809 additions and 206 deletions

View file

@ -0,0 +1,28 @@
import { bigint, mysqlTable, primaryKey, uniqueIndex } from "drizzle-orm/mysql-core"
import { timestamps, ulid, utc, workspaceColumns } from "../drizzle/types"
import { workspaceIndexes } from "./workspace.sql"
export const ReferralTable = mysqlTable(
"referral",
{
...workspaceColumns,
...timestamps,
inviteeAccountID: ulid("invitee_account_id").notNull(),
},
(table) => [
...workspaceIndexes(table),
uniqueIndex("referral_invitee_account_id").on(table.inviteeAccountID),
],
)
export const ReferralRewardTable = mysqlTable(
"referral_reward",
{
workspaceID: ulid("workspace_id").notNull(),
referralID: ulid("referral_id").notNull(),
...timestamps,
amount: bigint("amount", { mode: "number" }).notNull(),
timeApplied: utc("time_applied"),
},
(table) => [primaryKey({ columns: [table.workspaceID, table.referralID] })],
)