258 lines
5.6 KiB
Go
258 lines
5.6 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.31.1
|
|
// source: seed.sql
|
|
|
|
package dbgen
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
const seedCampaign = `-- name: SeedCampaign :exec
|
|
INSERT INTO campaigns (id, slug, title, category, summary, art, goal_amount,
|
|
ends_at, status, owner_id)
|
|
VALUES ($1, $2, $3, $4, $5, $6, $7,
|
|
$8, $9::campaign_status, $10)
|
|
`
|
|
|
|
type SeedCampaignParams struct {
|
|
ID string
|
|
Slug string
|
|
Title string
|
|
Category string
|
|
Summary string
|
|
Art string
|
|
GoalAmount int
|
|
EndsAt time.Time
|
|
Status string
|
|
OwnerID string
|
|
}
|
|
|
|
func (q *Queries) SeedCampaign(ctx context.Context, arg SeedCampaignParams) error {
|
|
_, err := q.db.Exec(ctx, seedCampaign,
|
|
arg.ID,
|
|
arg.Slug,
|
|
arg.Title,
|
|
arg.Category,
|
|
arg.Summary,
|
|
arg.Art,
|
|
arg.GoalAmount,
|
|
arg.EndsAt,
|
|
arg.Status,
|
|
arg.OwnerID,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const seedCampaignUpdate = `-- name: SeedCampaignUpdate :exec
|
|
INSERT INTO campaign_updates (id, campaign_id, title, body)
|
|
VALUES ($1, $2, $3, $4)
|
|
`
|
|
|
|
type SeedCampaignUpdateParams struct {
|
|
ID string
|
|
CampaignID string
|
|
Title string
|
|
Body string
|
|
}
|
|
|
|
func (q *Queries) SeedCampaignUpdate(ctx context.Context, arg SeedCampaignUpdateParams) error {
|
|
_, err := q.db.Exec(ctx, seedCampaignUpdate,
|
|
arg.ID,
|
|
arg.CampaignID,
|
|
arg.Title,
|
|
arg.Body,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const seedComment = `-- name: SeedComment :exec
|
|
INSERT INTO comments (id, campaign_id, author_name, body)
|
|
VALUES ($1, $2, $3, $4)
|
|
`
|
|
|
|
type SeedCommentParams struct {
|
|
ID string
|
|
CampaignID string
|
|
AuthorName string
|
|
Body string
|
|
}
|
|
|
|
func (q *Queries) SeedComment(ctx context.Context, arg SeedCommentParams) error {
|
|
_, err := q.db.Exec(ctx, seedComment,
|
|
arg.ID,
|
|
arg.CampaignID,
|
|
arg.AuthorName,
|
|
arg.Body,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const seedOwner = `-- name: SeedOwner :one
|
|
INSERT INTO owners (id, slug, name, initials, location, blurb, avatar_url, approved)
|
|
VALUES ($1, $2, $3, $4, $5, $6, NULLIF($7, ''), true)
|
|
ON CONFLICT (slug) DO UPDATE SET name = EXCLUDED.name
|
|
RETURNING id
|
|
`
|
|
|
|
type SeedOwnerParams struct {
|
|
ID string
|
|
Slug string
|
|
Name string
|
|
Initials string
|
|
Location string
|
|
Blurb string
|
|
AvatarUrl interface{}
|
|
}
|
|
|
|
func (q *Queries) SeedOwner(ctx context.Context, arg SeedOwnerParams) (string, error) {
|
|
row := q.db.QueryRow(ctx, seedOwner,
|
|
arg.ID,
|
|
arg.Slug,
|
|
arg.Name,
|
|
arg.Initials,
|
|
arg.Location,
|
|
arg.Blurb,
|
|
arg.AvatarUrl,
|
|
)
|
|
var id string
|
|
err := row.Scan(&id)
|
|
return id, err
|
|
}
|
|
|
|
const seedPledge = `-- name: SeedPledge :exec
|
|
INSERT INTO pledges (id, campaign_id, tier_id, backer_email, quantity,
|
|
amount, status, captured_at)
|
|
VALUES ($1, $2, $3, $4, 1,
|
|
$5, $6::pledge_status, $7)
|
|
`
|
|
|
|
type SeedPledgeParams struct {
|
|
ID string
|
|
CampaignID string
|
|
TierID string
|
|
BackerEmail string
|
|
Amount int
|
|
Status string
|
|
CapturedAt *time.Time
|
|
}
|
|
|
|
func (q *Queries) SeedPledge(ctx context.Context, arg SeedPledgeParams) error {
|
|
_, err := q.db.Exec(ctx, seedPledge,
|
|
arg.ID,
|
|
arg.CampaignID,
|
|
arg.TierID,
|
|
arg.BackerEmail,
|
|
arg.Amount,
|
|
arg.Status,
|
|
arg.CapturedAt,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const seedReset = `-- name: SeedReset :exec
|
|
|
|
DELETE FROM pledges
|
|
`
|
|
|
|
// The development and CI fixture loader. Not reachable from the shipping
|
|
// image: the seeder is built from its own Dockerfile stage.
|
|
// Relations cascade, so campaigns and owners are enough; users go too because
|
|
// the fixture's pledges are anonymous and any account left behind is an orphan.
|
|
func (q *Queries) SeedReset(ctx context.Context) error {
|
|
_, err := q.db.Exec(ctx, seedReset)
|
|
return err
|
|
}
|
|
|
|
const seedResetCampaigns = `-- name: SeedResetCampaigns :exec
|
|
DELETE FROM campaigns
|
|
`
|
|
|
|
func (q *Queries) SeedResetCampaigns(ctx context.Context) error {
|
|
_, err := q.db.Exec(ctx, seedResetCampaigns)
|
|
return err
|
|
}
|
|
|
|
const seedResetOwners = `-- name: SeedResetOwners :exec
|
|
DELETE FROM owners
|
|
`
|
|
|
|
func (q *Queries) SeedResetOwners(ctx context.Context) error {
|
|
_, err := q.db.Exec(ctx, seedResetOwners)
|
|
return err
|
|
}
|
|
|
|
const seedResetUsers = `-- name: SeedResetUsers :exec
|
|
DELETE FROM users
|
|
`
|
|
|
|
func (q *Queries) SeedResetUsers(ctx context.Context) error {
|
|
_, err := q.db.Exec(ctx, seedResetUsers)
|
|
return err
|
|
}
|
|
|
|
const seedStorySection = `-- name: SeedStorySection :exec
|
|
INSERT INTO story_sections (id, campaign_id, heading, body, position)
|
|
VALUES ($1, $2, $3, $4, $5)
|
|
`
|
|
|
|
type SeedStorySectionParams struct {
|
|
ID string
|
|
CampaignID string
|
|
Heading string
|
|
Body []string
|
|
Position int
|
|
}
|
|
|
|
func (q *Queries) SeedStorySection(ctx context.Context, arg SeedStorySectionParams) error {
|
|
_, err := q.db.Exec(ctx, seedStorySection,
|
|
arg.ID,
|
|
arg.CampaignID,
|
|
arg.Heading,
|
|
arg.Body,
|
|
arg.Position,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const seedTier = `-- name: SeedTier :exec
|
|
INSERT INTO reward_tiers (id, campaign_id, type, price, list_price, title,
|
|
includes, inventory_limit, estimated_delivery,
|
|
featured, position)
|
|
VALUES ($1, $2, $3::tier_type, $4, $5, $6,
|
|
$7, $8, $9, $10, $11)
|
|
`
|
|
|
|
type SeedTierParams struct {
|
|
ID string
|
|
CampaignID string
|
|
Type string
|
|
Price int
|
|
ListPrice *int
|
|
Title string
|
|
Includes []string
|
|
InventoryLimit *int
|
|
EstimatedDelivery *time.Time
|
|
Featured bool
|
|
Position int
|
|
}
|
|
|
|
func (q *Queries) SeedTier(ctx context.Context, arg SeedTierParams) error {
|
|
_, err := q.db.Exec(ctx, seedTier,
|
|
arg.ID,
|
|
arg.CampaignID,
|
|
arg.Type,
|
|
arg.Price,
|
|
arg.ListPrice,
|
|
arg.Title,
|
|
arg.Includes,
|
|
arg.InventoryLimit,
|
|
arg.EstimatedDelivery,
|
|
arg.Featured,
|
|
arg.Position,
|
|
)
|
|
return err
|
|
}
|