Skip to content

Commit

Permalink
Add a mechanism to perform database migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
Polochon-street committed Jul 30, 2024
1 parent 7dc1dda commit 3f5881f
Show file tree
Hide file tree
Showing 5 changed files with 361 additions and 57 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## bliss 0.9.0
* Add a mechanism to do migrations for Libraries, to make sure we're ready
for potential new features.
* Make `track_number` an integer, and not a string.

## bliss 0.8.0
* Remove the `number_songs` option from `Library::playlist_from_custom`.
Since it now returns an Iterator, `number_songs` can just be replaced by `take`.
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bliss-audio"
version = "0.8.0"
version = "0.9.0"
build = "build.rs"
authors = ["Polochon-street <[email protected]>"]
edition = "2021"
Expand Down
135 changes: 135 additions & 0 deletions data/old_database.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
create table song (
id integer primary key,
path text not null unique,
duration float,
album_artist text,
artist text,
title text,
album text,
track_number text,
genre text,
cue_path text,
audio_file_path text,
stamp timestamp default current_timestamp,
version integer,
analyzed boolean default false,
extra_info json,
error text
);
create table feature (
id integer primary key,
song_id integer not null,
feature real not null,
feature_index integer not null,
unique(song_id, feature_index),
foreign key(song_id) references song(id) on delete cascade
);

insert into song (
id, path, artist, title, album, album_artist,
track_number, genre, stamp, version, duration, analyzed,
extra_info
)
values (
1, '/random/path', 'Some Artist', 'A Title', 'Some Album',
'Some Album Artist', '01', 'Electronica', '2022-01-01',
1, 250, true, '{\"key\": \"value\"}'
),
(
2, '/random/path2', 'Some Artist', 'A Title', 'Some Album',
'Some Album Artist', '', 'Electronica', '2022-01-01',
1, 250, true, '{\"key\": \"value\"}'
),
(
3, '/random/path3', 'Some Artist', 'A Title', 'Some Album',
'Some Album Artist', null, 'Electronica', '2022-01-01',
1, 250, true, '{\"key\": \"value\"}'
),
(
4, '/random/path4', 'Some Artist', 'A Title', 'Some Album',
'Some Album Artist', 'test', 'Electronica', '2022-01-01',
1, 250, true, '{\"key\": \"value\"}'
);

insert into feature (song_id, feature, feature_index)
values
(1, 1.1, 1),
(1, 1.1, 2),
(1, 1.1, 3),
(1, 1.1, 4),
(1, 1.1, 5),
(1, 1.1, 6),
(1, 1.1, 7),
(1, 1.1, 8),
(1, 1.1, 9),
(1, 1.1, 10),
(1, 1.1, 11),
(1, 1.1, 12),
(1, 1.1, 13),
(1, 1.1, 14),
(1, 1.1, 15),
(1, 1.1, 16),
(1, 1.1, 17),
(1, 1.1, 18),
(1, 1.1, 19),
(1, 1.1, 20),
(2, 2.1, 1),
(2, 2.1, 2),
(2, 2.1, 3),
(2, 2.1, 4),
(2, 2.1, 5),
(2, 2.1, 6),
(2, 2.1, 7),
(2, 2.1, 8),
(2, 2.1, 9),
(2, 2.1, 10),
(2, 2.1, 11),
(2, 2.1, 12),
(2, 2.1, 13),
(2, 2.1, 14),
(2, 2.1, 15),
(2, 2.1, 16),
(2, 2.1, 17),
(2, 2.1, 18),
(2, 2.1, 19),
(2, 2.1, 20),
(3, 3.1, 1),
(3, 3.1, 2),
(3, 3.1, 3),
(3, 3.1, 4),
(3, 3.1, 5),
(3, 3.1, 6),
(3, 3.1, 7),
(3, 3.1, 8),
(3, 3.1, 9),
(3, 3.1, 10),
(3, 3.1, 11),
(3, 3.1, 12),
(3, 3.1, 13),
(3, 3.1, 14),
(3, 3.1, 15),
(3, 3.1, 16),
(3, 3.1, 17),
(3, 3.1, 18),
(3, 3.1, 19),
(3, 3.1, 20),
(4, 4.1, 1),
(4, 4.1, 2),
(4, 4.1, 3),
(4, 4.1, 4),
(4, 4.1, 5),
(4, 4.1, 6),
(4, 4.1, 7),
(4, 4.1, 8),
(4, 4.1, 9),
(4, 4.1, 10),
(4, 4.1, 11),
(4, 4.1, 12),
(4, 4.1, 13),
(4, 4.1, 14),
(4, 4.1, 15),
(4, 4.1, 16),
(4, 4.1, 17),
(4, 4.1, 18),
(4, 4.1, 19),
(4, 4.1, 20);
Loading

0 comments on commit 3f5881f

Please sign in to comment.