Sha256: 11ce98781639df37c24a2683737f79adb2de74a3bdb19309d0e4d33e48beb8b7

Contents?: true

Size: 1.74 KB

Versions: 2

Compression:

Stored size: 1.74 KB

Contents

class CreateDynamicFieldsetsTables < ActiveRecord::Migration
  def self.up
    create_table :fieldset_associators do |t|
      t.integer :fieldset_id
      t.integer :fieldset_model_id
      t.string :fieldset_model_type
      t.string :fieldset_model_name

      t.timestamps
    end

    create_table :fieldsets do |t|
      t.string :nkey, :null => false
      t.string :name
      t.text :description
      t.integer :parent_fieldset_id
      t.integer :order_num

      t.timestamps
    end
    add_index :fieldsets, :nkey, :unique => true
    
    
    create_table :fields do |t|
      t.integer :fieldset_id
      t.string :name
      t.string :label, :required => true
      t.string :field_type, :required => true
      t.boolean :required, :default => false
      t.boolean :enabled, :default => true
      t.integer :order_num, :required => true

      t.timestamps
    end
    
    create_table :field_options do |t|
      t.integer :field_id
      t.string :name
      t.boolean :enabled, :default => true
    
      t.timestamps
    end
      
    create_table :field_defaults do |t|
      t.integer :field_id
      t.string :value
      
      t.timestamps
    end  
    
    create_table :field_html_attributes do |t|
      t.integer :field_id
      t.string :attribute_name, :required => true # couldn't use attribute because it is used by active record
      t.string :value, :required => true

      t.timestamps
    end

    create_table :field_records do |t|
      t.integer :fieldset_associator_id
      t.integer :field_id
      t.text :value
    end
  end

  def self.down
    drop_table :fieldsets
    drop_table :fields
    drop_table :field_options
    drop_table :field_defaults
    drop_table :field_html_attributes
    drop_table :field_records
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dynamic_fieldsets-0.0.3 spec/dummy/db/migrate/20110726215814_create_dynamic_fieldsets_tables.rb
dynamic_fieldsets-0.0.2 spec/dummy/db/migrate/20110726215814_create_dynamic_fieldsets_tables.rb