Sha256: aa86ce36de6f5e808fb2f56f0e05b4dd561fc0b6ea333d4678b17a3f2abcdd5a

Contents?: true

Size: 1.2 KB

Versions: 14

Compression:

Stored size: 1.2 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
    
    create_table :choices do |t|
      t.integer :question_id
      t.string  :value
      t.integer :position
      t.timestamps
    end
    
    add_index :choices, :question_id
    
    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
    add_index :answers, :user_id
    
  end

  def self.down
    remove_index :answers, :question_id
    remove_index :answers, :user_id
    drop_table :answers
    
    drop_table :users
    
    remove_index :choices, :question_id
    drop_table :choices
    
    remove_index :questions, :data_group_id
    drop_table :questions
    
    drop_table :data_groups
  end
end

Version data entries

14 entries across 7 versions & 1 rubygems

Version Path
census-0.4.1 test/rails_root/db/migrate/20100421154808_create_census_tables.rb
census-0.4.1 generators/census/templates/migrations/with_users.rb
census-0.4.0 test/rails_root/db/migrate/20100416173354_create_census_tables.rb
census-0.4.0 generators/census/templates/migrations/with_users.rb
census-0.3.1 generators/census/templates/migrations/with_users.rb
census-0.3.1 test/rails_root/db/migrate/20100408172932_create_census_tables.rb
census-0.3.0 test/rails_root/db/migrate/20100408132452_create_census_tables.rb
census-0.3.0 generators/census/templates/migrations/with_users.rb
census-0.2.1 test/rails_root/db/migrate/20100406184714_create_census_tables.rb
census-0.2.1 generators/census/templates/migrations/with_users.rb
census-0.2.0 test/rails_root/db/migrate/20100406184714_create_census_tables.rb
census-0.2.0 generators/census/templates/migrations/with_users.rb
census-0.1.0 generators/census/templates/migrations/with_users.rb
census-0.1.0 test/rails_root/db/migrate/20100406160306_create_census_tables.rb