Sha256: fe411f7a746fd3f346fc7508253845aa4e06c8528abf0b0a2dd5e28d2c3fe83e

Contents?: true

Size: 1.97 KB

Versions: 37

Compression:

Stored size: 1.97 KB

Contents

class CreateLocalAuthorities < ActiveRecord::Migration
  def self.up
    create_table :local_authority_entries, force: true do |t|
      t.integer :local_authority_id
      t.string :label
      t.string :uri
    end

    create_table :local_authorities, force: true do |t|
      t.string :name, unique: true
    end

    create_table :domain_terms, force: true do |t|
      t.string :model
      t.string :term
    end

    create_table :domain_terms_local_authorities, id: false do |t|
      t.integer :domain_term_id, foreign_key: true
      t.integer :local_authority_id, foreign_key: true
    end

    create_table :subject_local_authority_entries, force: true  do |t|
      t.string :label
      t.string :lowerLabel
      t.string :url
    end

    add_index :local_authority_entries, [:local_authority_id, :label], name: 'entries_by_term_and_label'
    add_index :local_authority_entries, [:local_authority_id, :uri], name: 'entries_by_term_and_uri'
    add_index :domain_terms, [:model, :term], name: 'terms_by_model_and_term'
    add_index :domain_terms_local_authorities, [:local_authority_id, :domain_term_id], name: 'dtla_by_ids1'
    add_index :domain_terms_local_authorities, [:domain_term_id, :local_authority_id], name: 'dtla_by_ids2'
    add_index :subject_local_authority_entries, [:lowerLabel], name: 'entries_by_lower_label'
  end

  def self.down
    drop_table :local_authority_entries
    drop_table :local_authorities
    drop_table :domain_terms
    drop_table :domain_terms_local_authorities
    drop_table :subject_local_authority_entries
    remove_index :local_authority_entries, name: "entries_by_term_and_label"
    remove_index :local_authority_entries, name: "entries_by_term_and_uri"
    remove_index :domain_terms, name: "terms_by_model_and_term"
    remove_index :subject_local_authority_entries, name: 'entries_by_lower_label'
    remove_index :domain_terms_local_authorities, name: 'dtla_by_ids1'
    remove_index :domain_terms_local_authorities, name: 'dtla_by_ids2'
  end
end

Version data entries

37 entries across 37 versions & 2 rubygems

Version Path
sufia-models-6.2.0 lib/generators/sufia/models/templates/migrations/create_local_authorities.rb
sufia-models-6.1.0 lib/generators/sufia/models/templates/migrations/create_local_authorities.rb
sufia-5.0.0 sufia-models/lib/generators/sufia/models/templates/migrations/create_local_authorities.rb
sufia-models-5.0.0 lib/generators/sufia/models/templates/migrations/create_local_authorities.rb
sufia-models-6.0.0 lib/generators/sufia/models/templates/migrations/create_local_authorities.rb
sufia-6.0.0 sufia-models/lib/generators/sufia/models/templates/migrations/create_local_authorities.rb
sufia-6.0.0.rc4 sufia-models/lib/generators/sufia/models/templates/migrations/create_local_authorities.rb
sufia-models-6.0.0.rc4 lib/generators/sufia/models/templates/migrations/create_local_authorities.rb
sufia-6.0.0.rc3 sufia-models/lib/generators/sufia/models/templates/migrations/create_local_authorities.rb
sufia-models-6.0.0.rc3 lib/generators/sufia/models/templates/migrations/create_local_authorities.rb
sufia-5.0.0.rc1 sufia-models/lib/generators/sufia/models/templates/migrations/create_local_authorities.rb
sufia-models-5.0.0.rc1 lib/generators/sufia/models/templates/migrations/create_local_authorities.rb
sufia-6.0.0.rc2 sufia-models/lib/generators/sufia/models/templates/migrations/create_local_authorities.rb
sufia-models-6.0.0.rc2 lib/generators/sufia/models/templates/migrations/create_local_authorities.rb
sufia-6.0.0.rc1 sufia-models/lib/generators/sufia/models/templates/migrations/create_local_authorities.rb
sufia-models-6.0.0.rc1 lib/generators/sufia/models/templates/migrations/create_local_authorities.rb
sufia-4.3.1 sufia-models/lib/generators/sufia/models/templates/migrations/create_local_authorities.rb
sufia-models-4.3.1 lib/generators/sufia/models/templates/migrations/create_local_authorities.rb
sufia-6.0.0.beta1 sufia-models/lib/generators/sufia/models/templates/migrations/create_local_authorities.rb
sufia-models-6.0.0.beta1 lib/generators/sufia/models/templates/migrations/create_local_authorities.rb