20 lines
358 B
Ruby
20 lines
358 B
Ruby
|
namespace :db do
|
||
|
desc 'Cleans artist-album-track relations clean'
|
||
|
task :cleanup => :environment do
|
||
|
|
||
|
albums = Album.all
|
||
|
albums.each do |album|
|
||
|
if album.artist.nil?
|
||
|
album.delete
|
||
|
end
|
||
|
end
|
||
|
|
||
|
tracks = Track.all
|
||
|
tracks.each do |track|
|
||
|
if track.album.nil?
|
||
|
track.delete
|
||
|
end
|
||
|
end
|
||
|
|
||
|
end
|
||
|
end
|