replaced broken migration (#4) with correct version
This commit is contained in:
parent
e7d8c0a8e5
commit
decbc06992
@ -27,7 +27,7 @@ import Tracks, Tags from require "models"
|
|||||||
}
|
}
|
||||||
add_column "tracks", unpack column
|
add_column "tracks", unpack column
|
||||||
[3]: =>
|
[3]: =>
|
||||||
-- NOTE: bad migration!
|
-- NOTE: bad migration! (introduces more tags than it should)
|
||||||
for track in *Tracks\select "*"
|
for track in *Tracks\select "*"
|
||||||
tags = ""
|
tags = ""
|
||||||
for field in *{"artist", "mood", "link", "genre"}
|
for field in *{"artist", "mood", "link", "genre"}
|
||||||
@ -37,7 +37,7 @@ import Tracks, Tags from require "models"
|
|||||||
track.tags = process_tags trim(track.tags or "untagged") .. tags
|
track.tags = process_tags trim(track.tags or "untagged") .. tags
|
||||||
track\update "tags"
|
track\update "tags"
|
||||||
[4]: =>
|
[4]: =>
|
||||||
-- WARNING: removes all tags!
|
-- NOTE: bad migration! (doesn't save changes to database)
|
||||||
for track in *Tracks\select "*"
|
for track in *Tracks\select "*"
|
||||||
tags = ""
|
tags = ""
|
||||||
for field in *{"artist", "mood", "link", "genre"}
|
for field in *{"artist", "mood", "link", "genre"}
|
||||||
@ -62,5 +62,16 @@ import Tracks, Tags from require "models"
|
|||||||
tags[name] = 1
|
tags[name] = 1
|
||||||
for name, count in pairs tags
|
for name, count in pairs tags
|
||||||
Tags\create { :name, :count }
|
Tags\create { :name, :count }
|
||||||
|
[6]: =>
|
||||||
|
-- WARNING: removes all tags!
|
||||||
|
for track in *Tracks\select "*"
|
||||||
|
tags = ""
|
||||||
|
for field in *{"artist", "mood", "link", "genre"}
|
||||||
|
if track[field] and #track[field] > 0
|
||||||
|
tags ..= " #{field}:#{track[field]}"
|
||||||
|
if #tags > 0
|
||||||
|
track.tags = process_tags "untagged" .. tags
|
||||||
|
else
|
||||||
|
track.tags = " untagged "
|
||||||
|
track\update "tags"
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user