Sha256: a2c0acc33a653caec4bcf585193514485c9bcd38dabef483b14a77c1977807b4

Contents?: true

Size: 1.51 KB

Versions: 23

Compression:

Stored size: 1.51 KB

Contents

class AddActiveRecordSurvey < ActiveRecord::Migration
	def self.up
		create_table :active_record_surveys do |t|
			t.timestamps null: false
		end

		create_table :active_record_survey_nodes do |t|
			t.string :type

			t.timestamps null: false
		end

		create_table :active_record_survey_node_validations do |t|
			t.references :active_record_survey_node
			t.string :type
			t.string :value

			t.timestamps null: false
		end

		create_table :active_record_survey_node_maps do |t|
			t.references :active_record_survey_node

			# AwesomeNestedSet fields
			t.integer :parent_id, :null => true, :index => true
			t.integer :lft, :null => false, :index => true
			t.integer :rgt, :null => false, :index => true

			# optional fields
			t.integer :depth, :null => false, :default => 0
			t.integer :children_count, :null => false, :default => 0

			t.references :active_record_survey

			t.timestamps null: false
		end

		create_table :active_record_survey_instances do |t|
			t.references :active_record_survey

			t.timestamps null: false
		end
		create_table :active_record_survey_instance_nodes do |t|
			t.references :active_record_survey_instance
			t.references :active_record_survey_node
			t.string :value

			t.timestamps null: false
		end
	end

	def self.down
		drop_table :active_record_surveys
		drop_table :active_record_survey_nodes
		drop_table :active_record_survey_node_validations
		drop_table :active_record_survey_node_maps
		drop_table :active_record_survey_instances
		drop_table :active_record_survey_instance_nodes
	end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
active_record_survey-0.1.28 lib/generators/active_record_survey/templates/migration_0.1.0.rb
active_record_survey-0.1.27 lib/generators/active_record_survey/templates/migration_0.1.0.rb
active_record_survey-0.1.26 lib/generators/active_record_survey/templates/migration_0.1.0.rb