92ef53c04d
Table was referenced in migration 0005's comment but never created — this slice fills the gap. Soft-delete via deleted_at column; hot-path partial index on active rows; GIN index on session_vector for M3 sub-plan #3's similarity queries.
53 lines
1.4 KiB
Go
53 lines
1.4 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.31.1
|
|
// source: contextual_likes.sql
|
|
|
|
package dbq
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const insertContextualLike = `-- name: InsertContextualLike :exec
|
|
INSERT INTO contextual_likes (user_id, track_id, session_vector, session_id)
|
|
VALUES ($1, $2, $3, $4)
|
|
`
|
|
|
|
type InsertContextualLikeParams struct {
|
|
UserID pgtype.UUID
|
|
TrackID pgtype.UUID
|
|
SessionVector []byte
|
|
SessionID pgtype.UUID
|
|
}
|
|
|
|
func (q *Queries) InsertContextualLike(ctx context.Context, arg InsertContextualLikeParams) error {
|
|
_, err := q.db.Exec(ctx, insertContextualLike,
|
|
arg.UserID,
|
|
arg.TrackID,
|
|
arg.SessionVector,
|
|
arg.SessionID,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const softDeleteContextualLikesForUserTrack = `-- name: SoftDeleteContextualLikesForUserTrack :exec
|
|
UPDATE contextual_likes
|
|
SET deleted_at = now()
|
|
WHERE user_id = $1 AND track_id = $2 AND deleted_at IS NULL
|
|
`
|
|
|
|
type SoftDeleteContextualLikesForUserTrackParams struct {
|
|
UserID pgtype.UUID
|
|
TrackID pgtype.UUID
|
|
}
|
|
|
|
// Marks all currently-active rows for (user, track) as deleted. Idempotent —
|
|
// already-deleted rows aren't re-touched.
|
|
func (q *Queries) SoftDeleteContextualLikesForUserTrack(ctx context.Context, arg SoftDeleteContextualLikesForUserTrackParams) error {
|
|
_, err := q.db.Exec(ctx, softDeleteContextualLikesForUserTrack, arg.UserID, arg.TrackID)
|
|
return err
|
|
}
|