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
co-authored by Jack
parent 512e34af83
commit b32f071502
54 changed files with 20809 additions and 206 deletions
@@ -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] })],
)
@@ -6,10 +6,14 @@ export const WorkspaceTable = mysqlTable(
{
id: ulid("id").notNull().primaryKey(),
slug: varchar("slug", { length: 255 }),
referralCode: varchar("referral_code", { length: 10 }),
name: varchar("name", { length: 255 }).notNull(),
...timestamps,
},
(table) => [uniqueIndex("slug").on(table.slug)],
(table) => [
uniqueIndex("slug").on(table.slug),
uniqueIndex("referral_code").on(table.referralCode),
],
)
export function workspaceIndexes(table: any) {