Sha256: 5ddcc4a4b3a06843dd8f91a56e5defbc1fb524341718b424b1a1bd63114468b2

Contents?: true

Size: 1.7 KB

Versions: 8

Compression:

Stored size: 1.7 KB

Contents

class AddNotes < ActiveRecord::Migration
  def self.up
    unless table_exists?(:notes)
      create_table   :notes do |t|
        t.integer    :created_by_id
        t.text       :content
        t.references :noted_record, :polymorphic => true
        t.references :note_type

        t.timestamps
      end

      add_index :notes, [:noted_record_id, :noted_record_type]
      add_index :notes, :note_type_id
      add_index :notes, :created_by_id
      add_index :notes, :content
    end

    unless table_exists?(:note_types)
      create_table :note_types do |t|
        #these columns are required to support the behavior of the plugin 'awesome_nested_set'
        t.integer  	:parent_id
        t.integer  	:lft
        t.integer  	:rgt

        t.string     :description
        t.string     :internal_identifier
        t.string     :external_identifier
        t.references :note_type_record, :polymorphic => true

        t.timestamps
      end

      add_index :note_types, [:note_type_record_id, :note_type_record_type], :name => "note_type_record_idx"
    end

    unless table_exists?(:valid_note_types)
      create_table   :valid_note_types do |t|
        t.references :valid_note_type_record, :polymorphic => true
        t.references :note_type

        t.timestamps
      end

      add_index :valid_note_types, [:valid_note_type_record_id, :valid_note_type_record_type], :name => "valid_note_type_record_idx"
      add_index :valid_note_types, :note_type_id
    end
  end

  def self.down
    if table_exists?(:valid_note_types)
      drop_table :valid_note_types
    end

    if table_exists?(:note_types)
      drop_table :note_types
    end

    if table_exists?(:notes)
      drop_table :notes
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
erp_base_erp_svcs-3.0.7 db/migrate/upgrade/20110907171257_add_notes.rb
erp_base_erp_svcs-3.0.6 db/migrate/upgrade/20110907171257_add_notes.rb
erp_base_erp_svcs-3.0.5 db/migrate/upgrade/20110907171257_add_notes.rb
erp_base_erp_svcs-3.0.4 db/migrate/upgrade/20110907171257_add_notes.rb
erp_base_erp_svcs-3.0.3 db/migrate/upgrade/20110907171257_add_notes.rb
erp_base_erp_svcs-3.0.2 db/migrate/upgrade/20110907171257_add_notes.rb
erp_base_erp_svcs-3.0.1 db/migrate/upgrade/20110907171257_add_notes.rb
erp_base_erp_svcs-3.0.0 db/migrate/upgrade/20110907171257_add_notes.rb