mirror of
https://github.com/nkanaev/yarr.git
synced 2025-11-07 18:09:36 +00:00
support multiple media links
This commit is contained in:
@@ -17,6 +17,7 @@ var migrations = []func(*sql.Tx) error{
|
||||
m07_add_feed_size,
|
||||
m08_normalize_datetime,
|
||||
m09_change_item_index,
|
||||
m10_add_item_medialinks,
|
||||
}
|
||||
|
||||
var maxVersion = int64(len(migrations))
|
||||
@@ -306,3 +307,28 @@ func m09_change_item_index(tx *sql.Tx) error {
|
||||
_, err := tx.Exec(sql)
|
||||
return err
|
||||
}
|
||||
|
||||
func m10_add_item_medialinks(tx *sql.Tx) error {
|
||||
sql := `
|
||||
alter table items add column media_links blob;
|
||||
update items set media_links =
|
||||
iif(
|
||||
coalesce(image, '') != '' and coalesce(podcast_url, '') != '',
|
||||
json_array(json_object('type', 'image', 'url', image), json_object('type', 'audio', 'url', podcast_url)),
|
||||
iif(
|
||||
coalesce(image, '') != '',
|
||||
json_array(json_object('type', 'image', 'url', image)),
|
||||
iif(
|
||||
coalesce(podcast_url, '') != '',
|
||||
json_array(json_object('type', 'audio', 'url', podcast_url)),
|
||||
null
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
alter table items drop column image;
|
||||
alter table items drop column podcast_url;
|
||||
`
|
||||
_, err := tx.Exec(sql)
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user