Sha256: a45c11a5f959c8a624fc63bf1c0a673dc153d0e69a7b867b915431048145957c

Contents?: true

Size: 1.38 KB

Versions: 8

Compression:

Stored size: 1.38 KB

Contents

class CreateCensusTables < ActiveRecord::Migration
  def self.up
    create_table :data_groups do |t|
      t.string  :name
      t.integer :position
      t.timestamps
    end

    create_table :questions do |t|
      t.integer :data_group_id
      t.string  :data_type
      t.string  :prompt
      t.boolean :multiple
      t.boolean :other
      t.integer :position
      t.timestamps
    end
    
    add_index :questions, :data_group_id, :name => "idx_qstns_datagrpid"
    
    create_table :choices do |t|
      t.integer :question_id
      t.string  :value
      t.integer :position
      t.timestamps
    end
    
    add_index :choices, :question_id, :name => "idx_choices_qstnid"
    
    create_table(:users) do |t|
      t.timestamps
    end

    create_table :answers do |t|
      t.integer :question_id
      t.integer :user_id
      t.string  :data
    end
    
    add_index :answers, :question_id, :name => "idx_answrs_qstnid"
    add_index :answers, :user_id, :name => "idx_answrs_usrid"
    
  end

  def self.down
    remove_index :answers, :name => "idx_answrs_qstnid"
    remove_index :answers, :name => "idx_answrs_usrid"
    drop_table :answers
    
    drop_table :users
    
    remove_index :choices, :name => "idx_choices_qstnid"
    drop_table :choices
    
    remove_index :questions, :name => "idx_qstns_datagrpid"
    drop_table :questions
    
    drop_table :data_groups
  end
end

Version data entries

8 entries across 4 versions & 1 rubygems

Version Path
census-0.5.0 generators/census/templates/migrations/with_users.rb
census-0.5.0 test/rails_root/db/migrate/20100630131015_create_census_tables.rb
census-0.4.4 generators/census/templates/migrations/with_users.rb
census-0.4.4 test/rails_root/db/migrate/20100630131015_create_census_tables.rb
census-0.4.3 generators/census/templates/migrations/with_users.rb
census-0.4.3 test/rails_root/db/migrate/20100602175828_create_census_tables.rb
census-0.4.2 generators/census/templates/migrations/with_users.rb
census-0.4.2 test/rails_root/db/migrate/20100526201135_create_census_tables.rb