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.49 lib/generators/active_record_survey/templates/migration_0.1.0.rb
active_record_survey-0.1.48 lib/generators/active_record_survey/templates/migration_0.1.0.rb
active_record_survey-0.1.47 lib/generators/active_record_survey/templates/migration_0.1.0.rb
active_record_survey-0.1.46 lib/generators/active_record_survey/templates/migration_0.1.0.rb
active_record_survey-0.1.45 lib/generators/active_record_survey/templates/migration_0.1.0.rb
active_record_survey-0.1.44 lib/generators/active_record_survey/templates/migration_0.1.0.rb
active_record_survey-0.1.43 lib/generators/active_record_survey/templates/migration_0.1.0.rb
active_record_survey-0.1.42 lib/generators/active_record_survey/templates/migration_0.1.0.rb
active_record_survey-0.1.41 lib/generators/active_record_survey/templates/migration_0.1.0.rb
active_record_survey-0.1.40 lib/generators/active_record_survey/templates/migration_0.1.0.rb
active_record_survey-0.1.39 lib/generators/active_record_survey/templates/migration_0.1.0.rb
active_record_survey-0.1.38 lib/generators/active_record_survey/templates/migration_0.1.0.rb
active_record_survey-0.1.37 lib/generators/active_record_survey/templates/migration_0.1.0.rb
active_record_survey-0.1.36 lib/generators/active_record_survey/templates/migration_0.1.0.rb
active_record_survey-0.1.35 lib/generators/active_record_survey/templates/migration_0.1.0.rb
active_record_survey-0.1.34 lib/generators/active_record_survey/templates/migration_0.1.0.rb
active_record_survey-0.1.32 lib/generators/active_record_survey/templates/migration_0.1.0.rb
active_record_survey-0.1.31 lib/generators/active_record_survey/templates/migration_0.1.0.rb
active_record_survey-0.1.30 lib/generators/active_record_survey/templates/migration_0.1.0.rb
active_record_survey-0.1.29 lib/generators/active_record_survey/templates/migration_0.1.0.rb