Sha256: 41acd8940497a18350c116f03e43dc050a3473eb899a7d9d3d3997da3136dcd1
Contents?: true
Size: 854 Bytes
Versions: 2
Compression:
Stored size: 854 Bytes
Contents
require 'yaml' require 'securerandom' require 'gdshowsdb' class ImportShows < ActiveRecord::Migration include Gdshowsdb def up (1965..1995).each do |year| create_shows(year) create_sets(year) create_songs(year) end end def down Song.delete_all ShowSet.delete_all Show.delete_all end private def create_shows(year) show_yaml_parser = ShowYAMLParser.from_yaml(year) show_yaml_parser.parse.each do |show_yaml| show = Show.create(show_yaml) puts "Created #{show.title}" end end def create_sets(year) set_yaml_parser = SetYAMLParser.from_yaml(year) set_yaml_parser.parse.each do |set_yaml| ShowSet.create_from(set_yaml) end end def create_songs(year) song_yaml_parser = SongYAMLParser.from_yaml(year) song_yaml_parser.parse.each do |song_yaml| Song.create_from(song_yaml) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gdshowsdb-0.9.1 | lib/gdshowsdb/db/migrations/009_import_shows.rb |
gdshowsdb-0.9.0 | lib/gdshowsdb/db/migrations/009_import_shows.rb |