diff --git a/veza-backend-api/internal/models/seller_stripe_account.go b/veza-backend-api/internal/models/seller_stripe_account.go new file mode 100644 index 000000000..43a100ed4 --- /dev/null +++ b/veza-backend-api/internal/models/seller_stripe_account.go @@ -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" +} diff --git a/veza-backend-api/migrations/114_seller_stripe_accounts.sql b/veza-backend-api/migrations/114_seller_stripe_accounts.sql new file mode 100644 index 000000000..ff0f77065 --- /dev/null +++ b/veza-backend-api/migrations/114_seller_stripe_accounts.sql @@ -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);