quintodrome/db/migrations/20211008205505_add_smart_playlist.go

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

39 lines
842 B
Go
Raw Permalink Normal View History

2021-10-08 18:23:43 -08:00
package migrations
import (
2023-11-27 10:46:44 -09:00
"context"
2021-10-08 18:23:43 -08:00
"database/sql"
2023-04-04 05:57:00 -08:00
"github.com/pressly/goose/v3"
2021-10-08 18:23:43 -08:00
)
func init() {
2023-11-27 10:46:44 -09:00
goose.AddMigrationContext(upAddSmartPlaylist, downAddSmartPlaylist)
2021-10-08 18:23:43 -08:00
}
2023-11-27 10:46:44 -09:00
func upAddSmartPlaylist(_ context.Context, tx *sql.Tx) error {
2021-10-08 18:23:43 -08:00
_, err := tx.Exec(`
alter table playlist
add column rules varchar null;
alter table playlist
add column evaluated_at datetime null;
create index if not exists playlist_evaluated_at
on playlist(evaluated_at);
create table playlist_fields (
field varchar(255) not null,
playlist_id varchar(255) not null
constraint playlist_fields_playlist_id_fk
references playlist
on update cascade on delete cascade
);
create unique index playlist_fields_idx
on playlist_fields (field, playlist_id);
`)
return err
}
2023-11-27 10:46:44 -09:00
func downAddSmartPlaylist(_ context.Context, tx *sql.Tx) error {
2021-10-08 18:23:43 -08:00
return nil
}