feat(seller): add seller_stripe_accounts migration and model

This commit is contained in:
senke 2026-02-23 22:11:11 +01:00
parent ae81e171c7
commit 941f6e6f3e
2 changed files with 41 additions and 0 deletions

View file

@ -0,0 +1,24 @@
package models
import (
"time"
"github.com/google/uuid"
)
// SellerStripeAccount links a user (seller) to their Stripe Connect Express account
type SellerStripeAccount struct {
ID uuid.UUID `json:"id" gorm:"type:uuid;primaryKey;default:gen_random_uuid()"`
UserID uuid.UUID `json:"user_id" gorm:"type:uuid;uniqueIndex;not null"`
StripeAccountID string `json:"stripe_account_id" gorm:"type:varchar(255);uniqueIndex;not null"`
ChargesEnabled bool `json:"charges_enabled" gorm:"default:false"`
PayoutsEnabled bool `json:"payouts_enabled" gorm:"default:false"`
OnboardingCompleted bool `json:"onboarding_completed" gorm:"default:false"`
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"`
UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"`
}
// TableName specifies the table name for SellerStripeAccount
func (SellerStripeAccount) TableName() string {
return "seller_stripe_accounts"
}

View file

@ -0,0 +1,17 @@
-- Migration 114: Seller Stripe Connect accounts (v0.602)
-- Links users (sellers) to their Stripe Connect Express accounts
CREATE TABLE IF NOT EXISTS seller_stripe_accounts (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
stripe_account_id VARCHAR(255) NOT NULL,
charges_enabled BOOLEAN DEFAULT FALSE,
payouts_enabled BOOLEAN DEFAULT FALSE,
onboarding_completed BOOLEAN DEFAULT FALSE,
created_at TIMESTAMPTZ DEFAULT NOW(),
updated_at TIMESTAMPTZ DEFAULT NOW(),
CONSTRAINT uq_seller_stripe_user UNIQUE (user_id),
CONSTRAINT uq_seller_stripe_account UNIQUE (stripe_account_id)
);
CREATE INDEX idx_seller_stripe_accounts_user ON seller_stripe_accounts(user_id);