-
-
Notifications
You must be signed in to change notification settings - Fork 800
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add genre tables, read multiple-genres from tags
- Loading branch information
Showing
13 changed files
with
205 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package migrations | ||
|
||
import ( | ||
"database/sql" | ||
|
||
"github.com/pressly/goose" | ||
) | ||
|
||
func init() { | ||
goose.AddMigration(upAddGenreTables, downAddGenreTables) | ||
} | ||
|
||
func upAddGenreTables(tx *sql.Tx) error { | ||
_, err := tx.Exec(` | ||
create table if not exists genre | ||
( | ||
id varchar not null primary key, | ||
name varchar not null, | ||
constraint genre_name_ux | ||
unique (name) | ||
); | ||
create table if not exists album_genres | ||
( | ||
album_id varchar default null not null | ||
references album | ||
on delete cascade, | ||
genre_id varchar default null not null | ||
references genre | ||
on delete cascade, | ||
constraint album_genre_ux | ||
unique (album_id, genre_id) | ||
); | ||
create table if not exists media_file_genres | ||
( | ||
media_file_id varchar default null not null | ||
references media_file | ||
on delete cascade, | ||
genre_id varchar default null not null | ||
references genre | ||
on delete cascade, | ||
constraint media_file_genre_ux | ||
unique (media_file_id, genre_id) | ||
); | ||
create table if not exists artist_genres | ||
( | ||
artist_id varchar default null not null | ||
references artist | ||
on delete cascade, | ||
genre_id varchar default null not null | ||
references genre | ||
on delete cascade, | ||
constraint artist_genre_ux | ||
unique (artist_id, genre_id) | ||
); | ||
`) | ||
return err | ||
} | ||
|
||
func downAddGenreTables(tx *sql.Tx) error { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.