Sha256: d71dc5c17e61720ca4d927d9c4cbcbdb40d3c074a4b35aa305aa0c7d1b843543

Contents?: true

Size: 1.19 KB

Versions: 129

Compression:

Stored size: 1.19 KB

Contents

class NormalizeEntriesSubjects < ActiveRecord::Migration
  def self.up
    execute "ALTER TABLE entries_subjects DROP PRIMARY KEY, ADD PRIMARY KEY USING BTREE(subject_id, entry_id);"
    remove_column :entries_subjects, :language_id 
    remove_column :entries_subjects, :grain_size 
    execute "delete from entries_subjects where entry_id IN (select entries.id from entries inner join feeds ON feeds.id = entries.feed_id where feeds.uri = 'http://ndr.nsdl.org/oai?verb=ListRecords&metadataPrefix=nsdl_dc&set=439869');"
    execute "update feeds set last_harvested_at = '1969-01-01' where feeds.uri = 'http://ndr.nsdl.org/oai?verb=ListRecords&metadataPrefix=nsdl_dc&set=439869'"
  end

  def self.down
    add_column :entries_subjects, :language_id, :integer
    add_column :entries_subjects, :grain_size, :string
    add_index "entries_subjects", ["language_id"]
    add_index "entries_subjects", ["grain_size"]
    execute "ALTER TABLE entries_subjects DROP PRIMARY KEY, ADD PRIMARY KEY USING BTREE(subject_id, language_id, grain_size, entry_id);"
    execute "UPDATE entries_subjects AS es INNER JOIN entries AS e ON e.id = es.entry_id SET es.language_id = e.language_id, es.grain_size = e.grain_size"
  end
end

Version data entries

129 entries across 68 versions & 3 rubygems

Version Path
muck-raker-0.1.30 db/migrate/20090717175825_normalize_entries_subjects.rb
muck-raker-0.1.29 test/rails_root/db/migrate/20090717175825_normalize_entries_subjects.rb
muck-raker-0.1.29 db/migrate/20090717175825_normalize_entries_subjects.rb
muck-raker-0.1.28 db/migrate/20090717175825_normalize_entries_subjects.rb
muck-raker-0.1.28 test/rails_root/db/migrate/20090717175825_normalize_entries_subjects.rb
muck-raker-0.1.27 test/rails_root/db/migrate/20090717175825_normalize_entries_subjects.rb
muck-raker-0.1.27 db/migrate/20090717175825_normalize_entries_subjects.rb
muck-raker-0.1.22 db/migrate/20090717175825_normalize_entries_subjects.rb
muck-raker-0.1.22 test/rails_root/db/migrate/20090717175825_normalize_entries_subjects.rb
muck-raker-0.1.23 db/migrate/20090717175825_normalize_entries_subjects.rb
muck-raker-0.1.23 test/rails_root/db/migrate/20090717175825_normalize_entries_subjects.rb
muck-raker-0.1.24 test/rails_root/db/migrate/20090717175825_normalize_entries_subjects.rb
muck-raker-0.1.24 db/migrate/20090717175825_normalize_entries_subjects.rb
muck-raker-0.1.25 test/rails_root/db/migrate/20090717175825_normalize_entries_subjects.rb
muck-raker-0.1.25 db/migrate/20090717175825_normalize_entries_subjects.rb
muck-raker-0.1.26 db/migrate/20090717175825_normalize_entries_subjects.rb
muck-raker-0.1.26 test/rails_root/db/migrate/20090717175825_normalize_entries_subjects.rb
muck-raker-0.1.16 db/migrate/20090717175825_normalize_entries_subjects.rb
muck-raker-0.1.16 test/rails_root/db/migrate/20090717175825_normalize_entries_subjects.rb
muck-raker-0.1.17 db/migrate/20090717175825_normalize_entries_subjects.rb