summaryrefslogtreecommitdiffstats
path: root/lib/puppet/rails/database
diff options
context:
space:
mode:
authorJames Turnbull <james@lovedthanlost.net>2008-08-23 08:10:16 +1000
committerJames Turnbull <james@lovedthanlost.net>2008-08-23 08:10:16 +1000
commit5851061d8e6d1dded479b33f7a8da67a3346891c (patch)
tree0438347f183fb9a00e2d08c074f859b51fc2216c /lib/puppet/rails/database
parent67387e285cb39993c891d7decac34952ea64dbdb (diff)
parent7accb893d8b4a530aac7ccd402756afb0ce599bd (diff)
downloadpuppet-5851061d8e6d1dded479b33f7a8da67a3346891c.tar.gz
puppet-5851061d8e6d1dded479b33f7a8da67a3346891c.tar.xz
puppet-5851061d8e6d1dded479b33f7a8da67a3346891c.zip
Merge branch 'tickets/0.24.x/1506' into 0.24.x
Diffstat (limited to 'lib/puppet/rails/database')
-rw-r--r--lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb17
-rw-r--r--lib/puppet/rails/database/schema.rb8
2 files changed, 17 insertions, 8 deletions
diff --git a/lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb b/lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb
new file mode 100644
index 000000000..3873a13e2
--- /dev/null
+++ b/lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb
@@ -0,0 +1,17 @@
+class RemoveDuplicatedIndexOnAllTables < ActiveRecord::Migration
+ def self.up
+ ActiveRecord::Base.connection.tables.each do |t|
+ if ActiveRecord::Base.connection.indexes(t).collect {|c| c.columns}.include?("id")
+ remove_index t.to_s, :id
+ end
+ end
+ end
+
+ def self.down
+ ActiveRecord::Base.connection.tables.each do |t|
+ unless ActiveRecord::Base.connection.indexes(t).collect {|c| c.columns}.include?("id")
+ add_index t.to_s, :id, :integer => true
+ end
+ end
+ end
+end
diff --git a/lib/puppet/rails/database/schema.rb b/lib/puppet/rails/database/schema.rb
index d11d91aa5..f3ad2c11e 100644
--- a/lib/puppet/rails/database/schema.rb
+++ b/lib/puppet/rails/database/schema.rb
@@ -16,7 +16,6 @@ class Puppet::Rails::Schema
t.column :updated_at, :datetime
t.column :created_at, :datetime
end
- add_index :resources, :id, :integer => true
add_index :resources, :host_id, :integer => true
add_index :resources, :source_file_id, :integer => true
@@ -34,7 +33,6 @@ class Puppet::Rails::Schema
t.column :updated_at, :datetime
t.column :created_at, :datetime
end
- add_index :source_files, :id, :integer => true
add_index :source_files, :filename
create_table :resource_tags do |t|
@@ -43,7 +41,6 @@ class Puppet::Rails::Schema
t.column :updated_at, :datetime
t.column :created_at, :datetime
end
- add_index :resource_tags, :id, :integer => true
add_index :resource_tags, :resource_id, :integer => true
add_index :resource_tags, :puppet_tag_id, :integer => true
@@ -65,7 +62,6 @@ class Puppet::Rails::Schema
t.column :source_file_id, :integer
t.column :created_at, :datetime
end
- add_index :hosts, :id, :integer => true
add_index :hosts, :source_file_id, :integer => true
add_index :hosts, :name
@@ -74,7 +70,6 @@ class Puppet::Rails::Schema
t.column :updated_at, :datetime
t.column :created_at, :datetime
end
- add_index :fact_names, :id, :integer => true
add_index :fact_names, :name
create_table :fact_values do |t|
@@ -84,7 +79,6 @@ class Puppet::Rails::Schema
t.column :updated_at, :datetime
t.column :created_at, :datetime
end
- add_index :fact_values, :id, :integer => true
add_index :fact_values, :fact_name_id, :integer => true
add_index :fact_values, :host_id, :integer => true
@@ -96,7 +90,6 @@ class Puppet::Rails::Schema
t.column :updated_at, :datetime
t.column :created_at, :datetime
end
- add_index :param_values, :id, :integer => true
add_index :param_values, :param_name_id, :integer => true
add_index :param_values, :resource_id, :integer => true
@@ -105,7 +98,6 @@ class Puppet::Rails::Schema
t.column :updated_at, :datetime
t.column :created_at, :datetime
end
- add_index :param_names, :id, :integer => true
add_index :param_names, :name
end
end