Inserts or updates the print store URL for an artwork. Use this when an artist wants to link their artwork to an external print-on-demand service. The function determines INSERT vs UPDATE based on whether the artwork already has a print record.
Arguments
- url
Character. The print store URL. If `NULL` or empty string, the function returns early without making changes.
- artist
Character. Artist UUID.
- artwork
Character. Artwork UUID.
- has_print
Logical. If `TRUE`, updates existing record in `app.artwork_print`. If `FALSE`, inserts new record and sets `is_print = TRUE` in `app.artwork_index`.
- cn
Database connection. If `NULL`, opens and closes automatically.
Details
This function performs two different operations based on `has_print`:
**When `has_print = TRUE` (UPDATE):** - Updates `print_url` in existing `app.artwork_print` record
**When `has_print = FALSE` (INSERT):** - Inserts new row into `app.artwork_print` - Sets `is_print = TRUE` in `app.artwork_index`
The `has_print` flag should come from `app.artwork_index.is_print` to ensure consistency.
Examples
if (FALSE) { # \dontrun{
# Update existing print URL
.upsert_print_url(
url = "https://society6.com/artist/artwork",
artist = "746b8207-72f5-4ab6-8d19-a91d03daec3d",
artwork = "99a61148-1d3b-4340-8cf6-92ad26046b0f",
has_print = TRUE
)
# Add new print URL (artwork not yet print-enabled)
.upsert_print_url(
url = "https://redbubble.com/shop/artwork",
artist = artist_uuid,
artwork = artwork_uuid,
has_print = FALSE
)
} # }
