feat: add posts_per_page column to sites table
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
7c4dc0885e
commit
9b36a35c1a
|
|
@ -57,13 +57,14 @@ type PublishTarget struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Site struct {
|
type Site struct {
|
||||||
ID int64
|
ID int64
|
||||||
OwnerID int64
|
OwnerID int64
|
||||||
Guid string
|
Guid string
|
||||||
Title string
|
Title string
|
||||||
Tagline string
|
Tagline string
|
||||||
CreatedAt int64
|
CreatedAt int64
|
||||||
Timezone string
|
Timezone string
|
||||||
|
PostsPerPage int64
|
||||||
}
|
}
|
||||||
|
|
||||||
type Upload struct {
|
type Upload struct {
|
||||||
|
|
|
||||||
|
|
@ -28,18 +28,20 @@ INSERT INTO sites (
|
||||||
title,
|
title,
|
||||||
tagline,
|
tagline,
|
||||||
timezone,
|
timezone,
|
||||||
|
posts_per_page,
|
||||||
created_at
|
created_at
|
||||||
) VALUES (?, ?, ?, ?, ?, ?)
|
) VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||||
RETURNING id
|
RETURNING id
|
||||||
`
|
`
|
||||||
|
|
||||||
type InsertSiteParams struct {
|
type InsertSiteParams struct {
|
||||||
OwnerID int64
|
OwnerID int64
|
||||||
Guid string
|
Guid string
|
||||||
Title string
|
Title string
|
||||||
Tagline string
|
Tagline string
|
||||||
Timezone string
|
Timezone string
|
||||||
CreatedAt int64
|
PostsPerPage int64
|
||||||
|
CreatedAt int64
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *Queries) InsertSite(ctx context.Context, arg InsertSiteParams) (int64, error) {
|
func (q *Queries) InsertSite(ctx context.Context, arg InsertSiteParams) (int64, error) {
|
||||||
|
|
@ -49,6 +51,7 @@ func (q *Queries) InsertSite(ctx context.Context, arg InsertSiteParams) (int64,
|
||||||
arg.Title,
|
arg.Title,
|
||||||
arg.Tagline,
|
arg.Tagline,
|
||||||
arg.Timezone,
|
arg.Timezone,
|
||||||
|
arg.PostsPerPage,
|
||||||
arg.CreatedAt,
|
arg.CreatedAt,
|
||||||
)
|
)
|
||||||
var id int64
|
var id int64
|
||||||
|
|
@ -101,7 +104,7 @@ func (q *Queries) SelectAllSitesWithOwners(ctx context.Context) ([]SelectAllSite
|
||||||
}
|
}
|
||||||
|
|
||||||
const selectSiteByGUID = `-- name: SelectSiteByGUID :one
|
const selectSiteByGUID = `-- name: SelectSiteByGUID :one
|
||||||
SELECT id, owner_id, guid, title, tagline, created_at, timezone FROM sites WHERE guid = ?
|
SELECT id, owner_id, guid, title, tagline, created_at, timezone, posts_per_page FROM sites WHERE guid = ?
|
||||||
`
|
`
|
||||||
|
|
||||||
func (q *Queries) SelectSiteByGUID(ctx context.Context, guid string) (Site, error) {
|
func (q *Queries) SelectSiteByGUID(ctx context.Context, guid string) (Site, error) {
|
||||||
|
|
@ -115,12 +118,13 @@ func (q *Queries) SelectSiteByGUID(ctx context.Context, guid string) (Site, erro
|
||||||
&i.Tagline,
|
&i.Tagline,
|
||||||
&i.CreatedAt,
|
&i.CreatedAt,
|
||||||
&i.Timezone,
|
&i.Timezone,
|
||||||
|
&i.PostsPerPage,
|
||||||
)
|
)
|
||||||
return i, err
|
return i, err
|
||||||
}
|
}
|
||||||
|
|
||||||
const selectSiteByID = `-- name: SelectSiteByID :one
|
const selectSiteByID = `-- name: SelectSiteByID :one
|
||||||
SELECT id, owner_id, guid, title, tagline, created_at, timezone FROM sites WHERE id = ?
|
SELECT id, owner_id, guid, title, tagline, created_at, timezone, posts_per_page FROM sites WHERE id = ?
|
||||||
`
|
`
|
||||||
|
|
||||||
func (q *Queries) SelectSiteByID(ctx context.Context, id int64) (Site, error) {
|
func (q *Queries) SelectSiteByID(ctx context.Context, id int64) (Site, error) {
|
||||||
|
|
@ -134,12 +138,13 @@ func (q *Queries) SelectSiteByID(ctx context.Context, id int64) (Site, error) {
|
||||||
&i.Tagline,
|
&i.Tagline,
|
||||||
&i.CreatedAt,
|
&i.CreatedAt,
|
||||||
&i.Timezone,
|
&i.Timezone,
|
||||||
|
&i.PostsPerPage,
|
||||||
)
|
)
|
||||||
return i, err
|
return i, err
|
||||||
}
|
}
|
||||||
|
|
||||||
const selectSitesOwnedByUser = `-- name: SelectSitesOwnedByUser :many
|
const selectSitesOwnedByUser = `-- name: SelectSitesOwnedByUser :many
|
||||||
SELECT id, owner_id, guid, title, tagline, created_at, timezone FROM sites WHERE owner_id = ? ORDER BY title ASC
|
SELECT id, owner_id, guid, title, tagline, created_at, timezone, posts_per_page FROM sites WHERE owner_id = ? ORDER BY title ASC
|
||||||
`
|
`
|
||||||
|
|
||||||
func (q *Queries) SelectSitesOwnedByUser(ctx context.Context, ownerID int64) ([]Site, error) {
|
func (q *Queries) SelectSitesOwnedByUser(ctx context.Context, ownerID int64) ([]Site, error) {
|
||||||
|
|
@ -159,6 +164,7 @@ func (q *Queries) SelectSitesOwnedByUser(ctx context.Context, ownerID int64) ([]
|
||||||
&i.Tagline,
|
&i.Tagline,
|
||||||
&i.CreatedAt,
|
&i.CreatedAt,
|
||||||
&i.Timezone,
|
&i.Timezone,
|
||||||
|
&i.PostsPerPage,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -174,14 +180,15 @@ func (q *Queries) SelectSitesOwnedByUser(ctx context.Context, ownerID int64) ([]
|
||||||
}
|
}
|
||||||
|
|
||||||
const updateSite = `-- name: UpdateSite :exec
|
const updateSite = `-- name: UpdateSite :exec
|
||||||
UPDATE sites SET title = ?, tagline = ?, timezone = ? WHERE id = ?
|
UPDATE sites SET title = ?, tagline = ?, timezone = ?, posts_per_page = ? WHERE id = ?
|
||||||
`
|
`
|
||||||
|
|
||||||
type UpdateSiteParams struct {
|
type UpdateSiteParams struct {
|
||||||
Title string
|
Title string
|
||||||
Tagline string
|
Tagline string
|
||||||
Timezone string
|
Timezone string
|
||||||
ID int64
|
PostsPerPage int64
|
||||||
|
ID int64
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *Queries) UpdateSite(ctx context.Context, arg UpdateSiteParams) error {
|
func (q *Queries) UpdateSite(ctx context.Context, arg UpdateSiteParams) error {
|
||||||
|
|
@ -189,6 +196,7 @@ func (q *Queries) UpdateSite(ctx context.Context, arg UpdateSiteParams) error {
|
||||||
arg.Title,
|
arg.Title,
|
||||||
arg.Tagline,
|
arg.Tagline,
|
||||||
arg.Timezone,
|
arg.Timezone,
|
||||||
|
arg.PostsPerPage,
|
||||||
arg.ID,
|
arg.ID,
|
||||||
)
|
)
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
|
|
@ -14,15 +14,16 @@ INSERT INTO sites (
|
||||||
title,
|
title,
|
||||||
tagline,
|
tagline,
|
||||||
timezone,
|
timezone,
|
||||||
|
posts_per_page,
|
||||||
created_at
|
created_at
|
||||||
) VALUES (?, ?, ?, ?, ?, ?)
|
) VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||||
RETURNING id;
|
RETURNING id;
|
||||||
|
|
||||||
-- name: HasUsersAndSites :one
|
-- name: HasUsersAndSites :one
|
||||||
SELECT (SELECT COUNT(*) FROM users) > 0 AND (SELECT COUNT(*) FROM sites) > 0 AS has_users_and_sites;
|
SELECT (SELECT COUNT(*) FROM users) > 0 AND (SELECT COUNT(*) FROM sites) > 0 AS has_users_and_sites;
|
||||||
|
|
||||||
-- name: UpdateSite :exec
|
-- name: UpdateSite :exec
|
||||||
UPDATE sites SET title = ?, tagline = ?, timezone = ? WHERE id = ?;
|
UPDATE sites SET title = ?, tagline = ?, timezone = ?, posts_per_page = ? WHERE id = ?;
|
||||||
|
|
||||||
-- name: SelectAllSitesWithOwners :many
|
-- name: SelectAllSitesWithOwners :many
|
||||||
SELECT s.id, s.guid, s.title, s.owner_id, u.username
|
SELECT s.id, s.guid, s.title, s.owner_id, u.username
|
||||||
|
|
|
||||||
1
sql/schema/05_posts_per_page.up.sql
Normal file
1
sql/schema/05_posts_per_page.up.sql
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
ALTER TABLE sites ADD COLUMN posts_per_page INTEGER NOT NULL DEFAULT 10;
|
||||||
Loading…
Reference in a new issue