Support associations (no has_and_belongs_to)
This commit is contained in:
parent
73d5f36357
commit
dc55fc10f1
4 changed files with 45 additions and 6 deletions
|
@ -11,6 +11,6 @@ class Admin::VersionsController < Admin::BaseController
|
|||
private
|
||||
|
||||
def set_version
|
||||
@version = PaperTrail::Version.find(params[:id]).reify
|
||||
@version = PaperTrail::Version.find(params[:id]).reify(has_one: true)
|
||||
end
|
||||
end
|
||||
|
|
17
db/migrate/20151014121823_create_version_associations.rb
Normal file
17
db/migrate/20151014121823_create_version_associations.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
class CreateVersionAssociations < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :version_associations do |t|
|
||||
t.integer :version_id
|
||||
t.string :foreign_key_name, :null => false
|
||||
t.integer :foreign_key_id
|
||||
end
|
||||
add_index :version_associations, [:version_id]
|
||||
add_index :version_associations, [:foreign_key_name, :foreign_key_id], :name => 'index_version_associations_on_foreign_key'
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_index :version_associations, [:version_id]
|
||||
remove_index :version_associations, :name => 'index_version_associations_on_foreign_key'
|
||||
drop_table :version_associations
|
||||
end
|
||||
end
|
|
@ -0,0 +1,11 @@
|
|||
class AddTransactionIdColumnToVersions < ActiveRecord::Migration
|
||||
def self.up
|
||||
add_column :versions, :transaction_id, :integer
|
||||
add_index :versions, [:transaction_id]
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_index :versions, [:transaction_id]
|
||||
remove_column :versions, :transaction_id
|
||||
end
|
||||
end
|
13
db/schema.rb
13
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20151009204428) do
|
||||
ActiveRecord::Schema.define(version: 20151014121824) do
|
||||
|
||||
create_table "awaken_types", force: :cascade do |t|
|
||||
t.string "name"
|
||||
|
@ -134,6 +134,15 @@ ActiveRecord::Schema.define(version: 20151009204428) do
|
|||
|
||||
add_index "users_roles", ["user_id", "role_id"], name: "index_users_roles_on_user_id_and_role_id"
|
||||
|
||||
create_table "version_associations", force: :cascade do |t|
|
||||
t.integer "version_id"
|
||||
t.string "foreign_key_name", null: false
|
||||
t.integer "foreign_key_id"
|
||||
end
|
||||
|
||||
add_index "version_associations", ["foreign_key_name", "foreign_key_id"], name: "index_version_associations_on_foreign_key"
|
||||
add_index "version_associations", ["version_id"], name: "index_version_associations_on_version_id"
|
||||
|
||||
create_table "versions", force: :cascade do |t|
|
||||
t.string "item_type", null: false
|
||||
t.integer "item_id", null: false
|
||||
|
@ -141,8 +150,10 @@ ActiveRecord::Schema.define(version: 20151009204428) do
|
|||
t.string "whodunnit"
|
||||
t.text "object", limit: 1073741823
|
||||
t.datetime "created_at"
|
||||
t.integer "transaction_id"
|
||||
end
|
||||
|
||||
add_index "versions", ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id"
|
||||
add_index "versions", ["transaction_id"], name: "index_versions_on_transaction_id"
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue