Module: RedmineCrm::ActsAsDraftable::Migration

Defined in:
lib/redmine_crm/acts_as_draftable/rcrm_acts_as_draftable.rb

Overview

InstanceMethods

Instance Method Summary collapse

Instance Method Details

#create_drafts_tableObject



148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/redmine_crm/acts_as_draftable/rcrm_acts_as_draftable.rb', line 148

def create_drafts_table
  return if connection.table_exists?(:drafts)

  connection.create_table :drafts do |t|
    t.string :target_type, limit: 150, null: false
    t.references :user
    t.references :parent, polymorphic: true
    t.binary :data, limit: 16777215, null: false
    t.datetime :updated_at, null: false
  end

  connection.add_index :drafts, [:user_id, :target_type]
end

#drop_drafts_tableObject



162
163
164
# File 'lib/redmine_crm/acts_as_draftable/rcrm_acts_as_draftable.rb', line 162

def drop_drafts_table
  connection.drop_table :drafts if connection.table_exists?(:drafts)
end