navidrome/db/migration/20200423204116_add_sort_fie...

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

67 lines
1.9 KiB
Go
Raw Normal View History

package migrations
2020-04-24 16:13:59 +02:00
import (
2023-11-27 20:46:44 +01:00
"context"
2020-04-24 16:13:59 +02:00
"database/sql"
2020-04-26 18:53:36 +02:00
2023-04-04 15:57:00 +02:00
"github.com/pressly/goose/v3"
2020-04-24 16:13:59 +02:00
)
func init() {
2023-11-27 20:46:44 +01:00
goose.AddMigrationContext(Up20200423204116, Down20200423204116)
2020-04-24 16:13:59 +02:00
}
2023-11-27 20:46:44 +01:00
func Up20200423204116(_ context.Context, tx *sql.Tx) error {
2020-04-24 16:13:59 +02:00
_, err := tx.Exec(`
alter table artist
add order_artist_name varchar(255) collate nocase;
alter table artist
add sort_artist_name varchar(255) collate nocase;
create index if not exists artist_order_artist_name
on artist (order_artist_name);
alter table album
add order_album_name varchar(255) collate nocase;
alter table album
add order_album_artist_name varchar(255) collate nocase;
alter table album
add sort_album_name varchar(255) collate nocase;
alter table album
add sort_artist_name varchar(255) collate nocase;
alter table album
add sort_album_artist_name varchar(255) collate nocase;
create index if not exists album_order_album_name
on album (order_album_name);
create index if not exists album_order_album_artist_name
on album (order_album_artist_name);
alter table media_file
add order_album_name varchar(255) collate nocase;
alter table media_file
add order_album_artist_name varchar(255) collate nocase;
alter table media_file
add order_artist_name varchar(255) collate nocase;
alter table media_file
add sort_album_name varchar(255) collate nocase;
alter table media_file
add sort_artist_name varchar(255) collate nocase;
alter table media_file
add sort_album_artist_name varchar(255) collate nocase;
alter table media_file
add sort_title varchar(255) collate nocase;
create index if not exists media_file_order_album_name
on media_file (order_album_name);
create index if not exists media_file_order_artist_name
on media_file (order_artist_name);
`)
if err != nil {
return err
}
notice(tx, "A full rescan will be performed to change the search behaviour")
return forceFullRescan(tx)
}
2023-11-27 20:46:44 +01:00
func Down20200423204116(_ context.Context, tx *sql.Tx) error {
2020-04-24 16:13:59 +02:00
return nil
}