Sha256: 31b94a6d809b2d598aa60de0650700fea444bbbf5297e0f68088c87dd3ac0f62

Contents?: true

Size: 1.61 KB

Versions: 35

Compression:

Stored size: 1.61 KB

Contents

Sequel.migration do
  <%- if use_change -%>
  change do
    <%= table_action %>_table :<%= table_name %> do
      <%- if table_action == 'create' -%>
      primary_key :id
      <%- end -%>
      <%- attributes.each do |attribute| -%>
      <%- if table_action == 'create' -%>
      <%= attribute.type_class %> :<%= attribute.name %>
      <%- else -%>
      <%= column_action %>_column :<%= attribute.name %><% if column_action == 'add' %>, <%= attribute.type_class %><% end %>
      <%- end -%>
      <%- end -%>
    end
  end
  <%- else -%>
  up do
    <%- if table_action == 'drop' -%>
    drop_table :<%= table_name %>
    <%- else -%>
    <%= table_action %>_table :<%= table_name %> do
      <%- attributes.each do |attribute| -%>
      <%- if table_action == 'create' -%>
      <%= attribute.type_class %> :<%= attribute.name %>
      <%- else -%>
      <%= column_action %>_column :<%= attribute.name %><% if column_action == 'add' %>, <%= attribute.type_class %><% end %>
      <%- end -%>
      <%- end -%>
    end
    <%- end -%>
  end

  down do
    <%- alter_table_action = (table_action == 'drop') ? 'create' : table_action -%>
    <%- alter_column_action = (column_action == 'add') ? 'drop' : 'add' -%>
    <%= alter_table_action %>_table :<%= table_name %> do
      <%- attributes.each do |attribute| -%>
      <%- if alter_table_action == 'create' -%>
      <%= attribute.type_class %> :<%= attribute.name %>
      <%- else -%>
      <%= alter_column_action %>_column :<%= attribute.name %><% if alter_column_action == 'add' %>, <%= attribute.type_class %><% end %>
      <%- end -%>
      <%- end -%>
    end
  end
  <%- end -%>
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
sequel-rails-0.9.0 lib/generators/sequel/migration/templates/migration.rb.erb
sequel-rails-0.8.0 lib/generators/sequel/migration/templates/migration.rb.erb
sequel-rails-0.7.0 lib/generators/sequel/migration/templates/migration.rb.erb
sequel-rails-0.6.1 lib/generators/sequel/migration/templates/migration.rb.erb
sequel-rails-0.6.0 lib/generators/sequel/migration/templates/migration.rb.erb
sequel-rails-0.5.1 lib/generators/sequel/migration/templates/migration.rb.erb
sequel-rails-0.5.0 lib/generators/sequel/migration/templates/migration.rb.erb
sequel-rails-0.4.4 lib/generators/sequel/migration/templates/migration.rb.erb
sequel-rails-0.4.3 lib/generators/sequel/migration/templates/migration.rb.erb
sequel-rails-0.4.2 lib/generators/sequel/migration/templates/migration.rb.erb
sequel-rails-0.4.1 lib/generators/sequel/migration/templates/migration.rb.erb
sequel-rails-0.4.0 lib/generators/sequel/migration/templates/migration.rb.erb
sequel-rails-0.4.0.pre2 lib/generators/sequel/migration/templates/migration.rb.erb
sequel-rails-0.4.0.pre1 lib/generators/sequel/migration/templates/migration.rb.erb
sequel-rails-0.4.0.pre lib/generators/sequel/migration/templates/migration.rb.erb