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-3.1.0 db/migrate/20090717175825_normalize_entries_subjects.rb
muck-raker-3.0.0 db/migrate/20090717175825_normalize_entries_subjects.rb
muck-raker-3.0.0 test/rails_test/db/migrate/20090717175825_normalize_entries_subjects.rb
muck-raker-0.3.18 db/migrate/20090717175825_normalize_entries_subjects.rb
muck-raker-0.3.18 test/rails_root/db/migrate/20090717175825_normalize_entries_subjects.rb
muck-raker-0.3.17 db/migrate/20090717175825_normalize_entries_subjects.rb
muck-raker-0.3.17 test/rails_root/db/migrate/20090717175825_normalize_entries_subjects.rb
muck-raker-0.3.16 test/rails_root/db/migrate/20090717175825_normalize_entries_subjects.rb
muck-raker-0.3.16 db/migrate/20090717175825_normalize_entries_subjects.rb
muck-raker-0.3.15 test/rails_root/db/migrate/20090717175825_normalize_entries_subjects.rb
muck-raker-0.3.15 db/migrate/20090717175825_normalize_entries_subjects.rb
muck-raker-0.3.14 test/rails_root/db/migrate/20090717175825_normalize_entries_subjects.rb
muck-raker-0.3.14 db/migrate/20090717175825_normalize_entries_subjects.rb
muck-profiles-0.2.1 test/rails_root/db/migrate/20090717175825_normalize_entries_subjects.rb
muck-profiles-0.2.0 test/rails_root/db/migrate/20090717175825_normalize_entries_subjects.rb
muck-raker-0.3.13 test/rails_root/db/migrate/20090717175825_normalize_entries_subjects.rb
muck-raker-0.3.13 db/migrate/20090717175825_normalize_entries_subjects.rb
muck-raker-0.3.11 test/rails_root/db/migrate/20090717175825_normalize_entries_subjects.rb
muck-raker-0.3.11 db/migrate/20090717175825_normalize_entries_subjects.rb
muck-raker-0.3.10 db/migrate/20090717175825_normalize_entries_subjects.rb