1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-12-22 17:06:17 +00:00

Ignore case for artists, albums, tracks and folder names, regardless of the DB

Closes #41
This commit is contained in:
spl0k 2018-03-11 19:33:15 +01:00
parent ecba5826b4
commit efbe0d4a4b
5 changed files with 73 additions and 7 deletions

View File

@ -74,7 +74,12 @@ _MySQL_-compatible or _PostgreSQL_ database.
_Supysonic_ does not automatically create the database and tables it needs to
work. Thus the database and tables must be created prior to running the
application. Please refer to the documentation of the DBMS you've chosen on how
to create a database and how to use a command-line client.
to create a database and how to use a command-line client. If you want to use
_PostgreSQL_ you'll have to add the `citext` extension to the database once
created. This can be done when connected to the database as the superuser with
the folowing SQL command:
supysonic=# CREATE EXTENSION citext;
Table creation scripts are provided in the `schema` folder for _SQLite_,
_MySQL_ and _PostgreSQL_. Just feed them to any client you're able to use.

View File

@ -0,0 +1,9 @@
START TRANSACTION;
ALTER TABLE folder ALTER COLUMN name TYPE CITEXT;
ALTER TABLE artist ALTER COLUMN name TYPE CITEXT;
ALTER TABLE album ALTER COLUMN name TYPE CITEXT;
ALTER TABLE track ALTER COLUMN title TYPE CITEXT;
COMMIT;

View File

@ -0,0 +1,52 @@
BEGIN TRANSACTION;
ALTER TABLE folder RENAME TO folder_old;
ALTER TABLE track RENAME TO track_old;
CREATE TABLE folder (
id CHAR(36) PRIMARY KEY,
root BOOLEAN NOT NULL,
name VARCHAR(256) NOT NULL COLLATE NOCASE,
path VARCHAR(4096) NOT NULL,
created DATETIME NOT NULL,
has_cover_art BOOLEAN NOT NULL,
last_scan INTEGER NOT NULL,
parent_id CHAR(36) REFERENCES folder
);
CREATE TABLE track (
id CHAR(36) PRIMARY KEY,
disc INTEGER NOT NULL,
number INTEGER NOT NULL,
title VARCHAR(256) NOT NULL COLLATE NOCASE,
year INTEGER,
genre VARCHAR(256),
duration INTEGER NOT NULL,
album_id CHAR(36) NOT NULL REFERENCES album,
artist_id CHAR(36) NOT NULL REFERENCES artist,
bitrate INTEGER NOT NULL,
path VARCHAR(4096) NOT NULL,
content_type VARCHAR(32) NOT NULL,
created DATETIME NOT NULL,
last_modification INTEGER NOT NULL,
play_count INTEGER NOT NULL,
last_play DATETIME,
root_folder_id CHAR(36) NOT NULL REFERENCES folder,
folder_id CHAR(36) NOT NULL REFERENCES folder
);
INSERT INTO folder (id, root, name, path, created, has_cover_art, last_scan, parent_id)
SELECT id, root, name, path, created, has_cover_art, last_scan, parent_id
FROM folder_old;
INSERT INTO track(id, disc, number, title, year, genre, duration, album_id, artist_id, bitrate, path, content_type, created, last_modification, play_count, last_play, root_folder_id, folder_id)
SELECT id, disc, number, title, year, genre, duration, album_id, artist_id, bitrate, path, content_type, created, last_modification, play_count, last_play, root_folder_id, folder_id
FROM track_old;
DROP TABLE folder_old;
DROP TABLE track_old;
COMMIT;
VACUUM;

View File

@ -1,7 +1,7 @@
CREATE TABLE folder (
id UUID PRIMARY KEY,
root BOOLEAN NOT NULL,
name VARCHAR(256) NOT NULL,
name CITEXT NOT NULL,
path VARCHAR(4096) NOT NULL,
created TIMESTAMP NOT NULL,
has_cover_art BOOLEAN NOT NULL,
@ -11,12 +11,12 @@ CREATE TABLE folder (
CREATE TABLE artist (
id UUID PRIMARY KEY,
name VARCHAR(256) NOT NULL
name CITEXT NOT NULL
);
CREATE TABLE album (
id UUID PRIMARY KEY,
name VARCHAR(256) NOT NULL,
name CITEXT NOT NULL,
artist_id UUID NOT NULL REFERENCES artist
);
@ -24,7 +24,7 @@ CREATE TABLE track (
id UUID PRIMARY KEY,
disc INTEGER NOT NULL,
number INTEGER NOT NULL,
title VARCHAR(256) NOT NULL,
title CITEXT NOT NULL,
year INTEGER,
genre VARCHAR(256),
duration INTEGER NOT NULL,

View File

@ -1,7 +1,7 @@
CREATE TABLE folder (
id CHAR(36) PRIMARY KEY,
root BOOLEAN NOT NULL,
name VARCHAR(256) NOT NULL,
name VARCHAR(256) NOT NULL COLLATE NOCASE,
path VARCHAR(4096) NOT NULL,
created DATETIME NOT NULL,
has_cover_art BOOLEAN NOT NULL,
@ -24,7 +24,7 @@ CREATE TABLE track (
id CHAR(36) PRIMARY KEY,
disc INTEGER NOT NULL,
number INTEGER NOT NULL,
title VARCHAR(256) NOT NULL,
title VARCHAR(256) NOT NULL COLLATE NOCASE,
year INTEGER,
genre VARCHAR(256),
duration INTEGER NOT NULL,