Sha256: d8abac4df22c3f4aaefab3868dc599ada499fe47bb49136cef8ef3fbc11a150c

Contents?: true

Size: 1.78 KB

Versions: 15

Compression:

Stored size: 1.78 KB

Contents

class <%= migration_class_name %> < ActiveRecord::Migration<%= Rails::VERSION::MAJOR >= 5 ? "[#{ActiveRecord::Migration.current_version}]" : "" %>
  def change
    create_table :<%= table_name %><%= respond_to?(:primary_key_type) ? primary_key_type : "" %> do |t|
<% attributes.each do |attribute| -%>
<% if attribute.password_digest? -%>
      t.string :password_digest<%= attribute.inject_options %>
<% elsif attribute.respond_to?(:token?) && attribute.token? -%>
      t.string :<%= attribute.name %><%= attribute.inject_options %>
<% else -%>
      t.<%= attribute.type %> :<%= attribute.name %><%= attribute.inject_options %>
<% end -%>
<% end -%>

      # columns for CronoTrigger::Schedulable
      t.string    :cron
      t.datetime  :next_execute_at
      t.datetime  :last_executed_at
      t.string    :timezone
      t.integer   :execute_lock, limit: 8, default: 0, null: false
      t.string    :locked_by
      t.datetime  :started_at
      t.datetime  :finished_at
      t.string    :last_error_name
      t.string    :last_error_reason
      t.datetime  :last_error_time
      t.integer   :retry_count, default: 0, null: false

<% if options[:timestamps] %>
      t.timestamps<%= Rails::VERSION::MAJOR >=5 ? " null: false" : "" %>
<% end -%>
    end
<% attributes.select { |attribute| attribute.respond_to?(:token?) && attribute.token? }.each do |attribute| -%>
    add_index :<%= table_name %>, :<%= attribute.index_name %><%= attribute.inject_index_options %>, unique: true
<% end -%>
<% attributes_with_index.each do |attribute| -%>
    add_index :<%= table_name %>, :<%= attribute.index_name %><%= attribute.inject_index_options %>
<% end -%>
    add_index :<%= table_name %>, [:next_execute_at, :execute_lock, :started_at, :finished_at], name: "crono_trigger_index_on_<%= table_name %>"
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
crono_trigger-0.8.3 lib/generators/crono_trigger/migration/templates/create_table_migration.rb
crono_trigger-0.8.1 lib/generators/crono_trigger/migration/templates/create_table_migration.rb
crono_trigger-0.8.0 lib/generators/crono_trigger/migration/templates/create_table_migration.rb
crono_trigger-0.7.1 lib/generators/crono_trigger/migration/templates/create_table_migration.rb
crono_trigger-0.7.0 lib/generators/crono_trigger/migration/templates/create_table_migration.rb
crono_trigger-0.6.4 lib/generators/crono_trigger/migration/templates/create_table_migration.rb
crono_trigger-0.6.3 lib/generators/crono_trigger/migration/templates/create_table_migration.rb
crono_trigger-0.6.2 lib/generators/crono_trigger/migration/templates/create_table_migration.rb
crono_trigger-0.6.1 lib/generators/crono_trigger/migration/templates/create_table_migration.rb
crono_trigger-0.6.0 lib/generators/crono_trigger/migration/templates/create_table_migration.rb
crono_trigger-0.5.4 lib/generators/crono_trigger/migration/templates/create_table_migration.rb
crono_trigger-0.5.3 lib/generators/crono_trigger/migration/templates/create_table_migration.rb
crono_trigger-0.5.2 lib/generators/crono_trigger/migration/templates/create_table_migration.rb
crono_trigger-0.5.1 lib/generators/crono_trigger/migration/templates/create_table_migration.rb
crono_trigger-0.5.0 lib/generators/crono_trigger/migration/templates/create_table_migration.rb